當前位置: 首頁>>代碼示例>>Java>>正文


Java TableCell類代碼示例

本文整理匯總了Java中com.meterware.httpunit.TableCell的典型用法代碼示例。如果您正苦於以下問題:Java TableCell類的具體用法?Java TableCell怎麽用?Java TableCell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TableCell類屬於com.meterware.httpunit包,在下文中一共展示了TableCell類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doTest

import com.meterware.httpunit.TableCell; //導入依賴的package包/類
/**
 * Check that css classes are set correctly according to the ones in setProperty tags.
 * @param jspName jsp name, with full path
 * @throws Exception any axception thrown during test.
 */
@Override
@Test
public void doTest() throws Exception
{

    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled())
    {
        log.debug("RESPONSE: " + response.getText());
    }

    WebTable[] tables = response.getTables();

    Assert.assertEquals("Expected 1 table in result.", 1, tables.length);
    TableCell cell = tables[0].getTableCell(0, 0);
    Assert.assertTrue("Expected css class \"green\" not found", StringUtils.contains(cell.getClassName(), "green"));
    Assert.assertTrue(
        "Expected css class \"purple\" not found",
        StringUtils.contains(cell.getClassName(), "purple"));
}
 
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:29,代碼來源:CssPropertyTest.java

示例2: checkOnlyOneSorted

import com.meterware.httpunit.TableCell; //導入依賴的package包/類
/**
 * Check that only the expected column is sorted.
 * @param response WebResponse
 * @param sortedColumn expected sorted column number
 * @throws SAXException in processing WebTables
 */
private void checkOnlyOneSorted(WebResponse response, int sortedColumn) throws SAXException
{
    WebTable[] tables = response.getTables();

    Assert.assertEquals("Wrong number of tables.", 1, tables.length);
    Assert.assertEquals("Wrong number of columns in result.", 4, tables[0].getColumnCount());

    for (int j = 0; j < 4; j++)
    {
        TableCell cell = tables[0].getTableCell(0, j);
        boolean containsSorted = (cell.getAttribute("class").indexOf("sorted") > -1);
        if (j == sortedColumn)
        {
            Assert.assertTrue("Column " + j + " is not sorted as expected", containsSorted);
        }
        else
        {
            Assert.assertFalse(
                "Column " + j + " is sorted, but only " + sortedColumn + " should be",
                containsSorted);
        }

    }

}
 
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:32,代碼來源:Displ017Test.java

示例3: doTest

import com.meterware.httpunit.TableCell; //導入依賴的package包/類
/**
 * Check variable style and class attributes.
 * @param jspName jsp name, with full path
 * @throws Exception any axception thrown during test.
 */
@Override
@Test
public void doTest() throws Exception
{
    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled())
    {
        log.debug(response.getText());
    }

    WebTable[] tables = response.getTables();
    Assert.assertEquals("Wrong number of tables in result.", 1, tables.length);
    Assert.assertEquals("Wrong number of rows in result.", 3, tables[0].getRowCount());

    if (log.isDebugEnabled())
    {
        log.debug(response.getText());
    }

    TableCell row1Cell = tables[0].getTableCell(1, 0);
    Assert.assertEquals("Wrong style attribute.", "style-1", row1Cell.getAttribute("style"));
    Assert.assertEquals("Wrong class attribute.", "class-1", row1Cell.getClassName());

    TableCell row2Cell = tables[0].getTableCell(2, 0);
    Assert.assertEquals("Wrong style attribute.", "style-2", row2Cell.getAttribute("style"));
    Assert.assertEquals("Wrong class attribute.", "class-2", row2Cell.getClassName());
}
 
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:35,代碼來源:Displ049Test.java

示例4: doTest

import com.meterware.httpunit.TableCell; //導入依賴的package包/類
/**
 * Check content and ids in generated tables.
 * @param jspName jsp name, with full path
 * @throws Exception any axception thrown during test.
 */
@Override
@Test
public void doTest() throws Exception
{
    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
    WebResponse response;

    response = runner.getResponse(request);

    WebTable[] tables = response.getTables();
    Assert.assertEquals("Wrong number of tables.", 1, tables.length);
    WebTable table = tables[0];

    Assert.assertEquals("invalid id", "idX", table.getID());

    Assert.assertEquals("invalid attribute value", "cellspacingX", table.getAttribute("cellspacing"));
    Assert.assertEquals("invalid attribute value", "cellpaddingX", table.getAttribute("cellpadding"));
    Assert.assertEquals("invalid attribute value", "frameX", table.getAttribute("frame"));
    Assert.assertEquals("invalid attribute value", "rulesX", table.getAttribute("rules"));
    Assert.assertEquals("invalid attribute value", "styleX", table.getAttribute("style"));
    Assert.assertEquals("invalid attribute value", "summaryX", table.getAttribute("summary"));
    Assert.assertEquals("invalid attribute value", "classX table", table.getAttribute("class"));

    TableCell cell = table.getTableCell(1, 0);
    Assert.assertEquals("invalid attribute value", "styleX", cell.getAttribute("style"));
    Assert.assertEquals("invalid attribute value", "classX", cell.getAttribute("class"));

}
 
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:34,代碼來源:HtmlAttributesTest.java

