[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit FileUploadTest.java,1.10,1.11 WebFrameTe
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-01-17 19:38:14
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv32318/test/com/meterware/httpunit
Modified Files:
FileUploadTest.java WebFrameTest.java WebLinkTest.java
Log Message:
Make WebLink implement ParameterHolder to support validation and parameter ordering
Index: FileUploadTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FileUploadTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FileUploadTest.java 2002/01/14 18:13:45 1.10
+++ FileUploadTest.java 2002/01/17 19:38:09 1.11
@@ -106,7 +106,7 @@
try {
formSubmit.selectFile( "message", file );
fail( "Should not allow setting of a text parameter to a file value" );
- } catch (IllegalNonFileParameterException e) {
+ } catch (IllegalRequestParameterException e) {
}
}
@@ -126,7 +126,7 @@
try {
formSubmit.selectFile( "message", file );
fail( "Should not allow setting of a file parameter in a form which specifies url-encoding" );
- } catch (MultipartFormRequiredException e) {
+ } catch (IllegalRequestParameterException e) {
}
}
Index: WebFrameTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebFrameTest.java 2001/10/26 14:00:10 1.8
+++ WebFrameTest.java 2002/01/17 19:38:09 1.9
@@ -140,6 +140,36 @@
}
+ public void testDuplicateFrameNames() throws Exception {
+ defineWebPage( "Linker", "This is a trivial page with <a href=Target.html>one link</a>" );
+ defineWebPage( "Target", "This is another page with <a href=Form.html target=\"_top\">one link</a>" );
+ defineWebPage( "Form", "This is a page with a simple form: " +
+ "<form action=submit><input name=name><input type=submit></form>" +
+ "<a href=Linker.html target=red>a link</a>");
+ defineResource( "Frames.html",
+ "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" +
+ "<FRAMESET cols=\"20%,80%\">" +
+ " <FRAME src='SubFrames.html'>" +
+ " <FRAME src=Form.html>" +
+ "</FRAMESET></HTML>" );
+
+ defineResource( "SubFrames.html",
+ "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" +
+ "<FRAMESET cols=\"20%,80%\">" +
+ " <FRAME src=\"Linker.html\">" +
+ " <FRAME src=Form.html>" +
+ "</FRAMESET></HTML>" );
+
+ WebResponse response = _wc.getResponse( getHostPath() + "/Frames.html" );
+ WebResponse linker = getFrameWithURL( _wc, "Linker" );
+ assertNotNull( "Linker not found", linker );
+
+ response = _wc.getResponse( linker.getLinks()[0].getRequest() );
+ WebResponse target = getFrameWithURL( _wc, "Target" );
+ assertTrue( "Second response not the same as source frame contents", response == target );
+ }
+
+
public void testUnnamedFrames() throws Exception {
defineWebPage( "Linker", "This is a trivial page with <a href=Target.html>one link</a>" );
defineWebPage( "Target", "This is another page with <a href=Form.html target=\"_top\">one link</a>" );
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WebLinkTest.java 2001/11/27 16:40:47 1.17
+++ WebLinkTest.java 2002/01/17 19:38:09 1.18
@@ -141,6 +141,17 @@
}
+ public void testLinkImageAsText() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "HasImage", "<a href='somwhere.html' >\r\n<img src='blah.gif' alt='Blah Blah' >\r\n</a>" );
+
+ WebResponse initialPage = wc.getResponse( getHostPath() + "/HasImage.html" );
+ WebLink link = initialPage.getLinks()[0];
+ assertEquals( "Link text", "", link.asText() );
+ initialPage.getLinkWithImageText("Blah Blah");
+ }
+
+
public void testLinkFollowing() throws Exception {
WebConversation wc = new WebConversation();
defineWebPage( "Initial", "Go to <a href=\"Next.html\">the next page.</a> <a name=\"bottom\">Bottom</a>" );
@@ -323,6 +334,38 @@
WebRequest wr = link.getRequest();
assertMatchingSet( "Request parameter names", new String[] { "arg1", "valueless" }, toStringArray( wr.getParameterNames() ) );
assertEquals( "Value of arg1", null, wr.getParameter( "arg1" ) );
+ }
+
+
+ public void testLinkParameterOrder() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "encodedLinks", "<html><head><title>Encode Test</title></head>" +
+ "<body>" +
+ "<a href='/request?arg0=0&arg1&arg0=2&valueless='>request</a>" +
+ "</body></html>" );
+ WebResponse mapPage = wc.getResponse( getHostPath() + "/encodedLinks.html" );
+ WebLink link = mapPage.getLinks()[0];
+ WebRequest wr = link.getRequest();
+ assertMatchingSet( "Request parameter names", new String[] { "arg0", "arg1", "valueless" }, toStringArray( wr.getParameterNames() ) );
+ assertMatchingSet( "Value of arg0", new String[] { "0", "2" }, wr.getParameterValues( "arg0" ) );
+ assertEquals( "Actual query", "arg0=0&arg1&arg0=2&valueless=", wr.getQueryString() );
+ }
+
+
+ public void testLinkParameterValidation() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "encodedLinks", "<html><head><title>Encode Test</title></head>" +
+ "<body>" +
+ "<a href='/request?arg0=0&arg1&arg0=2&valueless='>request</a>" +
+ "</body></html>" );
+ WebResponse mapPage = wc.getResponse( getHostPath() + "/encodedLinks.html" );
+ WebLink link = mapPage.getLinks()[0];
+ WebRequest wr = link.getRequest();
+ wr.setParameter( "arg0", new String[] { "0", "2" } );
+ try {
+ wr.setParameter( "arg0", "3" );
+ fail( "Did not prevent change to link parameters" );
+ } catch (IllegalRequestParameterException e) {}
}
|