[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit FileUploadTest.java,1.6,1.7 FormSubmitTe
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-07-31 16:09:02
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv10743/test/com/meterware/httpunit
Modified Files:
FileUploadTest.java FormSubmitTest.java PseudoServerTest.java
WebFrameTest.java WebLinkTest.java
Log Message:
Minor feature additions and bug fixes
Index: FileUploadTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FileUploadTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FileUploadTest.java 2001/06/11 21:21:09 1.6
+++ FileUploadTest.java 2001/07/31 16:08:59 1.7
@@ -164,6 +164,24 @@
}
+ public void testInputStreamAsFile() throws Exception {
+ ByteArrayInputStream bais = new ByteArrayInputStream( "Not much text\nBut two lines\n".getBytes() );
+
+ defineResource( "ListParams", new MimeEcho() );
+ defineWebPage( "Default", "<form method=POST action = \"ListParams\" enctype=\"multipart/form-data\"> " +
+ "<Input type=file name=message>" +
+ "<Input type=submit name=update value=age>" +
+ "</form>" );
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( getHostPath() + "/Default.html" );
+ WebResponse simplePage = wc.getResponse( request );
+ WebRequest formSubmit = simplePage.getForms()[0].getRequest();
+ formSubmit.selectFile( "message", "temp.txt", bais, "text/plain" );
+ WebResponse encoding = wc.getResponse( formSubmit );
+ assertEquals( "update=age&text/plain:message.name=temp.txt&message.lines=2", encoding.getText().trim() );
+ }
+
+
public void testFileContentType() throws Exception {
File file = new File( "temp.gif" );
FileOutputStream fos = new FileOutputStream( file );
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FormSubmitTest.java 2001/07/17 12:50:47 1.9
+++ FormSubmitTest.java 2001/07/31 16:08:59 1.10
@@ -81,6 +81,19 @@
}
+ public void testFormProperties() throws Exception {
+ defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
+ "<Input type=text name=age value=12>" +
+ "<select name=empty></select>" +
+ "<Input type=submit>" +
+ "</form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getForms()[0];
+ assertEquals( "Form method", "GET", form.getMethod() );
+ assertEquals( "Form action", "/ask", form.getAction() );
+ }
+
+
public void testSubmitString() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age>" +
@@ -118,6 +131,23 @@
}
+ public void testButtonIDDetection() throws Exception {
+ defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
+ "<Input type=text name=age value=12>" +
+ "<Input type=submit id=main name=update>" +
+ "<Input type=submit name=recalculate>" +
+ "</form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getForms()[0];
+ SubmitButton button = form.getSubmitButton( "update" );
+ assertEquals( "Null ID", "", form.getSubmitButton( "recalculate" ).getID() );
+ assertEquals( "Button ID", "main", button.getID() );
+
+ SubmitButton button2 = form.getSubmitButtonWithID( "main" );
+ assertEquals( "Submit button", button, button2 );
+ }
+
+
public void testButtonTagDetection() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age value=12>" +
Index: PseudoServerTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PseudoServerTest.java 2001/07/23 03:05:30 1.15
+++ PseudoServerTest.java 2001/07/31 16:08:59 1.16
@@ -191,6 +191,7 @@
ps.addResourceHeader( resourceName, "Set-Cookie: age=12, name=george" );
ps.addResourceHeader( resourceName, "Set-Cookie: type=short" );
ps.addResourceHeader( resourceName, "Set-Cookie: funky=ab$==" );
+ ps.addResourceHeader( resourceName, "Set-Cookie: p30waco_sso=3.0,en,us,AMERICA,Drew;path=/, PORTAL30_SSO_TEST=X" );
try {
WebConversation wc = new WebConversation();
@@ -198,11 +199,13 @@
WebResponse response = wc.getResponse( request );
assertEquals( "requested resource", resourceValue, response.getText().trim() );
assertEquals( "content type", "text/html", response.getContentType() );
- assertEquals( "number of cookies", 4, wc.getCookieNames().length );
+ assertEquals( "number of cookies", 6, wc.getCookieNames().length );
assertEquals( "cookie 'age' value", "12", wc.getCookieValue( "age" ) );
assertEquals( "cookie 'name' value", "george", wc.getCookieValue( "name" ) );
assertEquals( "cookie 'type' value", "short", wc.getCookieValue( "type" ) );
assertEquals( "cookie 'funky' value", "ab$==", wc.getCookieValue( "funky" ) );
+ assertEquals( "cookie 'p30waco_sso' value", "3.0,en,us,AMERICA,Drew", wc.getCookieValue( "p30waco_sso" ) );
+ assertEquals( "cookie 'PORTAL30_SSO_TEST' value", "X", wc.getCookieValue( "PORTAL30_SSO_TEST" ) );
} finally {
ps.shutDown();
}
Index: WebFrameTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebFrameTest.java 2001/06/13 16:38:20 1.6
+++ WebFrameTest.java 2001/07/31 16:08:59 1.7
@@ -219,7 +219,7 @@
}
- public void testSelfTarget() throws Exception {
+ public void testSelfTargetLink() throws Exception {
defineWebPage( "Linker", "This is a trivial page with <a href=Target.html target=_self>one link</a>" );
_wc.getResponse( getHostPath() + "/Frames.html" );
@@ -230,6 +230,19 @@
}
+ public void testSelfTargetForm() throws Exception {
+ defineWebPage( "Linker", "<form action=redirect.html target=_self><input type=text name=sample value=z></form>" );
+ defineResource( "redirect.html?sample=z", "" );
+ addResourceHeader( "redirect.html?sample=z", "Location: " + getHostPath() + "/Target.html" );
+
+ _wc.getResponse( getHostPath() + "/Frames.html" );
+ WebResponse response = _wc.getResponse( _wc.getFrameContents( "red" ).getForms()[0].getRequest() );
+ assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, _wc.getFrameNames() );
+ assert( "Second response not the same as source frame contents", response == _wc.getFrameContents( "red" ) );
+ assertEquals( "URL for second request", getHostPath() + "/Target.html", response.getURL().toExternalForm() );
+ }
+
+
public void testSubFrameRedirect() throws Exception {
defineResource( "Linker.html", "" );
addResourceHeader( "Linker.html", "Location: " + getHostPath() + "/Target.html" );
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebLinkTest.java 2001/06/11 21:21:09 1.8
+++ WebLinkTest.java 2001/07/31 16:08:59 1.9
@@ -176,6 +176,25 @@
}
+ public void testImageMapLinks() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "pageWithMap", "Here is a page with <a href=\"somewhere\">a link</a>" +
+ " and a map: <IMG src=\"navbar1.gif\" usemap=\"#map1\" alt=\"navigation bar\">" +
+ "<map name=\"map1\">" +
+ " <area href=\"guide.html\" alt=\"Guide\" shape=\"rect\" coords=\"0,0,118,28\">" +
+ " <area href=\"search.html\" alt=\"Search\" shape=\"circle\" coords=\"184,200,60\">" +
+ "</map>" );
+ WebResponse mapPage = wc.getResponse( getHostPath() + "/pageWithMap.html" );
+ WebLink[] links = mapPage.getLinks();
+ assertEquals( "number of links found", 3, links.length );
+
+ WebLink guide = mapPage.getLinkWith( "Guide" );
+ assertNotNull( "Did not find the guide area", guide );
+ assertEquals( "Relative URL", "guide.html", guide.getURLString() );
+ }
+
+
+
private WebResponse _simplePage;
|