示例5: testColourGraphAndLegend

import com.meterware.httpunit.TableCell; //導入依賴的package包/類
public void testColourGraphAndLegend() throws Exception
{
	// Open a graph page and get the tab
	// Obtain the upload page on the website
	WebRequest request = new GetMethodWebRequest(m_testUtil.getUrlPmgraph()
			+ "?start=0&end=300000");
	WebResponse response = m_conversation.getResponse(request);
	// Get the table data from the page
	WebTable legend = (WebTable) response.getElementWithID(TestUtils.LEGEND_TBL);
	
	// Get the data from the chart. We use the renderer object to get the colour.
	JFreeChart chart;
	GraphFactory graphFactory = new GraphFactory();		
	RequestParams requestParams = new RequestParams(0, 300000, View.LOCAL_IP, 5);
	chart = graphFactory.stackedThroughputGraph(requestParams);
	XYPlot plot = (XYPlot) chart.getPlot();
	XYItemRenderer renderer = plot.getRenderer();

	// The two first rows are for the header
	for (int i = 2; i < legend.getRowCount() - 1; i++)
	{
		// Get the first cell of each row in html format and get the style
		// attribute which is the one used to define the colour in the
		// legend
		TableCell colourLegend = legend.getTableCell(i, 0);
		String legendStyle = colourLegend.getAttribute("style");
		
		// Go through the legendStyle string and extract the colour substring which starts with #
		String colourHex = null;
		for (int n = 0; n < legendStyle.length(); n++)
		{
			if (legendStyle.charAt(n) == '#')
			{
				colourHex = legendStyle.substring(n, n + 7);
			}
		}
		// Now we can compare the Graph Colour to the Legend Colour
		//
		// Get the colour for each graph series in RGB format, and 
		// convert it to hexadecimal format in the assertEquals
		Color graphColour = (Color) renderer.getSeriesPaint(i - 2);
		assertEquals("Colour check", "#"
				+ Integer.toHexString(graphColour.getRGB() & 0x00ffffff), colourHex);
	}
}
 
開發者ID:aptivate,項目名稱:pmgraph,代碼行數:46,代碼來源:ColourTest.java

示例6: doTest

import com.meterware.httpunit.TableCell; //導入依賴的package包/類
/**
 * No exception when an invalid page is requested.
 * @param jspName jsp name, with full path
 * @throws Exception any axception thrown during test.
 */
@Override
@Test
public void doTest() throws Exception
{
    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));

    ParamEncoder encoder = new ParamEncoder("table");
    String pageParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_PAGE);
    request.setParameter(pageParameter, "2");

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled())
    {
        log.debug(response.getText());
    }

    WebTable[] tables = response.getTables();
    Assert.assertEquals("Wrong number of tables in result.", 1, tables.length);
    Assert.assertEquals("Wrong number of rows in result.", 3, tables[0].getRowCount());

    if (log.isDebugEnabled())
    {
        log.debug(response.getText());
    }

    Assert.assertEquals("Wrong column header.", "Number", tables[0].getCellAsText(0, 0));
    Assert.assertEquals("Wrong column content.", "3", tables[0].getCellAsText(1, 0));
    Assert.assertEquals("Wrong column content.", "4", tables[0].getCellAsText(2, 0));

    TableCell headerCell = tables[0].getTableCell(0, 0);

    String cssClass = headerCell.getClassName();
    assertEqualsIgnoreOrder(
        "Wrong css attributes.",
        new String[]{"sortable", "sorted", "order2"},
        StringUtils.split(cssClass));

    WebLink[] headerLinks = headerCell.getLinks();
    Assert.assertEquals("Sorting link not found.", 1, headerLinks.length);
    WebLink sortingLink = headerLinks[0];
    assertEqualsIgnoreOrder(
        "Wrong parameters.",
        new String[]{"sort", "searchid", "dir", pageParameter},
        sortingLink.getParameterNames());

    HTMLElement pagebanner = response.getElementWithID("pagebanner");
    Assert.assertEquals("Wrong page banner", "10|3|4", pagebanner.getText());
    HTMLElement pagelinks = response.getElementWithID("pagelinks");
    Assert.assertEquals("Wrong page links", "1|[2]|3|4|5", pagelinks.getText());

}
 
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:58,代碼來源:Displ129Test.java


注:本文中的com.meterware.httpunit.TableCell類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。