本文整理汇总了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"));
}
示例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);
}
}
}
示例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());
}
示例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"));
}
示例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);
}
}
示例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());
}