本文整理汇总了Java中com.meterware.httpunit.WebResponse.getTableWithID方法的典型用法代码示例。如果您正苦于以下问题:Java WebResponse.getTableWithID方法的具体用法?Java WebResponse.getTableWithID怎么用?Java WebResponse.getTableWithID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.WebResponse
的用法示例。
在下文中一共展示了WebResponse.getTableWithID方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSomeFailures
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testSomeFailures() throws Exception {
ServletUnitClient client = newClient();
WebResponse wr = client.getResponse( "http://localhost/JUnit?test=" + FailingTests.class.getName() );
final WebTable resultsTable = wr.getTableWithID( "results" );
assertNotNull( "Did not find results table", resultsTable );
final String[][] results = resultsTable.asText();
assertEquals( "Num rows", 4, results.length );
assertEquals( "Num columns", 3, results[0].length );
assertEquals( "First header", "3 tests", results[0][0] );
assertEquals( "Status", "Problems Occurred", results[0][2] );
assertEquals( "Failure header", "2 failures", results[1][1] );
assertEquals( "Failure index 1", "1", results[2][0] );
assertEquals( "Failure index 2", "2", results[3][0] );
assertTrue( "Test class not found", results[2][1].indexOf( '(' + FailingTests.class.getName() + ')' ) >= 0 );
}
示例2: testScriptedServletAccess
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testScriptedServletAccess() throws Exception {
WebXMLString wxs = new WebXMLString();
Properties params = new Properties();
params.setProperty( "color", "red" );
params.setProperty( "age", "12" );
wxs.addServlet( "simple", "/SimpleServlet", SimpleGetServlet.class, params );
wxs.addServlet( "/JUnit", TestRunnerServlet.class );
MyFactory._runner = _runner = new ServletRunner( wxs.asInputStream() );
ServletUnitClient client = _runner.newClient();
WebResponse wr = client.getResponse( "http://localhost/JUnit?test=" + ServletAccessTest.class.getName() );
final WebTable resultsTable = wr.getTableWithID( "results" );
assertNotNull( "Did not find results table", resultsTable );
final String[][] results = resultsTable.asText();
assertEquals( "Status", "OK", results[0][2] );
}
示例3: testPolicy1
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testPolicy1() {
try {
WebConversation wc = new WebConversation();
WebResponse resp = logOn(wc, "startComponent.do?component=Material.ItemFinder&displayResultsScreen=true", "MAHESH", "dummy");
WebTable table = resp.getTableWithID("material_itemFinderResultsForm_rows");
assertNotNull("Found Table For Checks", table);
String text = null;
text = table.getCellAsText(1,2);
assertTrue("Serial is not D", text.equals("A"));
text = table.getCellAsText(2,2);
assertTrue("Serial is not E", text.equals("B") );
text = table.getCellAsText(3,2);
assertTrue("Serial is not D", text.equals("C"));
text = table.getCellAsText(4,2);
assertTrue("Serial is not E", text.equals("D") );
text = table.getCellAsText(5,2);
assertTrue("Serial is not E", text.equals("E") );
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例4: testPolicy2
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testPolicy2() {
try {
WebConversation wc = new WebConversation();
WebResponse resp = logOn(wc, "startComponent.do?component=Material.ItemFinder&displayResultsScreen=true", "PAUL", "dummy");
WebTable table = resp.getTableWithID("material_itemFinderResultsForm_rows");
assertNotNull("Found Table For Checks", table);
String text = null;
text = table.getCellAsText(1,2);
assertTrue("Serial is not A",text.equals("A") );
text = table.getCellAsText(2,2);
assertTrue( "Serial is not B", text.equals("B"));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例5: testCheckSubnet
import com.meterware.httpunit.WebResponse; //导入方法依赖的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);
}
示例6: testCompareSubnets
import com.meterware.httpunit.WebResponse; //导入方法依赖的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]));
}
}
示例7: testAllTestsPass
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testAllTestsPass() throws Exception {
ServletUnitClient client = newClient();
WebResponse wr = client.getResponse( "http://localhost/JUnit?test=" + PassingTests.class.getName() );
final WebTable resultsTable = wr.getTableWithID( "results" );
assertNotNull( "Did not find results table", resultsTable );
final String[][] results = resultsTable.asText();
assertEquals( "Num rows", 1, results.length );
assertEquals( "Num columns", 3, results[0].length );
assertEquals( "Time header", "1 test", results[0][0] );
assertEquals( "Status", "OK", results[0][2] );
}
示例8: testSomeErrors
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testSomeErrors() throws Exception {
ServletUnitClient client = newClient();
WebResponse wr = client.getResponse( "http://localhost/JUnit?test=" + ErrorTests.class.getName() );
final WebTable resultsTable = wr.getTableWithID( "results" );
assertNotNull( "Did not find results table", resultsTable );
final String[][] results = resultsTable.asText();
assertEquals( "Num rows", 3, results.length );
assertEquals( "Num columns", 3, results[0].length );
assertEquals( "First header", "2 tests", results[0][0] );
assertEquals( "Status", "Problems Occurred", results[0][2] );
assertEquals( "Failure header", "1 error", results[1][1] );
assertEquals( "Failure index 1", "1", results[2][0] );
assertTrue( "Test class not found", results[2][1].indexOf( '(' + ErrorTests.class.getName() + ')' ) >= 0 );
}
示例9: testAddSubnet
import com.meterware.httpunit.WebResponse; //导入方法依赖的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);
}
示例10: testCheckGroups
import com.meterware.httpunit.WebResponse; //导入方法依赖的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)));
}
}
示例11: testClerkAccess
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testClerkAccess() {
try {
WebConversation wc = new WebConversation();
WebResponse resp = logOn(wc, "startComponent.do?component=Test.Security.Test1", "GAUTAM", "dummy");
assertEquals("Got To Main Page", "Test.Security.Test1.Page1", resp.getTitle());
WebTable table = resp.getTableWithID("tagTable");
assertNotNull("Found Table For Checks", table);
String text = null;
// Access Function1 - false
text = table.getCellAsText(0,0);
assertTrue("Empty Row 1", text == null || text.length() == 0);
// No access Function1 - true
text = table.getCellAsText(1,0);
assertTrue("Not empty Row 2", text != null && text.length() > 0);
// Access Function2 - false
text = table.getCellAsText(2,0);
assertTrue("Empty Row 3", text == null || text.length() == 0);
// No access Function2 - true
text = table.getCellAsText(3,0);
assertTrue("Not empty Row 4", text != null && text.length() > 0);
// Access FunctionX - false
text = table.getCellAsText(4,0);
assertTrue("Empty Row 5", text == null || text.length() == 0);
// No access FunctionX - true
text = table.getCellAsText(5,0);
assertTrue("Not empty Row 6", text != null && text.length() > 0);
// Access Component Test.Security.Test2 - false
text = table.getCellAsText(6,0);
assertTrue("Empty Row 7", text == null || text.length() == 0);
// No access Component Test.Security.Test2 - true
text = table.getCellAsText(7,0);
assertTrue("Not empty Row 8", text != null && text.length() > 0);
// Access Component Not.Real.Component - false
text = table.getCellAsText(8,0);
assertTrue("Not empty Row 9", text != null && text.length() > 0);
// No access Component Not.Real.Component - true
text = table.getCellAsText(9,0);
assertTrue("Empty Row 10", text == null || text.length() == 0);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例12: testManagerAccess
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testManagerAccess() {
try {
WebConversation wc = new WebConversation();
WebResponse resp = logOn(wc, "startComponent.do?component=Test.Security.Test1", "PAUL", "dummy");
assertEquals("Got To Main Page", "Test.Security.Test1.Page1", resp.getTitle());
WebTable table = resp.getTableWithID("tagTable");
assertNotNull("Found Table For Checks", table);
String text = null;
// Access Function1 - true
text = table.getCellAsText(0,0);
assertTrue("Empty Row 1", text != null && text.length() > 0);
// No Access Function1 - false
text = table.getCellAsText(1,0);
assertTrue("Not empty Row 2", text == null || text.length() == 0);
// Access Function2 - true
text = table.getCellAsText(2,0);
assertTrue("Not empty Row 3", text != null && text.length() > 0);
// No Access Function2 - false
text = table.getCellAsText(3,0);
assertTrue("Empty Row 4", text == null || text.length() == 0);
// Access FunctionX - false
text = table.getCellAsText(4,0);
assertTrue("Empty Row 5", text == null || text.length() == 0);
// No access FunctionX - true
text = table.getCellAsText(5,0);
assertTrue("Not empty Row 6", text != null && text.length() > 0);
// Access Component Test.Security.Test2 - true
text = table.getCellAsText(6,0);
assertTrue("Empty Row 7", text != null && text.length() > 0);
// No Access Component Test.Security.Test2 - false
text = table.getCellAsText(7,0);
assertTrue("Not Empty Row 8", text == null || text.length() == 0);
// Access Component Not.Real.Component - false
text = table.getCellAsText(8,0);
assertTrue("Not empty Row 9", text != null && text.length() > 0);
// No access Component Not.Real.Component - true
text = table.getCellAsText(9,0);
assertTrue("Empty Row 10", text == null || text.length() == 0);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例13: testFormatSubnetZeros
import com.meterware.httpunit.WebResponse; //导入方法依赖的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);
}