httpunit-commit Mailing List for httpunit (Page 61)
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-06-23 23:52:42
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv29969/jars Modified Files: jars.txt servlet.jar Log Message: Added support for JSPs Index: jars.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/jars.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jars.txt 3 Mar 2002 22:59:29 -0000 1.2 +++ jars.txt 23 Jun 2002 23:52:39 -0000 1.3 @@ -4,7 +4,7 @@ junit 3.7 servlet 2.3 xerces 1.2.3 -jtidy 04aug2000r5 +jtidy 04aug2000r7 (for testing HttpUnit only) mail (javamail 1.2) Index: servlet.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/servlet.jar,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 Binary files /tmp/cvsvcMoRl and /tmp/cvsQq8Hax differ |
|
From: Russell G. <rus...@us...> - 2002-06-23 23:52:42
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv29969/doc
Modified Files:
release_notes.txt
Log Message:
Added support for JSPs
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- release_notes.txt 20 Jun 2002 15:33:18 -0000 1.115
+++ release_notes.txt 23 Jun 2002 23:52:38 -0000 1.116
@@ -13,6 +13,15 @@
Revision History:
+23-Jun-2002
+Acknowledgements:
+ Thanks to Steve Heath for an example on how to make JSPs work with ServletUnit.
+
+Additions:
+ 1. ServletUnit now supports ServletContext.getRealPath
+ 2. ServletUnit now supports JSPs using Jasper. By default, JSPs are expected to be in the current working directory.
+ If an external web.xml file is specified, JSPs will be searched for in the application context directory.
+
20-Jun-2002 1.4.1
Acknowledgements:
Thanks to Stefan Renz for finding the file control value bug and providing a fix.
@@ -31,7 +40,6 @@
6. bug #570644: As of JDK 1.3.1-03, the behavior of HttpURLConnection was changed to throw an IOException when an
error status is returned. This broke HttpUnit's handling of error codes. This has since been corrected.
-19-Jun-2002
Additions:
Content and parsing additions
1. HttpUnit now sends Accept-encoding: gzip unless disabled by a call to HttpUnitOptions.setAcceptGzip( false )
|
|
From: Russell G. <rus...@us...> - 2002-06-20 15:39:32
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv13890/doc Modified Files: faq.html Log Message: Updated FAQ for IllegalAccess Index: faq.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/faq.html,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- faq.html 24 Oct 2001 16:37:42 -0000 1.11 +++ faq.html 20 Jun 2002 15:39:29 -0000 1.12 @@ -81,7 +81,7 @@ Once you have corrected any errors, HttpUnit should see your form buttons and parameters. <A NAME="#reload"><H2>Why do I get java.lang.IllegalAccessError when calling getResponse()?</H2></A> -This happens when you use HttpUnit and JTidy with one of the JUnit graphical test runners, which reloads +<p>This happens when you use HttpUnit and certain versions of JTidy with one of the JUnit graphical test runners, which reloads classes every time to run a test. Unfortunately, this places different versions of the JTidy classes in different class loaders, so you get this error. To avoid it, you can do any of the following:<ul><li>Use only the text test runner</li> @@ -91,7 +91,8 @@ excluded.11=org.w3c.tidy.* </code></blockquote> This will require extracting the file, modifying it and then putting it back <em>in the same directory</em>, but it should allow your -tests to reload safely.</ul> +tests to reload safely.</ul></p> +<p>This problem appears to be resolved in JTidy r7, which is included with HttpUnit 1.4.1 or later. <A HREF="#badPost"><H2>Why doesn't my servlet see parameters on a POST request?</H2></A> Some older servlet engines, such as Tomcat 3.1, get confused when they see a charset attribute on the Content-Type |
|
From: Russell G. <rus...@us...> - 2002-06-20 15:35:20
|
Update of /cvsroot/httpunit/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv12755
Modified Files:
build.xml
Log Message:
Adjust version number for build
Index: build.xml
===================================================================
RCS file: /cvsroot/httpunit/httpunit/build.xml,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- build.xml 4 Mar 2002 02:10:49 -0000 1.42
+++ build.xml 20 Jun 2002 15:35:17 -0000 1.43
@@ -5,7 +5,7 @@
<project name="httpunit" default="jar" basedir=".">
<property name="name" value="httpunit" />
<property name="Name" value="HttpUnit" />
- <property name="version" value="1.4" />
+ <property name="version" value="1.4.1" />
<property name="debug" value="on" />
<property name="deprecation" value="off" />
|
|
From: Russell G. <rus...@us...> - 2002-06-20 15:33:21
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv12269/jars Modified Files: Tidy.jar Log Message: Prepare for 1.4.1 release Index: Tidy.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/Tidy.jar,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 Binary files /tmp/cvsoBVb2N and /tmp/cvsonVhev differ |
|
From: Russell G. <rus...@us...> - 2002-06-20 15:33:21
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv12269/doc
Modified Files:
release_notes.txt todo.txt
Log Message:
Prepare for 1.4.1 release
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- release_notes.txt 19 Jun 2002 13:47:19 -0000 1.114
+++ release_notes.txt 20 Jun 2002 15:33:18 -0000 1.115
@@ -4,6 +4,7 @@
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
Limitations:
1. HttpUnit does not support JavaScript
@@ -12,97 +13,55 @@
Revision History:
-19-Jun-2002
-Additions:
- 1. ServletUnit now implements the HttpServletRequest.getServletPath and getPathInfo methods.
-
-18-Jun-2002
-Acknowledgements:
- Thanks to Jessica Sant for correcting the handling of error statuses.
-Problems fixed:
- 1. bug #570644: As of JDK 1.3.1-03, the behavior of HttpURLConnection was changed to throw an IOException when an
- error status is returned. This broke HttpUnit's handling of error codes. This has since been corrected.
-
-17-Jun-2002
-Acknowledgements:
- Thanks to Robert Watkins for the content length test.
-
-Additions:
- 1. An IO exception is thrown if the content length does not match the actual received length for a response and
- content-length checking is enabled.
-
-21-May-2002
-Correction:
- 1. ServletUnit supports urls beginning with "/servlet/" as referring to a servlet class name if not mapped to anything else.
-
-20-May-2002
-Additions:
- 1. ServletUnitHttpRequest now implements getInputStream and getContentType.
-
-16-May-2002
-Acknowledgements:
- Thanks to James Murty for adding caching of servlet instances and some XML parsing cleanup.
-
-Additions:
- 1. ServletUnit now caches its servlet instances so that multiple invocations can use the same instance. This more
- closely matches the servlet spec.
- 2. Leading and trailing spaces in web.xml text nodes are now ignored.
- 3. If no other mapping matches a servlet name in a URL, ServletUnit will try to treat it as a servlet class name.
- This means that you can use something like http://localhost/com.nowhere.MyServlet to access your servlet without
- explicitly registering it.
-
-14-May-2002
-Additions:
- 1. A <select> control with a size attribute may now have its value undefined. The specification does not require
- this behavior, but both IE 5.5 and Netscape 6.2 do this.
- 2. WebResponse.getForms now caches its result so that multiple calls will return the same set of objects.
- 3. WebClient.sendRequest is now available as an alias for WebRequest.getResponse
-
- 9-May-2002
-Acknowledgements:
- Thanks to Yassen Damyanov for fixing a bug in the handling response headers
-
-Problems fixed:
- 1. Response headers were truncated to the first word only
- 2. The servletunit tutorial failed with a NullPointerException in the first step.
-
- 8-Apr-2002
-Additions:
- 1. It is now possible to set the value of a hidden field in a form using a mechanism which will support scripting in the future:
- form.getScriptableObject().setParameterValue( fieldName, newValue )
-
-25-Mar-2002
-Problems fixed:
- 1. Parameters were not being submitted for image buttons with no specified value
-
-21-Mar-2002
-Acknowledgements:
- Thanks to Frank Carver for extending base 64 encoding to handle character values > 127.
-
-Problems fixed:
- 1. Passwords with character values > 127 are now handled.
-
-
-15-Mar-2002
+20-Jun-2002 1.4.1
Acknowledgements:
Thanks to Stefan Renz for finding the file control value bug and providing a fix.
+ Thanks to Frank Carver for extending base 64 encoding to handle character values > 127.
+ Thanks to Yassen Damyanov for fixing a bug in the handling response headers
+ Thanks to James Murty for adding caching of servlet instances and some XML parsing cleanup.
+ Thanks to Robert Watkins for the content length test.
+ Thanks to Jessica Sant for correcting the handling of error statuses in JDK 1.3.1-03
Problems fixed:
1. Trying to get the value of a file parameter no longer results in a null pointer exception.
+ 2. Passwords with character values > 127 are now handled.
+ 3. Parameters were not being submitted for image buttons with no specified value
+ 4. Response headers were truncated to the first word only
+ 5. The servletunit tutorial failed with a NullPointerException in the first step.
+ 6. bug #570644: As of JDK 1.3.1-03, the behavior of HttpURLConnection was changed to throw an IOException when an
+ error status is returned. This broke HttpUnit's handling of error codes. This has since been corrected.
-14-Mar-2002
+19-Jun-2002
Additions:
- 1. It is now possible to set the action on a form using a mechanism which will support scripting in the future:
+ Content and parsing additions
+ 1. HttpUnit now sends Accept-encoding: gzip unless disabled by a call to HttpUnitOptions.setAcceptGzip( false )
+ 2. It is now possible to set the action on a form using a mechanism which will support scripting in the future:
form.getScriptableObject().setAction( newAction )
-
-11-Mar-2002
-
-Additions:
- 1. HttpUnit now sends Accept-encoding: gzip unless disabled by a call to HttpUnitOptions.setAcceptGzip( false )
+ 3. It is now possible to set the value of a hidden field in a form using a mechanism which will support scripting
+ in the future: form.getScriptableObject().setParameterValue( fieldName, newValue )
+ 4. A <select> control with a size attribute may now have its value undefined. The specification does not require
+ this behavior, but both IE 5.5 and Netscape 6.2 do this.
+ 5. WebResponse.getForms now caches its result so that multiple calls will return the same set of objects.
+ 6. WebClient.sendRequest is now available as an alias for WebRequest.getResponse
+ 7. An IO exception is thrown if the content length does not match the actual received length for a response and
+ content-length checking is enabled.
+
+ ServletUnit enhancements
+ 8. ServletUnit now caches its servlet instances so that multiple invocations can use the same instance. This more
+ closely matches the servlet spec.
+ 9. Leading and trailing spaces in web.xml text nodes are now ignored.
+ 10. If no other mapping matches a servlet name in a URL, ServletUnit will try to treat it as a servlet class name.
+ This means that you can use something like http://localhost/servlet/com.nowhere.MyServlet to access your servlet
+ without explicitly registering it.
+ 11. ServletUnitHttpRequest now implements getInputStream and getContentType.
+ 12. ServletUnit now implements the HttpServletRequest.getServletPath and getPathInfo methods.
Notes:
- 1. Hidden fields may not be modified if parameter validation is enabled, since they cannot be modified through
- normal user interaction (in the absence of JavaScript).
+ 1. Hidden fields may not be modified through the setParameter call if parameter validation is enabled, since they
+ cannot be modified through normal user interaction (in the absence of JavaScript). The getScriptableObject call
+ provides a way around this.
+ 2. The version of JTidy included with this release is 4-Aug-2000-r7, which seems to have fewer problems with classloading;
+ however, it is also described as a "less stable" pre-release.
6-Mar-2002 1.4
Index: todo.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- todo.txt 22 Jan 2002 15:25:16 -0000 1.26
+++ todo.txt 20 Jun 2002 15:33:18 -0000 1.27
@@ -1,7 +1,6 @@
-High Priority
-o Handle frames with the same name as one of their ancestors - fix both removal and lookup
-
Medium priority:
+o Enable client code to write directly to the output stream of a message body request
+o Provide customization for table to text
o Support optional tags which hide their contents (as in IFRAME, OBJECT, etc.)
o Check conformance with RFC 2109 - not currently sending $Version=1 string
o Support IFRAME tag
|
|
From: Russell G. <rus...@us...> - 2002-06-19 13:47:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv14187/src/com/meterware/servletunit
Modified Files:
InvocationContextImpl.java ServletUnitHttpRequest.java
ServletUnitServletConfig.java ServletUnitServletContext.java
WebApplication.java
Added Files:
ServletRequest.java
Log Message:
implemented getServerPath and getPathInfo
***** Error reading new file[Errno 2] No such file or directory: 'ServletRequest.java'
Index: InvocationContextImpl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- InvocationContextImpl.java 6 Mar 2002 04:59:52 -0000 1.4
+++ InvocationContextImpl.java 19 Jun 2002 13:47:19 -0000 1.5
@@ -67,13 +67,13 @@
public Servlet getServlet() throws ServletException {
if (_servlet == null) {
if (!_application.requiresAuthorization( _requestURL ) || userIsAuthorized() ) {
- _servlet = _application.getServlet( _requestURL );
+ _servlet = _application.getServletRequest( _requestURL ).getServlet();
} else if (_request.getRemoteUser() != null) {
throw new AccessDeniedException( _requestURL );
} else if (_application.usesBasicAuthentication()) {
throw new BasicAuthenticationRequiredException( _application.getAuthenticationRealm() );
} else if (_application.usesFormAuthentication()) {
- _servlet = _application.getServlet( _application.getLoginURL() );
+ _servlet = _application.getServletRequest( _application.getLoginURL() ).getServlet();
((ServletUnitHttpRequest) getRequest()).setOriginalURL( _requestURL );
} else {
throw new IllegalStateException( "Authorization required but no authentication method defined" );
@@ -135,7 +135,8 @@
_requestURL = request.getURL();
_target = request.getTarget();
- _request = new ServletUnitHttpRequest( request, runner.getContext(), clientHeaders, messageBody );
+ _request = new ServletUnitHttpRequest( _application.getServletRequest( _requestURL ), request, runner.getContext(),
+ clientHeaders, messageBody );
for (int i = 0; i < cookies.length; i++) _request.addCookie( cookies[i] );
if (_application.usesBasicAuthentication()) _request.readBasicAuthentication();
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ServletUnitHttpRequest.java 21 May 2002 13:57:56 -0000 1.12
+++ ServletUnitHttpRequest.java 19 Jun 2002 13:47:19 -0000 1.13
@@ -57,7 +57,8 @@
/**
* Constructs a ServletUnitHttpRequest from a WebRequest object.
**/
- ServletUnitHttpRequest( WebRequest request, ServletUnitContext context, Dictionary clientHeaders, byte[] messageBody ) throws MalformedURLException {
+ ServletUnitHttpRequest( ServletRequest servletRequest, WebRequest request, ServletUnitContext context, Dictionary clientHeaders, byte[] messageBody ) throws MalformedURLException {
+ _servletRequest = servletRequest;
_request = request;
_context = context;
_headers = new WebClient.HeaderDictionary();
@@ -165,8 +166,7 @@
* or a path to the servlet, but does not include any extra path information or a query string.
**/
public String getServletPath() {
- throwNotImplementedYet();
- return "";
+ return _servletRequest.getServletPath();
}
@@ -184,7 +184,7 @@
* This method returns null if there was no extra path information.
**/
public String getPathInfo() {
- return null;
+ return _servletRequest.getPathInfo();
}
@@ -720,6 +720,7 @@
private WebRequest _request;
+ private ServletRequest _servletRequest;
private WebClient.HeaderDictionary _headers;
private ServletUnitContext _context;
private ServletUnitHttpSession _session;
Index: ServletUnitServletConfig.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletConfig.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServletUnitServletConfig.java 1 Mar 2002 06:08:24 -0000 1.5
+++ ServletUnitServletConfig.java 19 Jun 2002 13:47:19 -0000 1.6
@@ -34,10 +34,10 @@
class ServletUnitServletConfig implements ServletConfig {
- ServletUnitServletConfig( Servlet servlet, WebApplication application, Hashtable initParams, Hashtable contextParams, File contextDir ) {
+ ServletUnitServletConfig( Servlet servlet, WebApplication application, Hashtable initParams ) {
_name = servlet.getClass().getName();
_initParameters = initParams;
- _context = new ServletUnitServletContext( application, contextParams, contextDir );
+ _context = new ServletUnitServletContext( application );
}
Index: ServletUnitServletContext.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ServletUnitServletContext.java 1 Mar 2002 06:08:24 -0000 1.8
+++ ServletUnitServletContext.java 19 Jun 2002 13:47:19 -0000 1.9
@@ -23,6 +23,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.FileNotFoundException;
import java.net.URL;
import java.net.MalformedURLException;
@@ -31,6 +32,7 @@
import java.util.Hashtable;
import java.util.Vector;
import java.util.Set;
+import java.util.Map;
import javax.servlet.*;
@@ -41,10 +43,8 @@
**/
class ServletUnitServletContext implements ServletContext {
- ServletUnitServletContext( WebApplication application, Hashtable contextParams, File contextDir ) {
+ ServletUnitServletContext( WebApplication application ) {
_application = application;
- _contextParams = contextParams;
- _contextDir = contextDir;
}
@@ -111,15 +111,11 @@
* method does not use class loaders.
**/
public java.net.URL getResource( String path ) {
- if (_contextDir == null) {
- return null; // no context, but maybe try against working dir?
- } else {
- try {
- File resourceFile = new File(_contextDir, path.substring(1));
- return resourceFile.toURL();
- } catch (IOException e) {
- return null;
- }
+ try {
+ File resourceFile = _application.getResourceFile( path );
+ return resourceFile == null ? null : resourceFile.toURL();
+ } catch (MalformedURLException e) {
+ return null;
}
}
@@ -138,15 +134,11 @@
* containers to make a resource available to a servlet from any location, without using a class loader.
**/
public java.io.InputStream getResourceAsStream( String path ) {
- if (_contextDir == null) {
- return null; // no context, but maybe try against working dir?
- } else {
- try {
- File resourceFile = new File(_contextDir, path.substring(1));
- return new FileInputStream(resourceFile);
- } catch (IOException e) {
- return null;
- }
+ try {
+ File resourceFile = _application.getResourceFile( path );
+ return resourceFile == null ? null : new FileInputStream( resourceFile );
+ } catch (FileNotFoundException e) {
+ return null;
}
}
@@ -161,7 +153,8 @@
**/
public javax.servlet.RequestDispatcher getRequestDispatcher( String path ) {
try {
- return new RequestDispatcherImpl( _application.getServlet( new URL( "http", "localhost", path ) ) );
+ URL url = new URL( "http", "localhost", path );
+ return new RequestDispatcherImpl( _application.getServletRequest( url ).getServlet() );
} catch (ServletException e) {
return null;
} catch (MalformedURLException e) {
@@ -267,7 +260,7 @@
* webmaster's email address or the name of a system that holds critical data.
**/
public java.lang.String getInitParameter( String name ) {
- return (String) _contextParams.get( name );
+ return (String) getContextParams().get( name );
}
@@ -276,7 +269,7 @@
* or an empty Enumeration if the context has no initialization parameters.
**/
public java.util.Enumeration getInitParameterNames() {
- return _contextParams.keys();
+ return getContextParams().keys();
}
@@ -351,12 +344,12 @@
void setInitParameter( String name, Object initParameter ) {
- _contextParams.put( name, initParameter );
+ getContextParams().put( name, initParameter );
}
void removeInitParameter( String name ) {
- _contextParams.remove( name );
+ getContextParams().remove( name );
}
@@ -366,6 +359,9 @@
private Hashtable _attributes = new Hashtable();
private WebApplication _application;
- private Hashtable _contextParams = new Hashtable();
- private File _contextDir;
+
+
+ private Hashtable getContextParams() {
+ return _application.getContextParameters();
+ }
}
Index: WebApplication.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- WebApplication.java 21 May 2002 20:43:31 -0000 1.9
+++ WebApplication.java 19 Jun 2002 13:47:19 -0000 1.10
@@ -55,6 +55,7 @@
**/
class WebApplication {
+
/**
* Constructs a default application spec with no information.
*/
@@ -120,53 +121,8 @@
}
- synchronized Servlet getServlet( URL url ) throws ServletException {
- final ServletConfiguration configuration = getServletConfiguration( url );
- if (configuration == null) throw new HttpNotFoundException( url );
-
- try {
- Class servletClass = Class.forName( configuration.getClassName() );
-
- Servlet cachedServlet = (Servlet)_cachedServlets.get(servletClass);
- if (cachedServlet != null) return cachedServlet;
-
- if (!Servlet.class.isAssignableFrom( servletClass )) throw new HttpInternalErrorException( url );
- Servlet servlet = (Servlet) servletClass.newInstance();
- servlet.init( new ServletUnitServletConfig( servlet, this, configuration.getInitParams(), _contextParameters, _contextDir ) );
- _cachedServlets.put( servletClass, servlet );
- return servlet;
- } catch (ClassNotFoundException e) {
- throw new HttpNotFoundException( url, e );
- } catch (IllegalAccessException e) {
- throw new HttpInternalErrorException( url, e );
- } catch (InstantiationException e) {
- throw new HttpInternalErrorException( url, e );
- }
- }
-
-
- private ServletConfiguration getServletConfiguration( URL url ) {
- if (!url.getFile().startsWith( _contextPath )) {
- return null;
- }
- String servletName = getServletName( getURLPath( url ) );
- if (servletName.endsWith( "j_security_check" )) {
- return SECURITY_CHECK_CONFIGURATION;
- } else {
- return _servletMapping.get( servletName );
- }
- }
-
-
- private String getURLPath( URL url ) {
- String file = url.getFile();
- if (_contextPath.equals( "" )) {
- return file;
- } else if (file.startsWith( _contextPath )) {
- return file.substring( _contextPath.length() );
- } else {
- return null;
- }
+ ServletRequest getServletRequest( URL url ) {
+ return _servletMapping.get( url );
}
@@ -206,7 +162,16 @@
* @param url the application-relative path of the URL
*/
boolean requiresAuthorization( URL url ) {
- return getControllingConstraint( getURLPath( url ) ) != NULL_SECURITY_CONSTRAINT;
+ String result;
+ String file = url.getFile();
+ if (_contextPath.equals( "" )) {
+ result = file;
+ } else if (file.startsWith( _contextPath )) {
+ result = file.substring( _contextPath.length() );
+ } else {
+ result = null;
+ }
+ return getControllingConstraint( result ) != NULL_SECURITY_CONSTRAINT;
}
@@ -214,7 +179,16 @@
* Returns true of the specified role may access the desired URL path.
*/
boolean roleMayAccess( String roleName, URL url ) {
- return getControllingConstraint( getURLPath( url ) ).hasRole( roleName );
+ String result;
+ String file = url.getFile();
+ if (_contextPath.equals( "" )) {
+ result = file;
+ } else if (file.startsWith( _contextPath )) {
+ result = file.substring( _contextPath.length() );
+ } else {
+ result = null;
+ }
+ return getControllingConstraint( result ).hasRole( roleName );
}
@@ -227,12 +201,31 @@
}
+ File getResourceFile( String path ) {
+ if (_contextDir == null) {
+ return null;
+ } else {
+ return new File( _contextDir, path.substring(1) );
+ }
+ }
+
+
+ Hashtable getContextParameters() {
+ return _contextParameters;
+ }
+
+
//------------------------------------------------ private members ---------------------------------------------
- private final static ServletConfiguration SECURITY_CHECK_CONFIGURATION = new ServletConfiguration( SecurityCheckServlet.class.getName() );
+
+ private final static SecurityConstraint NULL_SECURITY_CONSTRAINT = new NullSecurityConstraint();
+
+ private final ServletConfiguration SECURITY_CHECK_CONFIGURATION = new ServletConfiguration( SecurityCheckServlet.class.getName() );
+
+ private final ServletMapping SECURITY_CHECK_MAPPING = new ServletMapping( SECURITY_CHECK_CONFIGURATION );
/** A mapping of resource names to servlet class names. **/
- private ServletMapping _servletMapping = new ServletMapping();
+ private ServletMap _servletMapping = new ServletMap();
private ArrayList _securityConstraints = new ArrayList();
@@ -252,10 +245,6 @@
private String _contextPath = null;
- private HashMap _cachedServlets = new HashMap();
-
- final static private SecurityConstraint NULL_SECURITY_CONSTRAINT = new NullSecurityConstraint();
-
private void extractLoginConfiguration( Document document ) throws MalformedURLException, SAXException {
NodeList nl = document.getElementsByTagName( "login-config" );
@@ -338,17 +327,9 @@
}
- private String getServletName( String urlFile ) {
- if (urlFile.indexOf( '?' ) < 0) {
- return urlFile;
- } else {
- return urlFile.substring( 0, urlFile.indexOf( '?' ) );
- }
- }
-
-
//============================================= SecurityCheckServlet class =============================================
+
static class SecurityCheckServlet extends HttpServlet {
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
@@ -372,7 +353,7 @@
//============================================= ServletConfiguration class =============================================
- static class ServletConfiguration {
+ class ServletConfiguration {
public ServletConfiguration( String className ) {
_className = className;
@@ -389,6 +370,17 @@
}
+ synchronized Servlet getServlet() throws ClassNotFoundException, InstantiationException, IllegalAccessException, ServletException {
+ if (_servlet == null) {
+ Class servletClass = Class.forName( getClassName() );
+ _servlet = (Servlet) servletClass.newInstance();
+ _servlet.init( new ServletUnitServletConfig( _servlet, WebApplication.this, getInitParams() ) );
+ }
+
+ return _servlet;
+ }
+
+
String getClassName() {
return _className;
}
@@ -399,6 +391,7 @@
}
+ private Servlet _servlet;
private String _className;
private Hashtable _initParams = new Hashtable();
}
@@ -485,28 +478,126 @@
}
+ static class ServletRequestImpl implements ServletRequest {
+
+ private URL _url;
+ private String _servletName;
+ private ServletMapping _mapping;
+
+
+ ServletRequestImpl( URL url, String servletName, ServletMapping mapping ) {
+ _url = url;
+ _servletName = servletName;
+ _mapping = mapping;
+ }
+
+
+ public Servlet getServlet() throws ServletException {
+ if (getConfiguration() == null) throw new HttpNotFoundException( _url );
+
+ try {
+ return getConfiguration().getServlet();
+ } catch (ClassNotFoundException e) {
+ throw new HttpNotFoundException( _url, e );
+ } catch (IllegalAccessException e) {
+ throw new HttpInternalErrorException( _url, e );
+ } catch (InstantiationException e) {
+ throw new HttpInternalErrorException( _url, e );
+ } catch (ClassCastException e) {
+ throw new HttpInternalErrorException( _url, e );
+ }
+ }
+
+
+ public String getServletPath() {
+ return _mapping == null ? null : _mapping.getServletPath( _servletName );
+ }
+
+
+ public String getPathInfo() {
+ return _mapping == null ? null : _mapping.getPathInfo( _servletName );
+ }
+
+
+ private ServletConfiguration getConfiguration() {
+ return _mapping == null ? null : _mapping.getConfiguration();
+ }
+ }
+
+
+ static class ServletMapping {
+
+ private ServletConfiguration _configuration;
+
+
+ ServletConfiguration getConfiguration() {
+ return _configuration;
+ }
+
+
+ ServletMapping( ServletConfiguration configuration ) {
+ _configuration = configuration;
+ }
+
+
+ String getServletPath( String servletName ) {
+ return servletName;
+ }
+
+
+ String getPathInfo( String servletName ) {
+ return null;
+ }
+ }
+
+
+ static class PartialMatchServletMapping extends ServletMapping {
+
+ private String _prefix;
+
+
+ public PartialMatchServletMapping( ServletConfiguration configuration, String prefix ) {
+ super( configuration );
+ if (!prefix.endsWith( "/*" )) throw new IllegalArgumentException( prefix + " does not end with '/*'" );
+ _prefix = prefix.substring( 0, prefix.length()-2 );
+ }
+
+
+ String getServletPath( String servletName ) {
+ return _prefix;
+ }
+
+
+ String getPathInfo( String servletName ) {
+ return servletName.length() > _prefix.length()
+ ? servletName.substring( _prefix.length() )
+ : null;
+ }
+ }
+
+
/**
* A utility class for mapping servlets to url patterns. This implements the
* matching algorithm documented in section 10 of the JSDK-2.2 reference.
*/
- class ServletMapping {
+ class ServletMap {
private final Map _exactMatches = new HashMap();
private final Map _extensions = new HashMap();
private final Map _urlTree = new HashMap();
void put( String mapping, ServletConfiguration servletConfiguration ) {
- if (mapping.indexOf( '*' ) == -1) {
- _exactMatches.put( mapping, servletConfiguration );
- } else if (mapping.startsWith( "*." )) {
- _extensions.put( mapping.substring( 2 ), servletConfiguration );
+ if (mapping.startsWith( "*." )) {
+ _extensions.put( mapping.substring( 2 ), new ServletMapping( servletConfiguration ) );
+ } else if (!mapping.startsWith( "/" ) || !mapping.endsWith( "/*" )) {
+ _exactMatches.put( mapping, new ServletMapping( servletConfiguration ) );
} else {
ParsedPath path = new ParsedPath( mapping );
Map context = _urlTree;
while (path.hasNext()) {
String part = path.next();
if (part.equals( "*" )) {
- context.put( "*", servletConfiguration );
+ context.put( "*", new PartialMatchServletMapping( servletConfiguration, mapping ) );
return;
}
if (!context.containsKey( part )) {
@@ -514,20 +605,42 @@
}
context = (Map) context.get( part );
}
- context.put( "/", servletConfiguration );
}
}
- ServletConfiguration get( String url ) {
- if (_exactMatches.containsKey( url )) return (ServletConfiguration) _exactMatches.get( url );
+ ServletRequest get( URL url ) {
+ String file = url.getFile();
+ if (!file.startsWith( _contextPath )) throw new HttpNotFoundException( url );
+
+ String servletName = getServletName( file.substring( _contextPath.length() ) );
+
+ if (servletName.endsWith( "j_security_check" )) {
+ return new ServletRequestImpl( url, servletName, SECURITY_CHECK_MAPPING );
+ } else {
+ return new ServletRequestImpl( url, servletName, getMapping( servletName ) );
+ }
+ }
+
+
+ private String getServletName( String urlFile ) {
+ if (urlFile.indexOf( '?' ) < 0) {
+ return urlFile;
+ } else {
+ return urlFile.substring( 0, urlFile.indexOf( '?' ) );
+ }
+ }
+
+
+ private ServletMapping getMapping( String url ) {
+ if (_exactMatches.containsKey( url )) return (ServletMapping) _exactMatches.get( url );
Map context = getContextForLongestPathPrefix( url );
- if (context.containsKey( "*" )) return (ServletConfiguration) context.get( "*" );
+ if (context.containsKey( "*" )) return (ServletMapping) context.get( "*" );
- if (_extensions.containsKey( getExtension( url ))) return (ServletConfiguration) _extensions.get( getExtension( url ) );
+ if (_extensions.containsKey( getExtension( url ))) return (ServletMapping) _extensions.get( getExtension( url ) );
- if (_urlTree.containsKey( "/" )) return (ServletConfiguration) _urlTree.get( "/" );
+ if (_urlTree.containsKey( "/" )) return (ServletMapping) _urlTree.get( "/" );
final String prefix = "/servlet/";
if (!url.startsWith( prefix )) return null;
@@ -535,7 +648,7 @@
String className = url.substring( prefix.length() );
try {
Class.forName( className );
- return new ServletConfiguration( className );
+ return new ServletMapping( new ServletConfiguration( className ) );
} catch (ClassNotFoundException e) {
return null;
}
|
|
From: Russell G. <rus...@us...> - 2002-06-19 13:47:25
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv14187/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java WebXMLTest.java
Log Message:
implemented getServerPath and getPathInfo
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HttpServletRequestTest.java 20 May 2002 16:00:13 -0000 1.6
+++ HttpServletRequestTest.java 19 Jun 2002 13:47:20 -0000 1.7
@@ -25,6 +25,8 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebRequest;
@@ -54,7 +56,7 @@
public void testGetDefaultProperties() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertNull( "Authorization incorrectly specified", request.getAuthType() );
assertNull( "Character encoding incorrectly specified", request.getCharacterEncoding() );
assertEquals( "Parameters unexpectedly specified", "", request.getQueryString() );
@@ -66,7 +68,7 @@
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "age parameter", "12", request.getParameter( "age" ) );
assertNull( "unset parameter should be null", request.getParameter( "unset" ) );
@@ -77,7 +79,7 @@
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) );
assertMatchingSet( "color parameter", new String[] { "red", "blue" }, request.getParameterValues( "color" ) );
@@ -89,7 +91,7 @@
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "query string", "color=red&color=blue&age=12", request.getQueryString() );
}
@@ -97,7 +99,7 @@
public void testInlineSingleValuedParameter() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "age parameter", "12", request.getParameter( "age" ) );
assertNull( "unset parameter should be null", request.getParameter( "unset" ) );
@@ -106,7 +108,7 @@
public void testInlineMultiValuedParameter() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) );
assertMatchingSet( "color parameter", new String[] { "red", "blue" }, request.getParameterValues( "color" ) );
@@ -116,7 +118,7 @@
public void notestInlineQueryString() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "query string", "color=red&color=blue&age=12", request.getQueryString() );
}
@@ -124,7 +126,7 @@
public void testDefaultAttributes() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertNull( "attribute should not be defined yet", request.getAttribute( "unset" ) );
assertTrue( "attribute enumeration should be empty", !request.getAttributeNames().hasMoreElements() );
@@ -133,7 +135,7 @@
public void testNonDefaultAttributes() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
Object value = new Integer(1);
request.setAttribute( "one", value );
@@ -149,7 +151,7 @@
public void testDuplicateAttributes() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
Object value = new Integer(1);
request.setAttribute( "one", value );
@@ -164,7 +166,7 @@
public void testSessionCreation() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
HttpSession session = request.getSession( /* create */ false );
assertNull( "Unexpected session found", session );
@@ -177,7 +179,7 @@
public void testDefaultCookies() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
Cookie[] cookies = request.getCookies();
assertNull( "Unexpected cookies found", cookies );
}
@@ -185,7 +187,7 @@
public void testSetCookies() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- ServletUnitHttpRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+ ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
request.addCookie( new Cookie( "flavor", "vanilla" ) );
Cookie[] cookies = request.getCookies();
@@ -200,7 +202,7 @@
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitContext context = new ServletUnitContext();
- ServletUnitHttpRequest request = new ServletUnitHttpRequest( wr, context, new Hashtable(), NO_MESSAGE_BODY );
+ ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, context.newSession().getId() ) );
HttpSession session = request.getSession( /* create */ false );
@@ -212,16 +214,33 @@
ServletUnitContext context = new ServletUnitContext();
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
- ServletUnitHttpRequest request = new ServletUnitHttpRequest( wr, context, new Hashtable(), NO_MESSAGE_BODY );
+ ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
assertEquals("/simple", request.getRequestURI());
wr = new GetMethodWebRequest( "http://localhost/simple?foo=bar" );
- request = new ServletUnitHttpRequest( wr, context, new Hashtable(), NO_MESSAGE_BODY);
+ request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
assertEquals("/simple", request.getRequestURI());
}
private final static byte[] NO_MESSAGE_BODY = new byte[0];
+
+ private final static ServletRequest NULL_SERVLET_REQUEST = new ServletRequest() {
+
+ public Servlet getServlet() throws ServletException {
+ return null;
+ }
+
+
+ public String getServletPath() {
+ return null;
+ }
+
+
+ public String getPathInfo() {
+ return null;
+ }
+ };
}
Index: WebXMLTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- WebXMLTest.java 21 May 2002 20:43:31 -0000 1.9
+++ WebXMLTest.java 19 Jun 2002 13:47:20 -0000 1.10
@@ -264,8 +264,8 @@
ServletRunner sr = new ServletRunner( toInputStream( wxs.asText() ) );
ServletUnitClient wc = sr.newClient();
- checkMapping( wc, "http://localhost/foo/bar/index.html", Servlet1.class, "/foo/bar", "/index.html" );
- checkMapping( wc, "http://localhost/foo/bar/index.bop", Servlet1.class, "/foo/bar", "/index.bop" );
+ checkMapping( wc, "http://localhost/foo/bar/index.html", Servlet1.class, "/foo/bar", "/index.html" );
+ checkMapping( wc, "http://localhost/foo/bar/index.bop", Servlet1.class, "/foo/bar", "/index.bop" );
checkMapping( wc, "http://localhost/baz", Servlet2.class, "/baz", null );
checkMapping( wc, "http://localhost/baz/index.html", Servlet2.class, "/baz", "/index.html" );
checkMapping( wc, "http://localhost/catalog", Servlet3.class, "/catalog", null );
@@ -283,8 +283,8 @@
private void checkMapping( ServletUnitClient wc, final String url, final Class servletClass, final String expectedPath, final String expectedInfo ) throws IOException, ServletException {
InvocationContext ic = wc.newInvocation( url );
assertTrue( servletClass.isInstance( ic.getServlet() ) );
-// assertEquals( "ServletPath", expectedPath, ic.getRequest().getServletPath() );
-// assertEquals( "ServletInfo", expectedInfo, ic.getRequest().getPathInfo() );
+ assertEquals( "ServletPath for " + url, expectedPath, ic.getRequest().getServletPath() );
+ assertEquals( "ServletInfo for " + url, expectedInfo, ic.getRequest().getPathInfo() );
}
|
|
From: Russell G. <rus...@us...> - 2002-06-19 13:47:22
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv14187/doc
Modified Files:
release_notes.txt
Log Message:
implemented getServerPath and getPathInfo
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- release_notes.txt 18 Jun 2002 16:53:20 -0000 1.113
+++ release_notes.txt 19 Jun 2002 13:47:19 -0000 1.114
@@ -12,6 +12,10 @@
Revision History:
+19-Jun-2002
+Additions:
+ 1. ServletUnit now implements the HttpServletRequest.getServletPath and getPathInfo methods.
+
18-Jun-2002
Acknowledgements:
Thanks to Jessica Sant for correcting the handling of error statuses.
|
|
From: Russell G. <rus...@us...> - 2002-06-19 13:46:56
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv14083/src/com/meterware/httpunit
Modified Files:
WebLink.java WebTable.java
Log Message:
Clean up javadoc
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WebLink.java 6 Mar 2002 03:45:57 -0000 1.18
+++ WebLink.java 19 Jun 2002 13:46:51 -0000 1.19
@@ -34,7 +34,7 @@
/**
* This class represents a link in an HTML page. Users of this class may examine the
- * structure of the link (as a DOM), or create a {@tag WebRequest} to simulate clicking
+ * structure of the link (as a DOM), or create a {@link WebRequest} to simulate clicking
* on the link.
*
* @author <a href="mailto:rus...@ac...">Russell Gold</a>
Index: WebTable.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebTable.java 27 Nov 2001 19:51:27 -0000 1.15
+++ WebTable.java 19 Jun 2002 13:46:52 -0000 1.16
@@ -89,7 +89,6 @@
/**
* Returns the contents of the specified table cell with a given ID
* @return TableCell with given ID or null if ID is not found.
- * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a>
**/
public TableCell getTableCellWithID( String id ) {
if (_cells == null) readTable();
|
|
From: Russell G. <rus...@us...> - 2002-06-18 16:53:24
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv25413/test/com/meterware/servletunit
Modified Files:
ServletUnitTest.java
Log Message:
Removed temporary assertTrue definitions
Index: ServletUnitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ServletUnitTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServletUnitTest.java 5 Nov 2001 18:54:51 -0000 1.2
+++ ServletUnitTest.java 18 Jun 2002 16:53:21 -0000 1.3
@@ -41,11 +41,6 @@
super( name );
}
- public static void assertTrue( String comment, boolean expression ) {
- assert( comment, expression );
- }
-
-
//------------------------------------ protected members ------------------------------------------
|
|
From: Russell G. <rus...@us...> - 2002-06-18 16:53:23
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv25413/test/com/meterware/httpunit
Modified Files:
HttpUnitTest.java
Log Message:
Removed temporary assertTrue definitions
Index: HttpUnitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitTest.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- HttpUnitTest.java 21 Mar 2002 15:44:03 -0000 1.20
+++ HttpUnitTest.java 18 Jun 2002 16:53:20 -0000 1.21
@@ -99,10 +99,6 @@
return _hostPath;
}
- public static void assertTrue( String comment, boolean expression ) {
- assert( comment, expression );
- }
-
protected void assertEquals( String comment, Object[] expected, Object[] found ) {
if (!equals( expected, found )) {
|
|
From: Russell G. <rus...@us...> - 2002-06-18 16:53:23
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv25413/doc
Modified Files:
release_notes.txt
Log Message:
Removed temporary assertTrue definitions
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- release_notes.txt 18 Jun 2002 16:37:03 -0000 1.112
+++ release_notes.txt 18 Jun 2002 16:53:20 -0000 1.113
@@ -16,8 +16,8 @@
Acknowledgements:
Thanks to Jessica Sant for correcting the handling of error statuses.
Problems fixed:
- 1. As of JDK 1.3.1-03, the behavior of HttpURLConnection was changed to throw an IOException when an error status
- is returned. This broke HttpUnit's handling of error codes. This has since been corrected.
+ 1. bug #570644: As of JDK 1.3.1-03, the behavior of HttpURLConnection was changed to throw an IOException when an
+ error status is returned. This broke HttpUnit's handling of error codes. This has since been corrected.
17-Jun-2002
Acknowledgements:
|
|
From: Russell G. <rus...@us...> - 2002-06-18 16:37:07
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv17522/src/com/meterware/httpunit
Modified Files:
HttpWebResponse.java
Log Message:
from Jessica Sant: fixed handling of error status under JDK 1.3.1-03
Index: HttpWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- HttpWebResponse.java 9 May 2002 20:02:46 -0000 1.22
+++ HttpWebResponse.java 18 Jun 2002 16:37:03 -0000 1.23
@@ -22,6 +22,7 @@
import java.io.BufferedInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -53,7 +54,9 @@
/** make sure that any IO exception for HTML received page happens here, not later. **/
if (_responseCode < HttpURLConnection.HTTP_BAD_REQUEST || !throwExceptionOnError) {
- defineRawInputStream( new BufferedInputStream( connection.getInputStream() ) );
+ InputStream stream = (_responseCode < HttpURLConnection.HTTP_BAD_REQUEST) ? connection.getInputStream()
+ : ((HttpURLConnection) connection).getErrorStream();
+ defineRawInputStream( new BufferedInputStream( stream ) );
if (getContentType().startsWith( "text" )) loadResponseText();
}
}
|
|
From: Russell G. <rus...@us...> - 2002-06-18 16:37:07
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv17522/doc
Modified Files:
release_notes.txt
Log Message:
from Jessica Sant: fixed handling of error status under JDK 1.3.1-03
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- release_notes.txt 17 Jun 2002 21:22:04 -0000 1.111
+++ release_notes.txt 18 Jun 2002 16:37:03 -0000 1.112
@@ -12,6 +12,13 @@
Revision History:
+18-Jun-2002
+Acknowledgements:
+ Thanks to Jessica Sant for correcting the handling of error statuses.
+Problems fixed:
+ 1. As of JDK 1.3.1-03, the behavior of HttpURLConnection was changed to throw an IOException when an error status
+ is returned. This broke HttpUnit's handling of error codes. This has since been corrected.
+
17-Jun-2002
Acknowledgements:
Thanks to Robert Watkins for the content length test.
|
|
From: Russell G. <rus...@us...> - 2002-06-17 21:22:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv6049/src/com/meterware/httpunit
Modified Files:
HttpUnitOptions.java WebResponse.java
Log Message:
Robert Watkins: Added check for message truncated
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- HttpUnitOptions.java 20 May 2002 16:00:42 -0000 1.19
+++ HttpUnitOptions.java 17 Jun 2002 21:22:05 -0000 1.20
@@ -43,6 +43,7 @@
_matchesIgnoreCase = true;
_autoRefresh = false;
_autoRedirect = true;
+ _checkContentLength = false;
_redirectDelay = 0;
_characterSet = HttpUnitUtils.DEFAULT_CHARACTER_SET;
_contentType = DEFAULT_CONTENT_TYPE;
@@ -102,6 +103,24 @@
/**
+ * Returns true if HttpUnit will throw an exception when a message is only partially received. The default is
+ * to avoid such checks.
+ */
+ public static boolean isCheckContentLength() {
+ return _checkContentLength;
+ }
+
+
+ /**
+ * Specifies whether HttpUnit should throw an exception when the content length of a message does not match its
+ * actual received length. Defaults to false.
+ */
+ public static void setCheckContentLength( boolean checkContentLength ) {
+ _checkContentLength = checkContentLength;
+ }
+
+
+ /**
* Determines whether a normal POST request will include the character set in the content-type header.
* The default is to include it; however, some older servlet engines (most notably Tomcat 3.1) get confused
* when they see it.
@@ -340,6 +359,8 @@
private static boolean _autoRedirect = true;
private static boolean _postIncludesCharset = false;
+
+ private static boolean _checkContentLength = false;
private static int _redirectDelay;
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- WebResponse.java 16 May 2002 17:44:20 -0000 1.65
+++ WebResponse.java 17 Jun 2002 21:22:05 -0000 1.66
@@ -158,6 +158,19 @@
/**
+ * Returns the content length of this response.
+ * @return the content length, if known, or -1.
+ */
+ public int getContentLength() {
+ if (_contentLength == UNINITIALIZED_INT) {
+ String length = getHeaderField( "Content-Length" );
+ _contentLength = (length == null) ? -1 : Integer.parseInt( length );
+ }
+ return _contentLength;
+ }
+
+
+ /**
* Returns the content type of this response.
**/
public String getContentType() {
@@ -551,12 +564,16 @@
final private static String HTML_CONTENT = "text/html";
+ final private static int UNINITIALIZED_INT = -2;
+
private WebFrame[] _frames;
private ReceivedPage _page;
private String _contentHeader;
+ private int _contentLength = UNINITIALIZED_INT;
+
private String _contentType;
private String _characterSet;
@@ -600,6 +617,11 @@
readMetaTags( bytes );
_responseText = new String( bytes, getCharacterSet() );
_inputStream = new ByteArrayInputStream( bytes );
+
+ if (HttpUnitOptions.isCheckContentLength() && getContentLength() >= 0 && bytes.length != getContentLength()) {
+ throw new IOException("Truncated message. Expected length: " + getContentLength() +
+ ", Actual length: " + bytes.length);
+ }
} finally {
inputStream.close();
}
|
|
From: Russell G. <rus...@us...> - 2002-06-17 21:22:08
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv6049/doc
Modified Files:
release_notes.txt
Log Message:
Robert Watkins: Added check for message truncated
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- release_notes.txt 21 May 2002 20:43:30 -0000 1.110
+++ release_notes.txt 17 Jun 2002 21:22:04 -0000 1.111
@@ -12,6 +12,14 @@
Revision History:
+17-Jun-2002
+Acknowledgements:
+ Thanks to Robert Watkins for the content length test.
+
+Additions:
+ 1. An IO exception is thrown if the content length does not match the actual received length for a response and
+ content-length checking is enabled.
+
21-May-2002
Correction:
1. ServletUnit supports urls beginning with "/servlet/" as referring to a servlet class name if not mapped to anything else.
|
|
From: Russell G. <rus...@us...> - 2002-06-17 21:22:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv6049/test/com/meterware/httpunit
Modified Files:
WebPageTest.java
Log Message:
Robert Watkins: Added check for message truncated
Index: WebPageTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WebPageTest.java 14 Nov 2001 17:28:25 -0000 1.19
+++ WebPageTest.java 17 Jun 2002 21:22:05 -0000 1.20
@@ -338,4 +338,24 @@
}
return sb.toString();
}
+
+
+ /**
+ * This test verifies that an IO exception is thrown when only a partial response is received.
+ */
+ public void testTruncatedPage() throws Exception {
+ HttpUnitOptions.setCheckContentLength( true );
+ String page = "abcdefghijklmnop";
+ defineResource( "alphabet.html", page, "text/plain" );
+ addResourceHeader( "alphabet.html", "Content-length: 26" );
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( getHostPath() + "/alphabet.html" );
+ try {
+ WebResponse simplePage = wc.getResponse( request );
+ String alphabet = simplePage.getText();
+ assertEquals( "Full string", "abcdefghijklmnopqrstuvwxyz", alphabet );
+ } catch (IOException e) {
+ }
+ }
}
|
|
From: Russell G. <rus...@us...> - 2002-06-17 18:43:18
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv21557/test/com/meterware/httpunit
Modified Files:
FormSubmitTest.java
Log Message:
Add test for image button with no value
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FormSubmitTest.java 25 Mar 2002 05:07:29 -0000 1.17
+++ FormSubmitTest.java 17 Jun 2002 18:43:15 -0000 1.18
@@ -249,6 +249,17 @@
}
+ public void testImageButtonNoValuePositionalSubmit() throws Exception {
+ defineWebPage( "Default", "<form method='GET' action='test.jsp'>" +
+ "<input type='image' src='image.gif' name='aButton'>" +
+ "</form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getForms()[0];
+ WebRequest request = form.getRequest( form.getSubmitButton( "aButton" ), 20, 5 );
+ assertEquals( getHostPath() + "/test.jsp?aButton.x=20&aButton.y=5", request.getURL().toExternalForm() );
+ }
+
+
public void testSubmitButtonAttributes() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age value=12>" +
|
|
From: Russell G. <rus...@us...> - 2002-05-21 20:43:33
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv8706/test/com/meterware/servletunit
Modified Files:
StatelessTest.java WebXMLTest.java
Log Message:
Some cleanup and refactoring
Index: StatelessTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/StatelessTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StatelessTest.java 16 May 2002 19:04:13 -0000 1.6
+++ StatelessTest.java 21 May 2002 20:43:31 -0000 1.7
@@ -78,7 +78,7 @@
public void testServletAccessByClassName() throws Exception {
ServletRunner sr = new ServletRunner();
- WebRequest request = new GetMethodWebRequest( "http://localhost/" + SimpleGetServlet.class.getName() );
+ WebRequest request = new GetMethodWebRequest( "http://localhost/servlet/" + SimpleGetServlet.class.getName() );
WebResponse response = sr.getResponse( request );
assertNotNull( "No response received", response );
assertEquals( "content type", "text/html", response.getContentType() );
@@ -155,6 +155,20 @@
assertNotNull( "No response received", response );
assertEquals( "content type", "text/plain", response.getContentType() );
assertEquals( "requested resource", "You posted red", response.getText() );
+ }
+
+
+ public void testRequestInputStream() throws Exception {
+ ServletRunner sr = new ServletRunner();
+ WebRequest request = new PostMethodWebRequest( "http://localhost/servlet/" + ParameterServlet.class.getName() );
+ request.setParameter( "color", "green" );
+ final String expectedBody = "color=green";
+ InvocationContext ic = sr.newClient().newInvocation( request );
+ assertEquals( "Message body type", "application/x-www-form-urlencoded", ic.getRequest().getContentType() );
+ InputStream is = ic.getRequest().getInputStream();
+ byte[] buffer = new byte[ expectedBody.length() ];
+ assertEquals( "Input stream length", buffer.length, is.read( buffer ) );
+ assertEquals( "Message body", expectedBody, new String( buffer ) );
}
Index: WebXMLTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebXMLTest.java 16 May 2002 19:04:13 -0000 1.8
+++ WebXMLTest.java 21 May 2002 20:43:31 -0000 1.9
@@ -257,32 +257,36 @@
public void testServletMapping() throws Exception {
WebXMLString wxs = new WebXMLString();
- wxs.addServlet("/foo/bar/*", Servlet1.class);
- wxs.addServlet("/baz/*", Servlet2.class);
- wxs.addServlet("/catalog", Servlet3.class);
- wxs.addServlet("*.bop", Servlet4.class);
- ServletRunner sr = new ServletRunner( toInputStream( wxs.asText() ));
+ wxs.addServlet( "/foo/bar/*", Servlet1.class );
+ wxs.addServlet( "/baz/*", Servlet2.class );
+ wxs.addServlet( "/catalog", Servlet3.class );
+ wxs.addServlet( "*.bop", Servlet4.class );
+ ServletRunner sr = new ServletRunner( toInputStream( wxs.asText() ) );
ServletUnitClient wc = sr.newClient();
- InvocationContext ic = wc.newInvocation("http://localhost/foo/bar/index.html");
- assertTrue(ic.getServlet() instanceof Servlet1);
- ic = wc.newInvocation("http://localhost/foo/bar/index.bop");
- assertTrue(ic.getServlet() instanceof Servlet1);
- ic = wc.newInvocation("http://localhost/baz");
- assertTrue(ic.getServlet() instanceof Servlet2);
- ic = wc.newInvocation("http://localhost/baz/index.html");
- assertTrue(ic.getServlet() instanceof Servlet2);
- ic = wc.newInvocation("http://localhost/catalog");
- assertTrue(ic.getServlet() instanceof Servlet3);
+
+ checkMapping( wc, "http://localhost/foo/bar/index.html", Servlet1.class, "/foo/bar", "/index.html" );
+ checkMapping( wc, "http://localhost/foo/bar/index.bop", Servlet1.class, "/foo/bar", "/index.bop" );
+ checkMapping( wc, "http://localhost/baz", Servlet2.class, "/baz", null );
+ checkMapping( wc, "http://localhost/baz/index.html", Servlet2.class, "/baz", "/index.html" );
+ checkMapping( wc, "http://localhost/catalog", Servlet3.class, "/catalog", null );
+ checkMapping( wc, "http://localhost/catalog/racecar.bop", Servlet4.class, "/catalog/racecar.bop", null );
+ checkMapping( wc, "http://localhost/index.bop", Servlet4.class, "/index.bop", null );
+
try {
- ic = wc.newInvocation("http://localhost/catalog/index.html");
- ic.getServlet();
- fail("Should have gotten a 404");
- } catch (HttpNotFoundException e) {}
- ic = wc.newInvocation("http://localhost/catalog/racecar.bop");
- assertTrue(ic.getServlet() instanceof Servlet4);
- ic = wc.newInvocation("http://localhost/index.bop");
- assertTrue(ic.getServlet() instanceof Servlet4);
+ wc.newInvocation( "http://localhost/catalog/index.html" ).getServlet();
+ fail( "Should have gotten a 404" );
+ } catch (HttpNotFoundException e) {
+ }
}
+
+
+ private void checkMapping( ServletUnitClient wc, final String url, final Class servletClass, final String expectedPath, final String expectedInfo ) throws IOException, ServletException {
+ InvocationContext ic = wc.newInvocation( url );
+ assertTrue( servletClass.isInstance( ic.getServlet() ) );
+// assertEquals( "ServletPath", expectedPath, ic.getRequest().getServletPath() );
+// assertEquals( "ServletInfo", expectedInfo, ic.getRequest().getPathInfo() );
+ }
+
//===============================================================================================================
|
|
From: Russell G. <rus...@us...> - 2002-05-21 20:43:33
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv8706/src/com/meterware/servletunit
Modified Files:
ServletRunner.java WebApplication.java
Log Message:
Some cleanup and refactoring
Index: ServletRunner.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ServletRunner.java 20 May 2002 16:00:44 -0000 1.15
+++ ServletRunner.java 21 May 2002 20:43:31 -0000 1.16
@@ -129,11 +129,6 @@
//-------------------------------------------- package methods ---------------------------------------------------------
- Servlet getServlet( URL url ) throws ServletException {
- return _application.getServlet( url );
- }
-
-
ServletUnitContext getContext() {
return _context;
}
Index: WebApplication.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WebApplication.java 16 May 2002 19:04:13 -0000 1.8
+++ WebApplication.java 21 May 2002 20:43:31 -0000 1.9
@@ -529,7 +529,10 @@
if (_urlTree.containsKey( "/" )) return (ServletConfiguration) _urlTree.get( "/" );
- String className = url.substring( 1 );
+ final String prefix = "/servlet/";
+ if (!url.startsWith( prefix )) return null;
+
+ String className = url.substring( prefix.length() );
try {
Class.forName( className );
return new ServletConfiguration( className );
|
|
From: Russell G. <rus...@us...> - 2002-05-21 20:43:33
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv8706/doc
Modified Files:
release_notes.txt
Log Message:
Some cleanup and refactoring
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -r1.109 -r1.110
--- release_notes.txt 20 May 2002 16:00:14 -0000 1.109
+++ release_notes.txt 21 May 2002 20:43:30 -0000 1.110
@@ -8,9 +8,14 @@
Limitations:
1. HttpUnit does not support JavaScript
2. JDK 1.2 or higher is required
+ 3. ServletUnit does not support JSP
Revision History:
+21-May-2002
+Correction:
+ 1. ServletUnit supports urls beginning with "/servlet/" as referring to a servlet class name if not mapped to anything else.
+
20-May-2002
Additions:
1. ServletUnitHttpRequest now implements getInputStream and getContentType.
|
|
From: Russell G. <rus...@us...> - 2002-05-21 13:58:00
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv17468/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java
Log Message:
Return entire content-type header in getContentType
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ServletUnitHttpRequest.java 20 May 2002 16:00:13 -0000 1.11
+++ ServletUnitHttpRequest.java 21 May 2002 13:57:56 -0000 1.12
@@ -64,7 +64,7 @@
_headers.addEntries( clientHeaders );
_headers.addEntries( request.getHeaders() );
_messageBody = messageBody;
- readContentTypeHeader();
+ _contentType = (String) _headers.get( "Content-Type" );
if (context == null) throw new IllegalArgumentException( "Context must not be null" );
String file = request.getURL().getFile();
@@ -75,14 +75,6 @@
loadParameters( request.getQueryString() );
loadParameters( new String( _messageBody ) );
}
- }
- }
-
-
- private void readContentTypeHeader() {
- _contentType = (String) _headers.get( "Content-Type" );
- if (_contentType != null && _contentType.indexOf( ';' ) >= 0) {
- _contentType = _contentType.substring( 0, _contentType.indexOf( ';' ) );
}
}
|
|
From: Russell G. <rus...@us...> - 2002-05-20 16:00:46
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv31967/test/com/meterware/servletunit Modified Files: ConfigTest.java Log Message: Removed unused fields, methods, and imports Index: ConfigTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ConfigTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ConfigTest.java 18 Jun 2001 20:21:30 -0000 1.2 +++ ConfigTest.java 20 May 2002 16:00:44 -0000 1.3 @@ -19,16 +19,21 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ -import java.io.*; -import java.net.HttpURLConnection; -import javax.servlet.*; -import javax.servlet.http.*; +import com.meterware.httpunit.WebClient; +import com.meterware.httpunit.WebResponse; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; - -import com.meterware.httpunit.*; /** * Tests support for the servlet configuration. |
|
From: Russell G. <rus...@us...> - 2002-05-20 16:00:46
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv31967/src/com/meterware/httpunit
Modified Files:
HttpUnitOptions.java MimeEncodedMessageBody.java
PostMethodWebRequest.java WebRequest.java
Log Message:
Removed unused fields, methods, and imports
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- HttpUnitOptions.java 11 Mar 2002 12:34:31 -0000 1.18
+++ HttpUnitOptions.java 20 May 2002 16:00:42 -0000 1.19
@@ -320,7 +320,6 @@
private static final String DEFAULT_CONTENT_TYPE = "text/plain";
- private static final String DEFAULT_CONTENT_HEADER = DEFAULT_CONTENT_TYPE;
private static boolean _acceptGzip = true;
Index: MimeEncodedMessageBody.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/MimeEncodedMessageBody.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- MimeEncodedMessageBody.java 14 Jan 2002 18:13:45 -0000 1.11
+++ MimeEncodedMessageBody.java 20 May 2002 16:00:43 -0000 1.12
@@ -20,11 +20,8 @@
*
*******************************************************************************************************************/
import java.io.IOException;
-import java.io.OutputStream;
import java.io.InputStream;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
+import java.io.OutputStream;
/**
* A POST-method message body which is MIME-encoded. This is used when uploading files, and is selected when the enctype
Index: PostMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- PostMethodWebRequest.java 4 Feb 2002 22:33:55 -0000 1.23
+++ PostMethodWebRequest.java 20 May 2002 16:00:43 -0000 1.24
@@ -19,16 +19,11 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.io.File;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-
import java.net.URL;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
/**
* An HTTP request using the POST method.
@@ -132,11 +127,7 @@
//---------------------------------- private members -------------------------------------
- private InputStream _source;
private MessageBody _body;
-
- /** If true, non-form-based request will be MIME-encoded. **/
- private boolean _mimeEncoded;
}
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- WebRequest.java 4 Mar 2002 02:10:50 -0000 1.40
+++ WebRequest.java 20 May 2002 16:00:43 -0000 1.41
@@ -20,7 +20,6 @@
*
*******************************************************************************************************************/
import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -438,14 +437,6 @@
if (!_httpsProtocolSupportEnabled) {
verifyHttpsSupport();
_httpsProtocolSupportEnabled = true;
- }
- }
-
-
- private static void listProviders() {
- Provider[] list = Security.getProviders();
- for (int i = 0; i < list.length; i++) {
- System.out.println( "provider" + i + "=" + list[i] );
}
}
|