[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit WebLinkTest.java,1.10,1.11 WebPageTest.j
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-10-25 14:51:09
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv19806/test/com/meterware/httpunit
Modified Files:
WebLinkTest.java WebPageTest.java
Log Message:
Added search for link by name and id
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WebLinkTest.java 2001/10/24 18:06:28 1.10
+++ WebLinkTest.java 2001/10/25 14:51:05 1.11
@@ -58,9 +58,9 @@
defineResource( "SimplePage.html",
"<html><head><title>A Sample Page</title></head>\n" +
"<body>This has no forms but it does\n" +
- "have <a href=\"/other.html\">an <b>active</b> link</A>\n" +
+ "have <a href=\"/other.html\" id=\"activeID\">an <b>active</b> link</A>\n" +
" and <a name=here>an anchor</a>\n" +
- "<a href=\"basic.html\"><IMG SRC=\"/images/arrow.gif\" ALT=\"Next -->\" WIDTH=1 HEIGHT=4></a>\n" +
+ "<a href=\"basic.html\" name=\"nextLink\"><IMG SRC=\"/images/arrow.gif\" ALT=\"Next -->\" WIDTH=1 HEIGHT=4></a>\n" +
"</body></html>\n" );
WebConversation wc = new WebConversation();
@@ -118,6 +118,20 @@
HttpUnitOptions.setImagesTreatedAsAltText( false );
link = _simplePage.getLinkWith( "Next -->" );
assertNull( "the image link was found based on its hidden alt attribute", link );
+ }
+
+
+ public void testGetLinkByIDAndName() throws Exception {
+ WebLink link = _simplePage.getLinkWithID( "noSuchID" );
+ assertNull( "Non-existent link should not have been found", link );
+
+ link = _simplePage.getLinkWithID( "activeID" );
+ assertNotNull( "an active link was not found", link );
+ assertEquals( "active link URL", getHostPath() + "/other.html", link.getRequest().getURL().toExternalForm() );
+
+ link = _simplePage.getLinkWithName( "nextLink" );
+ assertNotNull( "the image link was not found", link );
+ assertEquals( "image link URL", getHostPath() + "/basic.html", link.getRequest().getURL().toExternalForm() );
}
Index: WebPageTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WebPageTest.java 2001/10/25 14:15:59 1.16
+++ WebPageTest.java 2001/10/25 14:51:05 1.17
@@ -276,6 +276,7 @@
"<meta Http-equiv=\"Expires\" content=\"now\"/>\n" +
"<meta name=\"robots\" content=\"index,follow\"/>" +
"<meta name=\"keywords\" content=\"test\"/>" +
+ "<meta name=\"keywords\" content=\"demo\"/>" +
"</head>\n" +
"<body>This has no data\n" +
"</body></html>\n";
@@ -285,9 +286,9 @@
WebRequest request = new GetMethodWebRequest( getHostPath() + "/SimplePage.html" );
WebResponse simplePage = wc.getResponse( request );
- assertEquals( "robots meta tag","index,follow",simplePage.getMetaTagContent("name","robots"));
- assertEquals( "keywords meta tag","test",simplePage.getMetaTagContent("name","keywords"));
- assertEquals( "Expires meta tag","now",simplePage.getMetaTagContent("http-equiv","Expires"));
+ assertMatchingSet( "robots meta tag", new String[] {"index,follow"}, simplePage.getMetaTagContent("name","robots"));
+ assertMatchingSet( "keywords meta tag",new String[] {"test","demo"},simplePage.getMetaTagContent("name","keywords"));
+ assertMatchingSet( "Expires meta tag",new String[] {"now"},simplePage.getMetaTagContent("http-equiv","Expires"));
}
/**
|