httpunit-commit Mailing List for httpunit (Page 60)
Brought to you by:
russgold
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
From: Russell G. <rus...@us...> - 2002-07-24 20:54:34
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv10054/test/com/meterware/httpunit/javascript Added Files: ScriptingTest.java Log Message: Initialize JavaScript implementation ***** Error reading new file[Errno 2] No such file or directory: 'ScriptingTest.java' |
From: Russell G. <rus...@us...> - 2002-07-24 20:54:34
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv10054/jars Added Files: js.jar Log Message: Initialize JavaScript implementation --- NEW FILE --- PK |
From: Russell G. <rus...@us...> - 2002-07-24 20:54:34
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv10054/doc Modified Files: release_notes.txt Log Message: Initialize JavaScript implementation Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.119 retrieving revision 1.120 diff -u -r1.119 -r1.120 --- release_notes.txt 15 Jul 2002 16:42:43 -0000 1.119 +++ release_notes.txt 24 Jul 2002 20:54:31 -0000 1.120 @@ -12,6 +12,13 @@ Revision History: +24-Jul-2002 +Additions: + 1. PseudoServer and associated classes are now publically available and in their own package, pseudoserver. + 2. Experimental JavaScript is starting to be added: support is present for the following DOM objects: + Window properties: self, window, document methods: alert, events: onLoad + Document properties: title, forms, <form name> + 15-Jul-2002 Problems fixed: 1. The "_parent" frame target should now be handled correctly. |
From: Russell G. <rus...@us...> - 2002-07-24 20:52:29
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv9376/test/com/meterware/httpunit/javascript Log Message: Directory /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript added to the repository |
From: Russell G. <rus...@us...> - 2002-07-24 20:52:29
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv9376/src/com/meterware/httpunit/javascript Log Message: Directory /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript added to the repository |
From: Russell G. <rus...@us...> - 2002-07-24 17:33:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv2729/src/com/meterware/servletunit Modified Files: WebApplication.java Log Message: Corrected null pointer exception Index: WebApplication.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- WebApplication.java 23 Jun 2002 23:52:39 -0000 1.11 +++ WebApplication.java 24 Jul 2002 17:33:04 -0000 1.12 @@ -85,7 +85,7 @@ */ WebApplication( Document document, File file, String contextPath ) throws MalformedURLException, SAXException { _contextDir = file; - _contextPath = contextPath; + _contextPath = contextPath == null ? "" : contextPath; registerServlets( document ); extractSecurityConstraints( document ); extractContextParameters( document ); |
From: Russell G. <rus...@us...> - 2002-07-24 17:32:11
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv2295/test/com/meterware/httpunit Modified Files: FileUploadTest.java HttpUnitSuite.java MessageBodyRequestTest.java WebClientTest.java WebFormTest.java WebPageTest.java Removed Files: PseudoServer.java PseudoServerTest.java PseudoServlet.java Log Message: moved pseudo server to its own package Index: FileUploadTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FileUploadTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- FileUploadTest.java 17 Jan 2002 19:38:09 -0000 1.11 +++ FileUploadTest.java 24 Jul 2002 17:32:08 -0000 1.12 @@ -19,6 +19,9 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import com.meterware.pseudoserver.PseudoServlet; +import com.meterware.pseudoserver.WebResource; + import java.io.*; import java.util.StringTokenizer; Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- HttpUnitSuite.java 15 Jul 2002 14:30:32 -0000 1.18 +++ HttpUnitSuite.java 24 Jul 2002 17:32:08 -0000 1.19 @@ -20,6 +20,8 @@ * *******************************************************************************************************************/ +import com.meterware.pseudoserver.PseudoServerTest; + import junit.framework.Test; import junit.framework.TestSuite; Index: MessageBodyRequestTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/MessageBodyRequestTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MessageBodyRequestTest.java 9 Nov 2001 18:35:14 -0000 1.3 +++ MessageBodyRequestTest.java 24 Jul 2002 17:32:08 -0000 1.4 @@ -19,6 +19,9 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import com.meterware.pseudoserver.PseudoServlet; +import com.meterware.pseudoserver.WebResource; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- WebClientTest.java 26 Jun 2002 15:48:56 -0000 1.5 +++ WebClientTest.java 24 Jul 2002 17:32:08 -0000 1.6 @@ -19,6 +19,9 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import com.meterware.pseudoserver.PseudoServlet; +import com.meterware.pseudoserver.WebResource; + import junit.framework.TestSuite; import java.io.ByteArrayOutputStream; Index: WebFormTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFormTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- WebFormTest.java 14 May 2002 18:38:54 -0000 1.21 +++ WebFormTest.java 24 Jul 2002 17:32:08 -0000 1.22 @@ -19,6 +19,9 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import com.meterware.pseudoserver.PseudoServlet; +import com.meterware.pseudoserver.WebResource; + import java.net.URL; import junit.framework.Test; Index: WebPageTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- WebPageTest.java 17 Jun 2002 21:22:05 -0000 1.20 +++ WebPageTest.java 24 Jul 2002 17:32:08 -0000 1.21 @@ -20,6 +20,9 @@ * *******************************************************************************************************************/ +import com.meterware.pseudoserver.PseudoServlet; +import com.meterware.pseudoserver.WebResource; + import java.net.URL; import junit.framework.Test; |
From: Russell G. <rus...@us...> - 2002-07-24 17:29:00
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv874/test/com/meterware/httpunit Modified Files: HttpUnitTest.java Removed Files: HttpRequestStream.java UnknownMethodException.java WebResource.java Log Message: moved pseudo server to its own package Index: HttpUnitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- HttpUnitTest.java 18 Jun 2002 16:53:20 -0000 1.21 +++ HttpUnitTest.java 24 Jul 2002 17:28:57 -0000 1.22 @@ -19,6 +19,8 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import com.meterware.pseudoserver.HttpUserAgentTest; + import java.net.URL; import junit.framework.Test; @@ -36,7 +38,8 @@ * @author <a href="mailto:rus...@ac...">Russell Gold</a> **/ abstract -public class HttpUnitTest extends TestCase { +public class HttpUnitTest extends HttpUserAgentTest { + public HttpUnitTest( String name ) { super( name ); @@ -44,160 +47,9 @@ public void setUp() throws Exception { - _server = new PseudoServer(); + super.setUp(); HttpUnitOptions.reset(); - _hostPath = "http://localhost:" + _server.getConnectedPort(); - } - - - public void tearDown() throws Exception { - if (_server != null) _server.shutDown(); - } - - -//--------------------------------- protected members ---------------------------------------------- - - - protected void defineResource( String resourceName, PseudoServlet servlet ) { - _server.setResource( resourceName, servlet ); - } - - - protected void defineResource( String resourceName, String value ) { - _server.setResource( resourceName, value ); - } - - - protected void defineResource( String resourceName, String value, int statusCode ) { - _server.setErrorResource( resourceName, statusCode, value ); - } - - - protected void defineResource( String resourceName, String value, String contentType ) { - _server.setResource( resourceName, value, contentType ); - } - - - protected void addResourceHeader( String resourceName, String header ) { - _server.addResourceHeader( resourceName, header ); - } - - - protected void setResourceCharSet( String resourceName, String setName, boolean reportCharSet ) { - _server.setCharacterSet( resourceName, setName ); - _server.setSendCharacterSet( resourceName, reportCharSet ); } - - - protected void defineWebPage( String pageName, String body ) { - defineResource( pageName + ".html", "<html><head><title>" + pageName + "</title></head>\n" + - "<body>" + body + "</body></html>" ); - } - - - protected String getHostPath() { - return _hostPath; - } - - - protected void assertEquals( String comment, Object[] expected, Object[] found ) { - if (!equals( expected, found )) { - fail( comment + " expected: " + asText( expected ) + " but found " + asText( found ) ); - } - } - - - private boolean equals( Object[] first, Object[] second ) - { - if (first.length != second.length) return false; - for (int i = 0; i < first.length; i++) - { - if (!first[i].equals( second[i] )) return false; - } - return true; - } - - - - - protected void assertMatchingSet( String comment, Object[] expected, Object[] found ) { - Vector expectedItems = new Vector(); - Vector foundItems = new Vector(); - - for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[i] ); - for (int i = 0; i < found.length; i++) foundItems.addElement( found[i] ); - - for (int i = 0; i < expected.length; i++) { - if (!foundItems.contains( expected[i] )) { - fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) ); - } else { - foundItems.removeElement( expected[i] ); - } - } - - for (int i = 0; i < found.length; i++) { - if (!expectedItems.contains( found[i] )) { - fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) ); - } else { - expectedItems.removeElement( found[i] ); - } - } - - if (!foundItems.isEmpty()) fail( comment + ": expected " + asText( expected ) + " but found " + asText( found ) ); - } - - - protected String asText( Object[] args ) { - StringBuffer sb = new StringBuffer( "{" ); - for (int i = 0; i < args.length; i++) { - if (i != 0) sb.append( "," ); - sb.append( '"' ).append( args[i] ).append( '"' ); - } - sb.append( "}" ); - return sb.toString(); - } - - - - - protected void assertEquals( String comment, byte[] expected, byte[] actual ) - { - if (!equals( expected, actual )) - { - fail( comment + " expected:\n" + toString( expected ) + ", but was:\n" + toString( actual ) ); - } - } - - - private boolean equals( byte[] first, byte[] second ) - { - if (first.length != second.length) return false; - for (int i = 0; i < first.length; i++) - { - if (first[i] != second[i]) return false; - } - return true; - } - - - private String toString( byte[] message ) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < message.length; i++) - { - if (i != 0 && (i % 4) == 0) sb.append( ' ' ); - if (message[i] >= 0 && message[i] < 16) sb.append( '0' ); - sb.append( Integer.toHexString( 0xff & (int) message[i] ) ); - } - return sb.toString(); - } - - -//---------------------------------------- private members ----------------------------------------- - - private String _hostPath; - - private PseudoServer _server; } |
From: Russell G. <rus...@us...> - 2002-07-24 17:29:00
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver In directory usw-pr-cvs1:/tmp/cvs-serv874/test/com/meterware/pseudoserver Added Files: PseudoServerTest.java Log Message: moved pseudo server to its own package ***** Error reading new file[Errno 2] No such file or directory: 'PseudoServerTest.java' |
From: Russell G. <rus...@us...> - 2002-07-24 17:28:59
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv874/src/com/meterware/httpunit Modified Files: HttpUnitUtils.java Log Message: moved pseudo server to its own package Index: HttpUnitUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitUtils.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- HttpUnitUtils.java 6 Mar 2002 03:45:57 -0000 1.8 +++ HttpUnitUtils.java 24 Jul 2002 17:28:56 -0000 1.9 @@ -55,7 +55,8 @@ return result; } - static String stripQuotes( String value ) { + + public static String stripQuotes( String value ) { if (value.startsWith( "'" ) || value.startsWith( "\"" )) value = value.substring( 1 ); if (value.endsWith( "'" ) || value.endsWith( "\"" )) value = value.substring( 0, value.length()-1 ); return value; |
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver In directory usw-pr-cvs1:/tmp/cvs-serv874/src/com/meterware/pseudoserver Added Files: HttpRequestStream.java HttpUserAgentTest.java PseudoServer.java PseudoServlet.java UnknownMethodException.java WebResource.java Log Message: moved pseudo server to its own package ***** Error reading new file[Errno 2] No such file or directory: 'HttpRequestStream.java' ***** Error reading new file[Errno 2] No such file or directory: 'HttpUserAgentTest.java' ***** Error reading new file[Errno 2] No such file or directory: 'PseudoServer.java' ***** Error reading new file[Errno 2] No such file or directory: 'PseudoServlet.java' ***** Error reading new file[Errno 2] No such file or directory: 'UnknownMethodException.java' ***** Error reading new file[Errno 2] No such file or directory: 'WebResource.java' |
From: Russell G. <rus...@us...> - 2002-07-24 17:06:31
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver In directory usw-pr-cvs1:/tmp/cvs-serv25062/test/com/meterware/pseudoserver Log Message: Directory /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver added to the repository |
From: Russell G. <rus...@us...> - 2002-07-24 17:06:31
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver In directory usw-pr-cvs1:/tmp/cvs-serv25062/src/com/meterware/pseudoserver Log Message: Directory /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver added to the repository |
From: Russell G. <rus...@us...> - 2002-07-15 16:42:46
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv15189/test/com/meterware/httpunit Modified Files: WebFrameTest.java Log Message: Added support for _parent target Index: WebFrameTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- WebFrameTest.java 14 Feb 2002 14:33:49 -0000 1.12 +++ WebFrameTest.java 15 Jul 2002 16:42:44 -0000 1.13 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -37,8 +37,8 @@ public static void main(String args[]) { junit.textui.TestRunner.run( suite() ); } - - + + public static Test suite() { return new TestSuite( WebFrameTest.class ); } @@ -84,12 +84,21 @@ public void testFrameNames() throws Exception { WebResponse response = _wc.getResponse( getHostPath() + "/Frames.html" ); - assertMatchingSet( "frame set names", + assertMatchingSet( "frame set names", new String[] { "red", "blue" }, response.getFrameNames() ); } + public void testParentTarget() throws Exception { + defineWebPage( "Target", "This is another page with <a href=Form.html target='_parent'>one link</a>" ); + _wc.getResponse( getHostPath() + "/Frames.html" ); + WebResponse resp = _wc.getResponse( _wc.getFrameContents( "red" ).getLinks()[0].getRequest() ); + resp = _wc.getResponse( resp.getLinks()[0].getRequest() ); + assertMatchingSet( "Frames after third response", new String[] { "_top" }, _wc.getFrameNames() ); + } + + public void testFrameRequests() throws Exception { WebResponse response = _wc.getResponse( getHostPath() + "/Frames.html" ); WebRequest[] requests = response.getFrameRequests(); @@ -121,7 +130,7 @@ public void testFrameURLBase() throws Exception { defineWebPage( "Deeper/Linker", "This is a trivial page with <a href=Target.html>one link</a>" ); defineWebPage( "Deeper/Target", "This is another page with <a href=Form.html target=\"_top\">one link</a>" ); - defineWebPage( "Deeper/Form", "This is a page with a simple form: " + + defineWebPage( "Deeper/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", @@ -174,7 +183,7 @@ 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>" ); - defineWebPage( "Form", "This is a page with a simple form: " + + 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", @@ -317,8 +326,8 @@ assertTrue( "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 testSelfTargetForm() throws Exception { defineWebPage( "Linker", "<form action=redirect.html target=_self><input type=text name=sample value=z></form>" ); defineResource( "redirect.html?sample=z", "", HttpURLConnection.HTTP_MOVED_PERM ); @@ -335,11 +344,11 @@ public void testSubFrameRedirect() throws Exception { defineResource( "Linker.html", "", HttpURLConnection.HTTP_MOVED_PERM ); addResourceHeader( "Linker.html", "Location: " + getHostPath() + "/Target.html" ); - + _wc.getResponse( getHostPath() + "/Frames.html" ); assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, _wc.getFrameNames() ); assertTrue( "Did not redirect", _wc.getFrameContents( "red" ).getURL().toExternalForm().endsWith( "Target.html" ) ); - + } |
From: Russell G. <rus...@us...> - 2002-07-15 16:42:46
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv15189/src/com/meterware/httpunit Modified Files: WebFrame.java Log Message: Added support for _parent target Index: WebFrame.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WebFrame.java 14 Feb 2002 14:33:49 -0000 1.6 +++ WebFrame.java 15 Jul 2002 16:42:44 -0000 1.7 @@ -58,8 +58,15 @@ static String getTargetFrameName( String sourceFrameName, final String relativeName ) { + if (relativeName.equalsIgnoreCase( "_parent" )) return getParentFrameName( sourceFrameName ); if (sourceFrameName.indexOf( ':' ) < 0) return relativeName; - return sourceFrameName.substring( 0, sourceFrameName.lastIndexOf( ':' ) ) + ':' + relativeName; + return getParentFrameName( sourceFrameName ) + ':' + relativeName; + } + + + static String getParentFrameName( String parentFrameName ) { + if (parentFrameName.indexOf( ':' ) < 0) return WebRequest.TOP_FRAME; + return parentFrameName.substring( 0, parentFrameName.lastIndexOf( ':' ) ); } |
From: Russell G. <rus...@us...> - 2002-07-15 16:42:46
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv15189/doc Modified Files: release_notes.txt Log Message: Added support for _parent target Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.118 retrieving revision 1.119 diff -u -r1.118 -r1.119 --- release_notes.txt 15 Jul 2002 14:30:32 -0000 1.118 +++ release_notes.txt 15 Jul 2002 16:42:43 -0000 1.119 @@ -1,7 +1,7 @@ HttpUnit release notes Known problems: - 1. The "_parent" and "_empty" frame targets are not handled correctly + 1. The "_new" and "_empty" frame targets are not handled correctly 2. The "accept-charset" attribute for forms is ignored; the page content character set is used to encode any response. This behavior matches that currently used by IE and Navigator. 3. The regression test "pseudo-server" does not appear to run properly under JDK 1.4 @@ -12,6 +12,10 @@ Revision History: +15-Jul-2002 +Problems fixed: + 1. The "_parent" frame target should now be handled correctly. + 10-Jul-2002 Additions: 1. WebResponse and WebCell now support a new method, getImages, which returns an array of objects representing the |
From: Russell G. <rus...@us...> - 2002-07-15 14:30:36
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv4133/doc Modified Files: release_notes.txt Log Message: Added web image support Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.117 retrieving revision 1.118 diff -u -r1.117 -r1.118 --- release_notes.txt 26 Jun 2002 15:48:56 -0000 1.117 +++ release_notes.txt 15 Jul 2002 14:30:32 -0000 1.118 @@ -4,15 +4,19 @@ 1. The "_parent" and "_empty" frame targets are not handled correctly 2. The "accept-charset" attribute for forms is ignored; the page content character set is used to encode any response. This behavior matches that currently used by IE and Navigator. - 3. The regression test "pseudo-server" do not appear to run properly under JDK 1.4 + 3. The regression test "pseudo-server" does not appear to run properly under JDK 1.4 Limitations: 1. HttpUnit does not support JavaScript 2. JDK 1.2 or higher is required - 3. ServletUnit does not support JSP Revision History: +10-Jul-2002 +Additions: + 1. WebResponse and WebCell now support a new method, getImages, which returns an array of objects representing the + image tags found. + 25-Jun-2002 Additions: 1. The HttpUnitOption property 'acceptCookies' now controls whether cookies received from the server will be saved |
From: Russell G. <rus...@us...> - 2002-07-15 14:30:36
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv4133/src/com/meterware/httpunit Modified Files: ParsedHTML.java WebResponse.java Added Files: WebImage.java Log Message: Added web image support ***** Error reading new file[Errno 2] No such file or directory: 'WebImage.java' Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- ParsedHTML.java 14 May 2002 19:31:04 -0000 1.20 +++ ParsedHTML.java 15 Jul 2002 14:30:32 -0000 1.21 @@ -32,6 +32,7 @@ class ParsedHTML { private WebForm[] _forms; + private WebImage[] _images; ParsedHTML( URL baseURL, String baseTarget, Node rootNode, String characterSet ) { @@ -174,6 +175,35 @@ /** + * Returns the images found in the page in the order in which they appear. + **/ + public WebImage[] getImages() { + if (_images == null) { + NodeList images = NodeUtils.getElementsByTagName( _rootNode, "img" ); + + _images = new WebImage[ images.getLength() ]; + for (int i = 0; i < _images.length; i++) { + _images[i] = new WebImage( this, _baseURL, images.item( i ) ); + } + } + return _images; + } + + + /** + * Returns the image found in the page with the specified src attribute. + **/ + public WebImage getImageWithSource( String source ) { + WebImage[] images = getImages(); + for (int i = 0; i < images.length; i++) { + if (images[i].getSource().equals( source )) return images[i]; + else if (HttpUnitOptions.getMatchesIgnoreCase() && images[i].getSource().equalsIgnoreCase( source )) return images[i]; + } + return null; + } + + + /** * Returns the top-level tables found in this page in the order in which * they appear. **/ @@ -299,6 +329,20 @@ interface TablePredicate { public boolean isTrue( WebTable table ); + } + + + interface LinkPredicate { + public boolean isTrue( WebLink link ); + } + + + WebLink getLinkSatisfyingPredicate( LinkPredicate predicate ) { + WebLink[] links = getLinks(); + for (int i = 0; i < links.length; i++) { + if (predicate.isTrue( links[ i ] )) return links[ i ]; + } + return null; } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- WebResponse.java 17 Jun 2002 21:22:05 -0000 1.66 +++ WebResponse.java 15 Jul 2002 14:30:32 -0000 1.67 @@ -360,6 +360,24 @@ /** + * Returns the images found in the page in the order in which they appear. + * @exception SAXException thrown if there is an error parsing the response. + **/ + public WebImage[] getImages() throws SAXException { + return getReceivedPage().getImages(); + } + + + /** + * Returns the image found in the page with the specified src attribute. + * @exception SAXException thrown if there is an error parsing the response. + **/ + public WebImage getImageWithSource( String source ) throws SAXException { + return getReceivedPage().getImageWithSource( source ); + } + + + /** * Returns the top-level tables found in this page in the order in which * they appear. * @exception SAXException thrown if there is an error parsing the response. |
From: Russell G. <rus...@us...> - 2002-07-15 14:30:36
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv4133/test/com/meterware/httpunit Modified Files: HttpUnitSuite.java Added Files: WebImageTest.java Log Message: Added web image support ***** Error reading new file[Errno 2] No such file or directory: 'WebImageTest.java' Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- HttpUnitSuite.java 28 Feb 2002 14:30:33 -0000 1.17 +++ HttpUnitSuite.java 15 Jul 2002 14:30:32 -0000 1.18 @@ -38,6 +38,7 @@ TestSuite result = new TestSuite(); result.addTest( WebPageTest.suite() ); result.addTest( WebLinkTest.suite() ); + result.addTest( WebImageTest.suite() ); result.addTest( HtmlTablesTest.suite() ); result.addTest( WebFormTest.suite() ); result.addTest( WebFrameTest.suite() ); |
From: Russell G. <rus...@us...> - 2002-06-26 15:48:59
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17599/test/com/meterware/httpunit Modified Files: WebClientTest.java Log Message: Support acceptCookies global option Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WebClientTest.java 26 Jun 2002 15:12:01 -0000 1.4 +++ WebClientTest.java 26 Jun 2002 15:48:56 -0000 1.5 @@ -88,6 +88,23 @@ } + public void testCookiesDisabled() throws Exception { + String resourceName = "something/baking"; + String resourceValue = "the desired content"; + + defineResource( resourceName, resourceValue ); + addResourceHeader( resourceName, "Set-Cookie: age=12" ); + + HttpUnitOptions.setAcceptCookies( false ); + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + '/' + resourceName ); + WebResponse response = wc.getResponse( request ); + assertEquals( "requested resource", resourceValue, response.getText().trim() ); + assertEquals( "content type", "text/html", response.getContentType() ); + assertEquals( "number of cookies", 0, wc.getCookieNames().length ); + } + + public void testOldCookies() throws Exception { String resourceName = "something/baking"; String resourceValue = "the desired content"; |
From: Russell G. <rus...@us...> - 2002-06-26 15:48:59
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17599/src/com/meterware/httpunit Modified Files: HttpUnitOptions.java WebClient.java Log Message: Support acceptCookies global option Index: HttpUnitOptions.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- HttpUnitOptions.java 17 Jun 2002 21:22:05 -0000 1.20 +++ HttpUnitOptions.java 26 Jun 2002 15:48:56 -0000 1.21 @@ -49,9 +49,25 @@ _contentType = DEFAULT_CONTENT_TYPE; _postIncludesCharset = false; _acceptGzip = true; + _acceptCookies = true; } + /** + * Returns true if HttpUnit is accepting and saving cookies. The default is to accept them. + */ + public static boolean isAcceptCookies() { + return _acceptCookies; + } + + + /** + * Specifies whether HttpUnit should accept and send cookies. + */ + public static void setAcceptCookies( boolean acceptCookies ) { + _acceptCookies = acceptCookies; + } + /** * Returns true if any WebClient created will accept GZIP encoding of responses. The default is to accept GZIP encoding. @@ -341,6 +357,8 @@ private static final String DEFAULT_CONTENT_TYPE = "text/plain"; private static boolean _acceptGzip = true; + + private static boolean _acceptCookies = true; private static boolean _parserWarningsEnabled; Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- WebClient.java 14 May 2002 19:31:04 -0000 1.23 +++ WebClient.java 26 Jun 2002 15:48:56 -0000 1.24 @@ -376,6 +376,8 @@ * Updates the cookies maintained in this client based on new cookies requested by the server. **/ private void updateCookies( WebResponse response ) { + if (!HttpUnitOptions.isAcceptCookies()) return; + String[] names = response.getNewCookieNames(); for (int i = 0; i < names.length; i++) { addCookie( names[i], response.getNewCookieValue( names[i] ) ); |
From: Russell G. <rus...@us...> - 2002-06-26 15:48:59
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv17599/jars Modified Files: jars.txt Log Message: Support acceptCookies global option Index: jars.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/jars.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- jars.txt 23 Jun 2002 23:52:39 -0000 1.3 +++ jars.txt 26 Jun 2002 15:48:56 -0000 1.4 @@ -5,6 +5,7 @@ servlet 2.3 xerces 1.2.3 jtidy 04aug2000r7 +rhino 1.5R3 (for testing HttpUnit only) mail (javamail 1.2) |
From: Russell G. <rus...@us...> - 2002-06-26 15:48:59
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv17599/doc Modified Files: release_notes.txt Log Message: Support acceptCookies global option Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.116 retrieving revision 1.117 diff -u -r1.116 -r1.117 --- release_notes.txt 23 Jun 2002 23:52:38 -0000 1.116 +++ release_notes.txt 26 Jun 2002 15:48:56 -0000 1.117 @@ -13,6 +13,11 @@ Revision History: +25-Jun-2002 +Additions: + 1. The HttpUnitOption property 'acceptCookies' now controls whether cookies received from the server will be saved + in a web client and sent on subsequent requests. The default is true. + 23-Jun-2002 Acknowledgements: Thanks to Steve Heath for an example on how to make JSPs work with ServletUnit. |
From: Russell G. <rus...@us...> - 2002-06-26 15:12:04
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv4546/test/com/meterware/httpunit Modified Files: PseudoServerTest.java WebClientTest.java Log Message: Moved cookie test to more logical suite Index: PseudoServerTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- PseudoServerTest.java 6 Mar 2002 04:59:52 -0000 1.24 +++ PseudoServerTest.java 26 Jun 2002 15:12:01 -0000 1.25 @@ -1,42 +1,38 @@ package com.meterware.httpunit; /******************************************************************************************************************** -* $Id$ -* -* Copyright (c) 2000-2002, Russell Gold -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -* to permit persons to whom the Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or substantial portions -* of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -* -*******************************************************************************************************************/ -import java.net.HttpURLConnection; - -import java.util.Dictionary; - -import junit.framework.Test; + * $Id$ + * + * Copyright (c) 2000-2002, Russell Gold + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *******************************************************************************************************************/ import junit.framework.TestCase; import junit.framework.TestSuite; -import com.meterware.httpunit.*; +import java.net.HttpURLConnection; + public class PseudoServerTest extends HttpUnitTest { - public static void main(String args[]) { + public static void main( String args[] ) { junit.textui.TestRunner.run( suite() ); } - public static Test suite() { + public static TestSuite suite() { return new TestSuite( PseudoServerTest.class ); } @@ -57,80 +53,52 @@ public void testNotFound() throws Exception { - PseudoServer ps = new PseudoServer(); - int port = ps.getConnectedPort(); - - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + "/nothing.htm" ); + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/nothing.htm" ); try { WebResponse response = wc.getResponse( request ); fail( "Should have rejected the request" ); } catch (HttpNotFoundException e) { assertEquals( "Response code", HttpURLConnection.HTTP_NOT_FOUND, e.getResponseCode() ); - } finally { - ps.shutDown(); } } public void testNotModifiedResponse() throws Exception { - PseudoServer ps = new PseudoServer(); - ps.setErrorResource( "error.htm", 304, "Not Modified" ); - int port = ps.getConnectedPort(); + defineResource( "error.htm", "Not Modified", 304 ); - try { - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + "/error.htm" ); - WebResponse response = wc.getResponse( request ); - assertEquals( "Response code", 304, response.getResponseCode() ); - response.getText(); - response.getInputStream().read(); - } finally { - ps.shutDown(); - } + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/error.htm" ); + WebResponse response = wc.getResponse( request ); + assertEquals( "Response code", 304, response.getResponseCode() ); + response.getText(); + response.getInputStream().read(); } public void testInternalErrorException() throws Exception { - PseudoServer ps = new PseudoServer(); - ps.setErrorResource( "error.htt", 501, "Internal error" ); - int port = ps.getConnectedPort(); + defineResource( "error.htm", "Internal error", 501 ); - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + "/error.htt" ); + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/error.htm" ); try { WebResponse response = wc.getResponse( request ); fail( "Should have rejected the request" ); } catch (HttpException e) { assertEquals( "Response code", 501, e.getResponseCode() ); - } finally { - ps.shutDown(); } } public void testInternalErrorDisplay() throws Exception { - PseudoServer ps = new PseudoServer(); - ps.setErrorResource( "error.htm", 501, "Internal error" ); - int port = ps.getConnectedPort(); - - try { - WebConversation wc = new WebConversation(); - wc.setExceptionsThrownOnErrorStatus( false ); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + "/error.htm" ); - WebResponse response = wc.getResponse( request ); - assertEquals( "Response code", 501, response.getResponseCode() ); - assertEquals( "Message contents", "Internal error", response.getText().trim() ); - } finally { - ps.shutDown(); - } - } - + defineResource( "error.htm", "Internal error", 501 ); - public void testHeaderFields() throws Exception { WebConversation wc = new WebConversation(); - wc.setHeaderField( "user-agent", "Mozilla 6" ); - assertEquals( "Mozilla 6", wc.getUserAgent() ); + wc.setExceptionsThrownOnErrorStatus( false ); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/error.htm" ); + WebResponse response = wc.getResponse( request ); + assertEquals( "Response code", 501, response.getResponseCode() ); + assertEquals( "Message contents", "Internal error", response.getText().trim() ); } @@ -138,19 +106,13 @@ String resourceName = "something/interesting"; String resourceValue = "the desired content"; - PseudoServer ps = new PseudoServer(); - ps.setResource( resourceName, resourceValue ); - int port = ps.getConnectedPort(); + defineResource( resourceName, resourceValue ); - try { - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + '/' + resourceName ); - WebResponse response = wc.getResponse( request ); - assertEquals( "requested resource", resourceValue, response.getText().trim() ); - assertEquals( "content type", "text/html", response.getContentType() ); - } finally { - ps.shutDown(); - } + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + '/' + resourceName ); + WebResponse response = wc.getResponse( request ); + assertEquals( "requested resource", resourceValue, response.getText().trim() ); + assertEquals( "content type", "text/html", response.getContentType() ); } @@ -158,138 +120,33 @@ StringBuffer sb = new StringBuffer(); char[] chars = s.toCharArray(); for (int i = 0; i < chars.length; i++) { - sb.append( Integer.toHexString( chars[i] ) ).append( " " ); + sb.append( Integer.toHexString( chars[i] ) ).append( " " ); } return sb.toString(); } - public void testCookies() throws Exception { - String resourceName = "something/baking"; - String resourceValue = "the desired content"; - - PseudoServer ps = new PseudoServer(); - int port = ps.getConnectedPort(); - ps.setResource( resourceName, resourceValue ); - ps.addResourceHeader( resourceName, "Set-Cookie: HSBCLoginFailReason=; path=/" ); - 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" ); - ps.addResourceHeader( resourceName, "Set-Cookie: SESSION_ID=17585,Dzm5LzbRPnb95QkUyIX+7w5RDT7p6OLuOVZ91AMl4hsDATyZ1ej+FA==; path=/;" ); - - try { - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + '/' + resourceName ); - WebResponse response = wc.getResponse( request ); - assertEquals( "requested resource", resourceValue, response.getText().trim() ); - assertEquals( "content type", "text/html", response.getContentType() ); - assertEquals( "number of cookies", 8, wc.getCookieNames().length ); - assertEquals( "cookie 'HSBCLoginFailReason' value", "", wc.getCookieValue( "HSBCLoginFailReason" ) ); - 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" ) ); - assertEquals( "cookie 'SESSION_ID' value", "17585,Dzm5LzbRPnb95QkUyIX+7w5RDT7p6OLuOVZ91AMl4hsDATyZ1ej+FA==", wc.getCookieValue( "SESSION_ID" ) ); - } finally { - ps.shutDown(); - } - } - - - public void testOldCookies() throws Exception { - String resourceName = "something/baking"; - String resourceValue = "the desired content"; - - PseudoServer ps = new PseudoServer(); - int port = ps.getConnectedPort(); - ps.setResource( resourceName, resourceValue ); - ps.addResourceHeader( resourceName, "Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT" ); - - try { - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + '/' + resourceName ); - WebResponse response = wc.getResponse( request ); - assertEquals( "requested resource", resourceValue, response.getText().trim() ); - assertEquals( "content type", "text/html", response.getContentType() ); - assertEquals( "number of cookies", 1, wc.getCookieNames().length ); - assertEquals( "cookie 'CUSTOMER' value", "WILE_E_COYOTE", wc.getCookieValue( "CUSTOMER" ) ); - } finally { - ps.shutDown(); - } - } - - - public void testPseudoServlet() throws Exception { String resourceName = "tellMe"; String name = "Charlie"; final String prefix = "Hello there, "; String expectedResponse = prefix + name; - PseudoServer ps = new PseudoServer(); - int port = ps.getConnectedPort(); + defineResource( resourceName, new PseudoServlet() { - try { - ps.setResource( resourceName, new PseudoServlet() { - public WebResource getPostResponse() { - return new WebResource( prefix + getParameter( "name" )[0], "text/plain" ); - } - } ); - - WebConversation wc = new WebConversation(); - WebRequest request = new PostMethodWebRequest( "http://localhost:" + port + '/' + resourceName ); - request.setParameter( "name", name ); - WebResponse response = wc.getResponse( request ); - assertEquals( "Content type", "text/plain", response.getContentType() ); - assertEquals( "Response", expectedResponse, response.getText().trim() ); - } finally { - ps.shutDown(); - } - } - - - public void testRefererHeader() throws Exception { - String resourceName = "tellMe"; - String linkSource = "fromLink"; - String formSource = "fromForm"; - - PseudoServer ps = new PseudoServer(); - int port = ps.getConnectedPort(); + public WebResource getPostResponse() { + return new WebResource( prefix + getParameter( "name" )[0], "text/plain" ); + } + } ); - String page0 = "http://localhost:" + port + '/' + resourceName; - String page1 = "http://localhost:" + port + '/' + linkSource; - String page2 = "http://localhost:" + port + '/' + formSource; - - ps.setResource( linkSource, "<html><head></head><body><a href=\"tellMe\">Go</a></body></html>" ); - ps.setResource( formSource, "<html><body><form action=\"tellMe\"><input type=submit></form></body></html>" ); - - try { - ps.setResource( resourceName, new PseudoServlet() { - public WebResource getGetResponse() { - String referer = getHeader( "Referer" ); - return new WebResource( referer == null ? "null" : referer, "text/plain" ); - } - } ); - - WebConversation wc = new WebConversation(); - WebResponse response = wc.getResponse( page0 ); - assertEquals( "Content type", "text/plain", response.getContentType() ); - assertEquals( "Default Referer header", "null", response.getText().trim() ); - - response = wc.getResponse( page1 ); - response = wc.getResponse( response.getLinks()[0].getRequest() ); - assertEquals( "Link Referer header", page1, response.getText().trim() ); - - response = wc.getResponse( page2 ); - response = wc.getResponse( response.getForms()[0].getRequest() ); - assertEquals( "Form Referer header", page2, response.getText().trim() ); - } finally { - ps.shutDown(); - } + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest( getHostPath() + '/' + resourceName ); + request.setParameter( "name", name ); + WebResponse response = wc.getResponse( request ); + assertEquals( "Content type", "text/plain", response.getContentType() ); + assertEquals( "Response", expectedResponse, response.getText().trim() ); } + } Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- WebClientTest.java 11 Mar 2002 12:34:32 -0000 1.3 +++ WebClientTest.java 26 Jun 2002 15:12:01 -0000 1.4 @@ -19,7 +19,6 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ - import junit.framework.TestSuite; import java.io.ByteArrayOutputStream; @@ -50,6 +49,92 @@ public WebClientTest( String name ) { super( name ); + } + + + public void testHeaderFields() throws Exception { + WebConversation wc = new WebConversation(); + wc.setHeaderField( "user-agent", "Mozilla 6" ); + assertEquals( "Mozilla 6", wc.getUserAgent() ); + } + + + public void testCookies() throws Exception { + String resourceName = "something/baking"; + String resourceValue = "the desired content"; + + defineResource( resourceName, resourceValue ); + addResourceHeader( resourceName, "Set-Cookie: HSBCLoginFailReason=; path=/" ); + addResourceHeader( resourceName, "Set-Cookie: age=12, name= george" ); + addResourceHeader( resourceName, "Set-Cookie: type=short" ); + addResourceHeader( resourceName, "Set-Cookie: funky=ab$==" ); + addResourceHeader( resourceName, "Set-Cookie: p30waco_sso=3.0,en,us,AMERICA,Drew;path=/, PORTAL30_SSO_TEST=X" ); + addResourceHeader( resourceName, "Set-Cookie: SESSION_ID=17585,Dzm5LzbRPnb95QkUyIX+7w5RDT7p6OLuOVZ91AMl4hsDATyZ1ej+FA==; path=/;" ); + + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + '/' + resourceName ); + WebResponse response = wc.getResponse( request ); + assertEquals( "requested resource", resourceValue, response.getText().trim() ); + assertEquals( "content type", "text/html", response.getContentType() ); + assertEquals( "number of cookies", 8, wc.getCookieNames().length ); + assertEquals( "cookie 'HSBCLoginFailReason' value", "", wc.getCookieValue( "HSBCLoginFailReason" ) ); + 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" ) ); + assertEquals( "cookie 'SESSION_ID' value", "17585,Dzm5LzbRPnb95QkUyIX+7w5RDT7p6OLuOVZ91AMl4hsDATyZ1ej+FA==", wc.getCookieValue( "SESSION_ID" ) ); + } + + + public void testOldCookies() throws Exception { + String resourceName = "something/baking"; + String resourceValue = "the desired content"; + + defineResource( resourceName, resourceValue ); + addResourceHeader( resourceName, "Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT" ); + + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + '/' + resourceName ); + WebResponse response = wc.getResponse( request ); + assertEquals( "requested resource", resourceValue, response.getText().trim() ); + assertEquals( "content type", "text/html", response.getContentType() ); + assertEquals( "number of cookies", 1, wc.getCookieNames().length ); + assertEquals( "cookie 'CUSTOMER' value", "WILE_E_COYOTE", wc.getCookieValue( "CUSTOMER" ) ); + } + + + public void testRefererHeader() throws Exception { + String resourceName = "tellMe"; + String linkSource = "fromLink"; + String formSource = "fromForm"; + + String page0 = getHostPath() + '/' + resourceName; + String page1 = getHostPath() + '/' + linkSource; + String page2 = getHostPath() + '/' + formSource; + + defineResource( linkSource, "<html><head></head><body><a href=\"tellMe\">Go</a></body></html>" ); + defineResource( formSource, "<html><body><form action=\"tellMe\"><input type=submit></form></body></html>" ); + defineResource( resourceName, new PseudoServlet() { + public WebResource getGetResponse() { + String referer = getHeader( "Referer" ); + return new WebResource( referer == null ? "null" : referer, "text/plain" ); + } + } ); + + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( page0 ); + assertEquals( "Content type", "text/plain", response.getContentType() ); + assertEquals( "Default Referer header", "null", response.getText().trim() ); + + response = wc.getResponse( page1 ); + response = wc.getResponse( response.getLinks()[0].getRequest() ); + assertEquals( "Link Referer header", page1, response.getText().trim() ); + + response = wc.getResponse( page2 ); + response = wc.getResponse( response.getForms()[0].getRequest() ); + assertEquals( "Form Referer header", page2, response.getText().trim() ); } |
From: Russell G. <rus...@us...> - 2002-06-23 23:52:42
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv29969/src/com/meterware/servletunit Modified Files: InvocationContextImpl.java ServletRunner.java ServletUnitClient.java ServletUnitContext.java ServletUnitServletContext.java WebApplication.java Added Files: JSPServletDescriptor.java Log Message: Added support for JSPs ***** Error reading new file[Errno 2] No such file or directory: 'JSPServletDescriptor.java' Index: InvocationContextImpl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InvocationContextImpl.java 19 Jun 2002 13:47:19 -0000 1.5 +++ InvocationContextImpl.java 23 Jun 2002 23:52:39 -0000 1.6 @@ -131,7 +131,7 @@ * request, and cookie headers. **/ InvocationContextImpl( ServletRunner runner, WebRequest request, Cookie[] cookies, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { - _application = runner._application; + _application = runner.getApplication(); _requestURL = request.getURL(); _target = request.getTarget(); Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- ServletRunner.java 21 May 2002 20:43:31 -0000 1.16 +++ ServletRunner.java 23 Jun 2002 23:52:39 -0000 1.17 @@ -25,6 +25,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Dictionary; +import java.util.Hashtable; import javax.servlet.Servlet; import javax.servlet.ServletException; @@ -47,8 +48,8 @@ * Default constructor, which defines no servlets. */ public ServletRunner() { - _context = new ServletUnitContext(); _application = new WebApplication(); + completeInitialization( null ); } /** @@ -58,8 +59,8 @@ * @param webXMLFileSpec the full path to the web.xml file */ public ServletRunner( String webXMLFileSpec ) throws IOException, SAXException { - _context = new ServletUnitContext(); _application = new WebApplication( HttpUnitUtils.newParser().parse( webXMLFileSpec ) ); + completeInitialization( null ); } @@ -71,9 +72,9 @@ * @param contextPath the context path */ public ServletRunner( String webXMLFileSpec, String contextPath ) throws IOException, SAXException { - _context = new ServletUnitContext( contextPath ); File webXMLFile = new File( webXMLFileSpec ); - _application = new WebApplication( HttpUnitUtils.newParser().parse( webXMLFileSpec ), webXMLFile.getParentFile().getParentFile(), _context.getContextPath() ); + _application = new WebApplication( HttpUnitUtils.newParser().parse( webXMLFileSpec ), webXMLFile.getParentFile().getParentFile(), contextPath ); + completeInitialization( contextPath ); } @@ -81,22 +82,37 @@ * Constructor which expects an input stream containing the web.xml for the application. **/ public ServletRunner( InputStream webXML ) throws IOException, SAXException { - this(webXML, null); + this( webXML, null ); } /** * Constructor which expects an input stream containing the web.xml for the application. **/ public ServletRunner( InputStream webXML, String contextPath ) throws IOException, SAXException { - _context = new ServletUnitContext(contextPath); - _application = new WebApplication( HttpUnitUtils.newParser().parse( new InputSource( webXML ) ), _context.getContextPath()); + _application = new WebApplication( HttpUnitUtils.newParser().parse( new InputSource( webXML ) ), contextPath ); + completeInitialization( contextPath ); } + /** * Registers a servlet class to be run. **/ public void registerServlet( String resourceName, String servletClassName ) { - _application.registerServlet( resourceName, servletClassName ); + _application.registerServlet( resourceName, servletClassName, null ); + } + + + private void completeInitialization( String contextPath ) { + _context = new ServletUnitContext( contextPath ); + _application.registerServlet( "*.jsp", _jspServletDescriptor.getClassName(), _jspServletDescriptor.getInitializationParameters( null, null ) ); + } + + + /** + * Registers a servlet class to be run, specifying initialization parameters. + **/ + public void registerServlet( String resourceName, String servletClassName, Hashtable initParameters ) { + _application.registerServlet( resourceName, servletClassName, initParameters ); } @@ -126,6 +142,25 @@ } + public static class JasperJSPServletDescriptor implements JSPServletDescriptor { + + public String getClassName() { + return "org.apache.jasper.servlet.JspServlet"; + } + + + public Hashtable getInitializationParameters( String classPath, String workingDirectory ) { + Hashtable params = new Hashtable(); + if (classPath != null) params.put( "classpath", classPath ); + if (workingDirectory != null) params.put( "scratchdir", workingDirectory ); + return params; + } + } + + + public final static JSPServletDescriptor JASPER_DESCRIPTOR = new JasperJSPServletDescriptor(); + + //-------------------------------------------- package methods --------------------------------------------------------- @@ -134,9 +169,16 @@ } + WebApplication getApplication() { + return _application; + } + + //---------------------------- private members ------------------------------------ - WebApplication _application; + private static JSPServletDescriptor _jspServletDescriptor = JASPER_DESCRIPTOR; + + private WebApplication _application; private ServletUnitClient _client; @@ -153,5 +195,6 @@ if (_client == null) _client = newClient(); return _client; } + } Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ServletUnitClient.java 4 Feb 2002 22:33:55 -0000 1.5 +++ ServletUnitClient.java 23 Jun 2002 23:52:39 -0000 1.6 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2001, Russell Gold +* Copyright (c) 2000-2002, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation Index: ServletUnitContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitContext.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServletUnitContext.java 1 Mar 2002 06:08:24 -0000 1.2 +++ ServletUnitContext.java 23 Jun 2002 23:52:39 -0000 1.3 @@ -26,7 +26,7 @@ class ServletUnitContext { ServletUnitContext() { - _contextPath = ""; + this( null ); } ServletUnitContext(String contextPath) { Index: ServletUnitServletContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ServletUnitServletContext.java 19 Jun 2002 13:47:19 -0000 1.9 +++ ServletUnitServletContext.java 23 Jun 2002 23:52:39 -0000 1.10 @@ -235,7 +235,7 @@ * any reason (such as when the content is being made available from a .war archive). **/ public String getRealPath( String path ) { - return null; // XXX not implemented + return _application.getResourceFile( path ).getAbsolutePath(); } Index: WebApplication.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WebApplication.java 19 Jun 2002 13:47:19 -0000 1.10 +++ WebApplication.java 23 Jun 2002 23:52:39 -0000 1.11 @@ -104,8 +104,8 @@ /** * Registers a servlet class to be run. **/ - void registerServlet( String resourceName, String servletClassName ) { - registerServlet( resourceName, new ServletConfiguration( servletClassName ) ); + void registerServlet( String resourceName, String servletClassName, Hashtable initParams ) { + registerServlet( resourceName, new ServletConfiguration( servletClassName, initParams ) ); } @@ -203,7 +203,7 @@ File getResourceFile( String path ) { if (_contextDir == null) { - return null; + return new File( path.substring(1) ); } else { return new File( _contextDir, path.substring(1) ); } @@ -355,8 +355,14 @@ class ServletConfiguration { - public ServletConfiguration( String className ) { + ServletConfiguration( String className ) { _className = className; + } + + + ServletConfiguration( String className, Hashtable initParams ) { + _className = className; + if (initParams != null) _initParams = initParams; } |