当前位置: 首页>>代码示例>>Java>>正文


Java WebTable.getRowCount方法代码示例

本文整理汇总了Java中com.meterware.httpunit.WebTable.getRowCount方法的典型用法代码示例。如果您正苦于以下问题:Java WebTable.getRowCount方法的具体用法?Java WebTable.getRowCount怎么用?Java WebTable.getRowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.meterware.httpunit.WebTable的用法示例。


在下文中一共展示了WebTable.getRowCount方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCheckSubnet

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
public void testCheckSubnet() throws InstantiationException, IllegalAccessException, 
        ClassNotFoundException, SQLException, IOException, SAXException
{
	TestUtils theTestUtils = new TestUtils();
	WebResponse response = loadUrl(theTestUtils);  
	String subnet1 = "10.0.156.";
	String subnet2 = "10.21.21.";
	
	
	boolean isSubnet1 = false;
	boolean isSubnet2 = false;
    WebTable table = response.getTableWithID("TableLocalSubnets");
	for (int i = 1; i < table.getRowCount(); i++)
	{
		String currentSubnet = table.getCellAsText(i, 0);
		if (currentSubnet.equals(subnet1))
			isSubnet1 = true;
		if (currentSubnet.equals(subnet2))
			isSubnet2 = true;
	}
	
	assertTrue(isSubnet1);
	assertFalse(isSubnet2);
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:25,代码来源:TestMultiSubnets.java

示例2: testCompareSubnets

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
public void testCompareSubnets() throws InstantiationException, IllegalAccessException, 
  ClassNotFoundException, SQLException, IOException, SAXException
  {		
String[] vectSubnets = Configuration.getLocalSubnet();

TestUtils theTestUtils = new TestUtils();
WebResponse response = loadUrl(theTestUtils);
WebTable table = response.getTableWithID("TableLocalSubnets");
int numSubnet = table.getRowCount() - SIZE_HEADS;
      assertEquals(numSubnet, vectSubnets.length);
      
      if (numSubnet == vectSubnets.length)
      	for (int i = 0; i < numSubnet; i++)
      	{
      		String currentSubnet = table.getCellAsText(i+1, 0);
      		assertTrue(currentSubnet.equals(vectSubnets[i]));
      	}
  }
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:19,代码来源:TestMultiSubnets.java

示例3: testAddSubnet

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
public void testAddSubnet() throws InstantiationException, IllegalAccessException, 
           ClassNotFoundException, SQLException, IOException, SAXException
{		
	TestUtils theTestUtils = new TestUtils();
	WebRequest request = new GetMethodWebRequest(theTestUtils.getUrlPmgraph() + "configure.jsp");
	WebResponse response = m_conversation.getResponse(request);
	
	WebForm configurationForm = response.getFormWithID("config");
	WebTable table = response.getTableWithID("TableLocalSubnets");
	int oldNumSubnets = table.getRowCount() - SIZE_HEADS;
	String newSubnet = "99.99.99.";
	configurationForm.setParameter("newSubnet", newSubnet);
	configurationForm.submit();
	
	theTestUtils = new TestUtils();
	response = loadUrl (theTestUtils);
	table = response.getTableWithID("TableLocalSubnets");
	int numSubnets = table.getRowCount() - SIZE_HEADS;
	assertTrue(numSubnets > oldNumSubnets);
    	assertEquals(table.getCellAsText(numSubnets,0), newSubnet);
    	
    	configurationForm = response.getFormWithID("config");
    FormControl aux = configurationForm.getControlWithID("delSubnet"+numSubnets);
	aux.toggle();
	configurationForm.submit();	
	
	response = loadUrl (theTestUtils);
	table = response.getTableWithID("TableLocalSubnets");
	numSubnets = table.getRowCount() - SIZE_HEADS;
	assertTrue(numSubnets == oldNumSubnets);
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:32,代码来源:TestMultiSubnets.java

示例4: testCheckGroups

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
public void testCheckGroups() throws Exception
{						
	TestUtils testUtils = new TestUtils();
	WebResponse response = loadUrl(testUtils);
	WebTable table = response.getTableWithID("TableGroups");
	if (Groups.size() > 0)
	{
		for (int i = 1; i < table.getRowCount(); i++)		
			assertTrue(table.getCellAsText(i, 0).contains(Groups.get(i-1)));
	}
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:12,代码来源:TestGroups.java

示例5: rowOf

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
/**
 * Return the first row of the table where the given text occurs in the 2nd
 * column. The table is the first table of the page.
 * @param text The text to look for in the second column of each row.
 * @return The first row where the text occurs.
 * @throws SAXException
 */
protected int rowOf(String text) throws SAXException {
  WebTable table = resp.getTables()[0];
  assertNotNull(table);
  
  int row = 0;
  while (row < table.getRowCount() && !table.getTableCell(row, 1).asText()
      .equals(text))
    row ++;
      
  assertTrue("The text \"" + text + "\" was not found in any tablerow.",
      row < table.getRowCount());
  return row;
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:21,代码来源:AccessctlTest.java

示例6: rowOfLink

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
/**
 * Return the first row of the table where the given text occurs as text on
 * a link in the 1st column. The table is the first table of the page.
 * @param text The text of the link to search for in the 1st column.
 * @return The first row where a link with the text occurs.
 * @throws SAXException
 */
protected int rowOfLink(String text) throws SAXException {
  WebTable table = resp.getTables()[0];
  assertNotNull(table);
  
  int row = 0;
  while (row < table.getRowCount() && table.getTableCell(row, 0)
      .getLinkWith(text) == null)
    row ++;
      
  assertTrue("A link with the text \"" + text + "\" was not found in any"
      + " tablerow.", 
      row < table.getRowCount());
  return row;
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:22,代码来源:AccessctlTest.java

示例7: testFormatSubnetZeros

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
public void testFormatSubnetZeros() throws InstantiationException, IllegalAccessException, 
ClassNotFoundException, SQLException, IOException, SAXException
{	
	TestUtils theTestUtils = new TestUtils();		
	WebResponse response = loadUrl (theTestUtils);
	WebForm configurationForm = response.getFormWithID("config");
	WebTable table = response.getTableWithID("TableLocalSubnets");
	int oldNumSubnets = table.getRowCount() - SIZE_HEADS;
	String newSubnet = "99.99.99.";		
	configurationForm.setParameter("newSubnet", newSubnet);
	configurationForm.submit();		
	String newSubnet2 = "000.015.255.";
	configurationForm.setParameter("newSubnet", newSubnet2);
	response = configurationForm.submit();
	HTMLElement result = response.getElementWithID("unsuccessResult");
    String resultString =  result.getNode().getFirstChild().getNextSibling().getFirstChild().getNodeValue();
    assertEquals("Incorrect new subnet format. Please try again as follows: 0-255.0-255.0-255.", resultString);
    
	theTestUtils = new TestUtils();
	response = loadUrl (theTestUtils);
	table = response.getTableWithID("TableLocalSubnets");
	int numSubnets = table.getRowCount() - SIZE_HEADS;
	assertTrue(numSubnets > oldNumSubnets);
    	assertEquals(newSubnet, table.getCellAsText((numSubnets),0));
    	//assertEquals(table., "0.15.255.");
    	
    	WebRequest request = new GetMethodWebRequest(theTestUtils.getUrlPmgraph() + "configure.jsp?newSubnet=099.099.099.&numSubnets="+numSubnets);
    response = m_conversation.getResponse(request);
    result = response.getElementWithID("unsuccessResult");
    resultString =  result.getNode().getFirstChild().getNextSibling().getFirstChild().getNodeValue();
    assertEquals("Incorrect new subnet format. Please try again as follows: 0-255.0-255.0-255.", resultString);
	
    response = loadUrl (theTestUtils);
    	configurationForm = response.getFormWithID("config");
    FormControl aux = configurationForm.getControlWithID("delSubnet"+numSubnets);
	aux.toggle();
	configurationForm.submit();	
	
	response = loadUrl (theTestUtils);
	table = response.getTableWithID("TableLocalSubnets");
	numSubnets = table.getRowCount() - SIZE_HEADS;
	assertEquals(oldNumSubnets, numSubnets);
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:44,代码来源:TestMultiSubnets.java

示例8: testColourGraphAndLegend

import com.meterware.httpunit.WebTable; //导入方法依赖的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

示例9: checkUploadDownloadLegendTable

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
/**
 * Just check if the donwloaded and uploaded values of a legend table match
 * the values specified by the parameters.
 * 
 * @param table
 * @param downloaded
 * @param uploaded
 * @param rows
 * @param view
 * @throws IOException
 * @throws SAXException
 */
protected void checkUploadDownloadLegendTable(WebTable table, long downloaded[],
		long uploaded[], String rows[], View view) throws IOException, SAXException
{
	// Check the table data
	// The data starts in the third row because the first two are the table headers
	int j = 2;	
	int i = 0;
	int totalDownloaded = 0;
	int totalUploaded = 0;
	while (j < table.getRowCount() - 1)	
	{	
		totalDownloaded += downloaded[i];
		totalUploaded += uploaded[i];
		if (table.getCellAsText(j,1).equals(""))
		{
			j++;
		}
		assertEquals("Check the IP Or Port Address", rows[i], table.getCellAsText(j, 1));
		switch (view)
		{
			default:
			case LOCAL_IP:
				// Columns in the table are Colour, Host IP, Host Name,
				// Downloaded, Uploaded, avg downloaded, avg uploaded
				assertEquals("Check the Downloaded Value", String.valueOf(downloaded[i]), 
						table.getCellAsText(j, 3));
				assertEquals("Check the Uploaded Value", String.valueOf(uploaded[i]), 
						table.getCellAsText(j, 4));
			break;
			case LOCAL_PORT:
				// Columns in the table are Colour, port, protocol, service,
				// Downloaded, Uploaded, average downloaded, average uploaded
				assertEquals("Check the Downloaded Value", String.valueOf(downloaded[i]), 
						table.getCellAsText(j, 2));
				assertEquals("Check the Uploaded Value", String.valueOf(uploaded[i]), 
						table.getCellAsText(j, 3));
			break;
		}
		i++;
		j++;
	}
	if(table.getRowCount() > 0)
	{
		assertEquals("Check the total downloaded traffic values", totalDownloaded, Long.parseLong(table.getCellAsText(j, 3)));
		assertEquals("Check the total downloaded traffic values", totalUploaded, Long.parseLong(table.getCellAsText(j, 4)));
	}
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:60,代码来源:LegendTestBase.java

示例10: checkUploadDownloadLegendTable

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
/**
 * Just check if the donwloaded and uploaded values of a legend table match
 * the values specified by the parameters.
 * 
 * @param table
 * @param downloaded
 * @param uploaded
 * @param ipPort
 * @throws IOException
 * @throws SAXException
 */
private void checkUploadDownloadLegendTable(WebTable table,
		long downloaded[], long uploaded[], String ipPort[],
		String serviceHostName[], String services[], long averageDownloaded[], long averageUploaded[])
		throws IOException, SAXException
{

	// Check the table data
	String upload, download, averageUpload, averageDownload;
	// It is i - 2 to avoid the headers in the table
	for (int i = 2; i < table.getRowCount() - 1; i++)
	{
		int column= 1;
		assertEquals("Check the IP Or Port Address", ipPort[i - 2], table
				.getCellAsText(i, column++));
		
		if (table.getColumnCount() == 8) {
			assertEquals("Check the protocol", String
					.valueOf( services[i - 2]), table.getCellAsText(i, column++));				
		}
		
		
		assertEquals("Check the service or Host Name", String
				.valueOf( serviceHostName[i - 2]), table.getCellAsText(i, column++));
		
		
		
		if (downloaded[i - 2] == 0)
			download ="<1";
		else
			download =String.valueOf (downloaded[i - 2]); 
		assertEquals("Check the Downloaded Value", 
				download, table.getCellAsText(i, column++));

		if (uploaded[i - 2] == 0)
			upload ="<1";
		else
			upload =String.valueOf (uploaded[i - 2]);
		
		assertEquals("Check the Uploaded Value", 
				upload, table.getCellAsText(i, column++));
		
		if (averageDownloaded[i - 2] == 0)
			averageDownload ="<1";
		else
			averageDownload =String.valueOf (averageDownloaded[i - 2]); 
		assertEquals("Check the Downloaded average Value", 
				averageDownload, table.getCellAsText(i, column++));

		if (averageUploaded[i - 2] == 0)
			averageUpload ="<1";
		else
			averageUpload =String.valueOf (averageUploaded[i - 2]);
		
		assertEquals("Check the Uploaded average Value", 
				averageUpload, table.getCellAsText(i, column));
	}
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:69,代码来源:LegendTestPortView.java

示例11: testUnitsThroughput

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
public void testUnitsThroughput() throws IOException, SAXException, InstantiationException,
		IllegalAccessException, ClassNotFoundException, SQLException, ConfigurationException
{
	// Time periods to check, in minutes.
	long timePeriod[] = { 8, 250, 15500 };

	for (int i = 0; i < timePeriod.length; i++)
	{
		LegendData data = new LegendData();
		RequestParams requestParams = new RequestParams(0, timePeriod[i] * 60000,
				View.LOCAL_IP, 5);
		Hashtable<Integer,List<DataPoint>> resultsHash = data.getLegendData(requestParams.getSortBy(),
						requestParams.getOrder(), requestParams, false);
		String addUrl = "?start=0&end=" + (timePeriod[i] * 60000);			
		// Obtain the upload page on web site
		WebRequest request = new GetMethodWebRequest(m_testUtils.getUrlPmgraph() + addUrl);
		WebResponse response = m_conversation.getResponse(request);

		WebTable legend = (WebTable) response.getElementWithID(TestUtils.LEGEND_TBL);
		
		//Check if the legend units matches the period of time
		String totalThroughput = legend.getCellAsText(0, 3);
		String expectedLabel = null;
		if (timePeriod[i] < 10)
		{
			expectedLabel = "Totals (KB)";
		}
		else
		{
			if ((timePeriod[i] >= 10) && (timePeriod[i] < 14400))
			{
				expectedLabel ="Totals (MB)";
			}
			else
			{
				expectedLabel = "Totals (GB)";
			}
		}
		
		assertEquals("Check if the header in the legend matches the units we are using",
				totalThroughput, expectedLabel);
		
		//Check the values shown are correct
		long bitsToDivideBy;
		for (int j = 2; j < legend.getRowCount() - 1; j++)
		{
			// KB
			if (timePeriod[i] < 10)
				bitsToDivideBy = 1024;
			else{
				// MB
				if ((timePeriod[i] >= 10) && (timePeriod[i] < 14400))
					bitsToDivideBy = 1024*1024;
				// GB
				else
					bitsToDivideBy = 1024*1024*1024;
			}
			for (Enumeration e = resultsHash.keys (); e.hasMoreElements ();) 
			{
				int key = (Integer) e.nextElement();
				List<DataPoint> throughput = resultsHash.get(key);
				
				String databaseValueDown = String.valueOf(throughput.get(j-2).getDownloaded()/bitsToDivideBy);
				//if the result is zero change it for "<1" as in the legend
				if (databaseValueDown.equals("0"))
					databaseValueDown = "<1";
				String databaseValueUp = String.valueOf(throughput.get(j-2).getUploaded()/bitsToDivideBy);
				if (databaseValueUp.equals("0"))
					databaseValueUp = "<1";
				assertEquals(
					"Check if the downloaded throughput in the legend matches the units we are using",
						legend.getCellAsText(j, 3), databaseValueDown);
				assertEquals(
					"Check if the uploaded throughput in the legend matches the units we are using",
						legend.getCellAsText(j, 4), databaseValueUp );
			}
		}
	}
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:80,代码来源:LegendTest.java

示例12: doTest

import com.meterware.httpunit.WebTable; //导入方法依赖的package包/类
/**
 * Test for content disposition and filename.
 * @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);

    WebTable[] tables = response.getTables();

    // nested tables don't show up in the count
    Assert.assertEquals("Wrong number of first-level tables", 1, tables.length);
    Assert.assertEquals("Wrong number of columns in main table", 4, tables[0].getColumnCount());
    Assert.assertEquals("Wrong number of rows in main table", 4, tables[0].getRowCount());

    for (int j = 1; j < tables[0].getRowCount(); j++)
    {
        Assert.assertEquals(
            "Content in cell [" + j + ",0] in main table is wrong",
            Integer.toString(j),
            tables[0].getCellAsText(j, 0));
        Assert.assertEquals(
            "Content in cell [" + j + ",1] in main table is wrong",
            KnownValue.ANT,
            tables[0].getCellAsText(j, 1));
        Assert.assertEquals(
            "Content in cell [" + j + ",2] in main table is wrong",
            KnownValue.BEE,
            tables[0].getCellAsText(j, 2));

        WebTable nested = tables[0].getTableCell(j, 3).getFirstMatchingTable(new HTMLElementPredicate()
        {

            @Override
            public boolean matchesCriteria(Object htmlElement, Object criteria)
            {
                return true;
            }
        }, null);

        Assert.assertNotNull("Nested table not found in cell [" + j + ",3]", nested);
        Assert.assertEquals("Wrong number of columns in nested table", 3, nested.getColumnCount());
        Assert.assertEquals("Wrong number of rows in nested table", 4, nested.getRowCount());

        for (int x = 1; x < nested.getRowCount(); x++)
        {
            Assert.assertEquals(
                "Content in cell [" + x + ",0] in nested table is wrong",
                Integer.toString(x),
                nested.getCellAsText(x, 0));
            Assert.assertEquals(
                "Content in cell [" + x + ",1] in nested table is wrong",
                KnownValue.ANT,
                nested.getCellAsText(x, 1));
            Assert.assertEquals(
                "Content in cell [" + x + ",2] in nested table is wrong",
                KnownValue.CAMEL,
                nested.getCellAsText(x, 2));
        }

    }

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:69,代码来源:NestedTest.java


注:本文中的com.meterware.httpunit.WebTable.getRowCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。