httpunit-commit Mailing List for httpunit (Page 70)
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...> - 2001-11-12 20:22:57
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial/src/tutorial In directory usw-pr-cvs1:/tmp/cvs-serv11608/doc/tutorial/src/tutorial Log Message: Directory /cvsroot/httpunit/httpunit/doc/tutorial/src/tutorial added to the repository |
|
From: Russell G. <rus...@us...> - 2001-11-12 20:22:13
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial/src In directory usw-pr-cvs1:/tmp/cvs-serv11394/doc/tutorial/src Log Message: Directory /cvsroot/httpunit/httpunit/doc/tutorial/src added to the repository |
|
From: Russell G. <rus...@us...> - 2001-11-12 20:21:12
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory usw-pr-cvs1:/tmp/cvs-serv11006/doc/tutorial Log Message: Directory /cvsroot/httpunit/httpunit/doc/tutorial added to the repository |
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv31024/src/com/meterware/servletunit
Modified Files:
InvocationContext.java ServletRunner.java
ServletUnitHttpRequest.java ServletUnitHttpResponse.java
ServletUnitHttpSession.java
Log Message:
General code cleanup
Index: InvocationContext.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InvocationContext.java 2001/06/06 13:25:04 1.1
+++ InvocationContext.java 2001/11/12 19:48:35 1.2
@@ -19,11 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
-
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
Index: ServletRunner.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletRunner.java 2001/11/08 22:07:53 1.6
+++ ServletRunner.java 2001/11/12 19:48:35 1.7
@@ -19,37 +19,30 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+import com.meterware.httpunit.WebResponse;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.HttpNotFoundException;
+import com.meterware.httpunit.HttpInternalErrorException;
-import java.io.IOException;
import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-import java.util.Vector;
import java.util.Dictionary;
+import java.util.Hashtable;
import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.meterware.httpunit.*;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
import org.apache.xerces.parsers.DOMParser;
-import org.w3c.dom.Document;
+
import org.w3c.dom.NodeList;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
+
/**
* This class acts as a test environment for servlets.
@@ -171,10 +164,10 @@
/** A mapping of resource names to servlet class names. **/
- Hashtable _servlets = new Hashtable();
+ private Hashtable _servlets = new Hashtable();
- ServletUnitClient _client = new ServletUnitClient( this );
- ServletUnitContext _context = new ServletUnitContext();
+ private ServletUnitClient _client = new ServletUnitClient( this );
+ private ServletUnitContext _context = new ServletUnitContext();
private String getServletName( String urlFile ) {
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServletUnitHttpRequest.java 2001/11/08 22:07:53 1.4
+++ ServletUnitHttpRequest.java 2001/11/12 19:48:35 1.5
@@ -19,21 +19,23 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.io.*;
+import com.meterware.httpunit.HttpUnitUtils;
+import com.meterware.httpunit.WebRequest;
+import java.io.BufferedReader;
+import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
-
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.StringTokenizer;
import java.util.Vector;
-
-import javax.servlet.*;
-import javax.servlet.http.*;
+import java.util.StringTokenizer;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.HttpUnitUtils;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpSession;
+import javax.servlet.ServletInputStream;
+import javax.servlet.RequestDispatcher;
/**
Index: ServletUnitHttpResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletUnitHttpResponse.java 2001/11/08 22:07:53 1.6
+++ ServletUnitHttpResponse.java 2001/11/12 19:48:35 1.7
@@ -1,4 +1,5 @@
package com.meterware.servletunit;
+
/********************************************************************************************************************
* $Id$
*
@@ -19,19 +20,22 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.io.*;
-import java.net.HttpURLConnection;
+import com.meterware.httpunit.HttpUnitUtils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Vector;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-import com.meterware.httpunit.HttpUnitUtils;
-import com.meterware.httpunit.WebRequest;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
class ServletUnitHttpResponse implements HttpServletResponse {
Index: ServletUnitHttpSession.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpSession.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServletUnitHttpSession.java 2000/11/21 22:18:19 1.2
+++ ServletUnitHttpSession.java 2001/11/12 19:48:35 1.3
@@ -19,22 +19,12 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.io.*;
-
-import java.net.HttpURLConnection;
-
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.*;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import com.meterware.httpunit.*;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
class ServletUnitHttpSession implements HttpSession {
@@ -216,7 +206,7 @@
private int _maxInactiveInterval;
- private long _creationTime = new Date().getTime();
+ private final long _creationTime = new Date().getTime();
private long _lastAccessedTime = new Date().getTime();
@@ -226,6 +216,6 @@
private boolean _isNew = true;
- private String _id = Integer.toString( _NextID++ );
+ private final String _id = Integer.toString( _NextID++ );
}
|
|
From: Russell G. <rus...@us...> - 2001-11-12 19:48:38
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv31024/src/com/meterware/httpunit
Modified Files:
WebClient.java WebForm.java WebRequest.java
Log Message:
General code cleanup
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WebClient.java 2001/11/08 22:07:52 1.10
+++ WebClient.java 2001/11/12 19:48:35 1.11
@@ -254,13 +254,14 @@
private void validateHeaders( WebResponse response ) throws HttpException, IOException {
if (response.getHeaderField( "WWW-Authenticate" ) != null) {
throw new AuthorizationRequiredException( response.getHeaderField( "WWW-Authenticate" ) );
- } else if (!HttpUnitOptions.getExceptionsThrownOnErrorStatus()) {
- } else if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
- throw new HttpInternalErrorException( response.getURL() );
- } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
- throw new HttpNotFoundException( response.getURL() );
- } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) {
- throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() );
+ } else if (HttpUnitOptions.getExceptionsThrownOnErrorStatus()) {
+ if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
+ throw new HttpInternalErrorException( response.getURL() );
+ } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new HttpNotFoundException( response.getURL() );
+ } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) {
+ throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() );
+ }
}
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WebForm.java 2001/11/08 22:07:52 1.30
+++ WebForm.java 2001/11/12 19:48:35 1.31
@@ -21,9 +21,14 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.*;
+import java.util.Hashtable;
+import java.util.Vector;
-import org.w3c.dom.*;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
/**
* This class represents a form in an HTML page. Users of this class may examine the parameters
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WebRequest.java 2001/11/09 18:35:14 1.28
+++ WebRequest.java 2001/11/12 19:48:35 1.29
@@ -19,13 +19,25 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.lang.reflect.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
import java.security.Provider;
import java.security.Security;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
/**
* A request sent to a web server.
|
|
From: Russell G. <rus...@us...> - 2001-11-12 19:47:08
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv30259/doc Modified Files: release_notes.txt Log Message: Address WebSphere Cookies Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- release_notes.txt 2001/11/09 18:35:14 1.65 +++ release_notes.txt 2001/11/12 19:47:05 1.66 @@ -10,6 +10,10 @@ Limitations: HttpUnit does not support JavaScript Revision History: +12-Nov-2001 +Problems fixed: + 1. WebSphere cookie values ending with "=" or "==" are now handled. + 9-Nov-2001 Acknowledgements: |
|
From: Russell G. <rus...@us...> - 2001-11-12 19:47:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv30259/test/com/meterware/httpunit
Modified Files:
PseudoServerTest.java
Log Message:
Address WebSphere Cookies
Index: PseudoServerTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PseudoServerTest.java 2001/07/31 16:08:59 1.16
+++ PseudoServerTest.java 2001/11/12 19:47:05 1.17
@@ -188,10 +188,11 @@
PseudoServer ps = new PseudoServer();
int port = ps.getConnectedPort();
ps.setResource( resourceName, resourceValue );
- ps.addResourceHeader( resourceName, "Set-Cookie: age=12, name=george" );
+ 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();
@@ -199,13 +200,14 @@
WebResponse response = wc.getResponse( request );
assertEquals( "requested resource", resourceValue, response.getText().trim() );
assertEquals( "content type", "text/html", response.getContentType() );
- assertEquals( "number of cookies", 6, wc.getCookieNames().length );
+ assertEquals( "number of cookies", 7, wc.getCookieNames().length );
assertEquals( "cookie 'age' value", "12", wc.getCookieValue( "age" ) );
assertEquals( "cookie 'name' value", "george", wc.getCookieValue( "name" ) );
assertEquals( "cookie 'type' value", "short", wc.getCookieValue( "type" ) );
assertEquals( "cookie 'funky' value", "ab$==", wc.getCookieValue( "funky" ) );
assertEquals( "cookie 'p30waco_sso' value", "3.0,en,us,AMERICA,Drew", wc.getCookieValue( "p30waco_sso" ) );
assertEquals( "cookie 'PORTAL30_SSO_TEST' value", "X", wc.getCookieValue( "PORTAL30_SSO_TEST" ) );
+ assertEquals( "cookie 'SESSION_ID' value", "17585,Dzm5LzbRPnb95QkUyIX+7w5RDT7p6OLuOVZ91AMl4hsDATyZ1ej+FA==", wc.getCookieValue( "SESSION_ID" ) );
} finally {
ps.shutDown();
}
|
|
From: Russell G. <rus...@us...> - 2001-11-12 19:47:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv30259/src/com/meterware/httpunit
Modified Files:
WebResponse.java
Log Message:
Address WebSphere Cookies
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- WebResponse.java 2001/11/08 22:07:52 1.52
+++ WebResponse.java 2001/11/12 19:47:05 1.53
@@ -20,7 +20,6 @@
*
*******************************************************************************************************************/
-import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -625,46 +624,32 @@
}
+ /**
+ *
+ */
private void processCookieHeader( String cookieHeader, int version ) {
if (cookieHeader == null) return;
- Vector tokens = getCookieTokens(cookieHeader);
- // holds tokens that should be part of the value of
- // the first token before it that contains an
- // equals sign (=)
+ Vector tokens = getCookieTokens( cookieHeader );
String tokensToAdd = "";
- int numTokens = tokens.size();
- for (int i=numTokens - 1; i >= 0; i--) {
- String token = (String) tokens.elementAt(i);
- int equalsIndex = token.indexOf('=');
+ for (int i = tokens.size() - 1; i >= 0; i--) {
+ String token = (String) tokens.elementAt( i );
- // if this token has an equals sign (=) in it
+ int equalsIndex = getEqualsIndex( token );
if (equalsIndex != -1) {
- String name = token.substring(0,equalsIndex).trim();
- // make sure we aren't using a cookie's attribute other
- // than the name/value pair
- if ( !isStringCookieAttribute(name,version) ) {
- String value = token.substring(equalsIndex+1).trim();
- _newCookies.put(name,value+tokensToAdd);
+ String name = token.substring( 0, equalsIndex ).trim();
+ if (!isCookieAttribute( name, version )) {
+ String value = token.substring( equalsIndex + 1 ).trim();
+ _newCookies.put( name, value + tokensToAdd );
}
tokensToAdd = "";
- }
-
- else {
- // make sure we aren't counting a one word reserved
- // cookie attribute value
- if ( !isTokenReservedWord(token,version) ) {
- tokensToAdd = token + tokensToAdd;
- String preceedingToken = (String) tokens.elementAt(i - 1);
- char lastChar = preceedingToken.charAt(preceedingToken.length()-1);
- if (lastChar != '=') {
- tokensToAdd = ","+ tokensToAdd;
- }
- }
- // the token is a secure or discard flag for the cookie
- else {
- // just to be safe we should clear the tokens
- // to append to the value of the cookie
- tokensToAdd = "";
+ } else if (isCookieReservedWord( token, version )) {
+ tokensToAdd = "";
+ } else {
+ tokensToAdd = token + tokensToAdd;
+ String preceedingToken = (String) tokens.elementAt( i - 1 );
+ char lastChar = preceedingToken.charAt( preceedingToken.length() - 1 );
+ if (lastChar != '=') {
+ tokensToAdd = "," + tokensToAdd;
}
}
}
@@ -672,6 +657,20 @@
/**
+ * Returns the index (if any) of the equals sign separating a cookie name from the its value.
+ * Equals signs at the end of the token are ignored in this calculation, since they may be
+ * part of a Base64-encoded value.
+ */
+ private int getEqualsIndex( String token ) {
+ if (!token.endsWith( "=" )) {
+ return token.indexOf( '=' );
+ } else {
+ return getEqualsIndex( token.substring( 0, token.length()-1 ) );
+ }
+ }
+
+
+ /**
* Tokenizes a cookie header and returns the tokens in a
* <code>Vector</code>.
**/
@@ -707,50 +706,40 @@
}
- private boolean isStringCookieAttribute(String string,
- int version) {
+ private boolean isCookieAttribute( String string,
+ int version ) {
String stringLowercase = string.toLowerCase();
if (version == IETF_RFC2109) {
- if ( stringLowercase.equals("path") ||
- stringLowercase.equals("domain") ||
- stringLowercase.equals("expires") ||
- stringLowercase.equals("comment") ||
- stringLowercase.equals("max-age") ||
- stringLowercase.equals("version") ) {
- return true;
- }
- }
- else if (version == IETF_RFC2965) {
- if ( stringLowercase.equals("path") ||
- stringLowercase.equals("domain") ||
- stringLowercase.equals("comment") ||
- stringLowercase.equals("commenturl") ||
- stringLowercase.equals("max-age") ||
- stringLowercase.equals("version") ||
- stringLowercase.equals("$version") ||
- stringLowercase.equals("port") ) {
- return true;
- }
+ return stringLowercase.equals("path") ||
+ stringLowercase.equals("domain") ||
+ stringLowercase.equals("expires") ||
+ stringLowercase.equals("comment") ||
+ stringLowercase.equals("max-age") ||
+ stringLowercase.equals("version");
+ } else if (version == IETF_RFC2965) {
+ return stringLowercase.equals("path") ||
+ stringLowercase.equals("domain") ||
+ stringLowercase.equals("comment") ||
+ stringLowercase.equals("commenturl") ||
+ stringLowercase.equals("max-age") ||
+ stringLowercase.equals("version") ||
+ stringLowercase.equals("$version") ||
+ stringLowercase.equals("port");
+ } else {
+ return false;
}
- return false;
}
- private boolean isTokenReservedWord(String token,
- int version) {
- String tokenLowercase = token.toLowerCase();
+ private boolean isCookieReservedWord( String token,
+ int version ) {
if (version == IETF_RFC2109) {
- if ( tokenLowercase.equals("secure") ) {
- return true;
- }
- }
- else if (version == IETF_RFC2965) {
- if ( tokenLowercase.equals("discard") ||
- tokenLowercase.equals("secure") ) {
- return true;
- }
+ return token.equalsIgnoreCase( "secure" );
+ } else if (version == IETF_RFC2965) {
+ return token.equalsIgnoreCase( "discard" ) || token.equalsIgnoreCase( "secure" );
+ } else {
+ return false;
}
- return false;
}
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv30213/src/com/meterware/httpunit
Modified Files:
AuthorizationRequiredException.java GetMethodWebRequest.java
HTMLSegment.java HttpException.java HttpUnitOptions.java
HttpWebResponse.java IllegalRequestParameterException.java
MimeEncodedMessageBody.java NodeUtils.java
PostMethodWebRequest.java ReceivedPage.java SubmitButton.java
TableCell.java WebFrame.java WebLink.java WebRequest.java
Log Message:
Coding style cleanup
Index: AuthorizationRequiredException.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/AuthorizationRequiredException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AuthorizationRequiredException.java 2001/04/02 19:54:29 1.3
+++ AuthorizationRequiredException.java 2001/11/09 18:35:14 1.4
@@ -30,13 +30,13 @@
AuthorizationRequiredException( String wwwAuthenticateHeader ) throws IOException {
- int i = wwwAuthenticateHeader.indexOf( ' ' );
- if (i < 0) { // non-conforming header
+ final int index = wwwAuthenticateHeader.indexOf( ' ' );
+ if (index < 0) { // non-conforming header
_scheme = "Basic";
_params = wwwAuthenticateHeader;
} else {
- _scheme = wwwAuthenticateHeader.substring( 0, i );
- _params = wwwAuthenticateHeader.substring( i+1 );
+ _scheme = wwwAuthenticateHeader.substring( 0, index );
+ _params = wwwAuthenticateHeader.substring( index+1 );
}
_properties = new Properties();
_properties.load( new ByteArrayInputStream( _params.getBytes() ) );
Index: GetMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- GetMethodWebRequest.java 2001/04/18 03:16:07 1.8
+++ GetMethodWebRequest.java 2001/11/09 18:35:14 1.9
@@ -19,7 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.MalformedURLException;
import java.net.URL;
/**
Index: HTMLSegment.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLSegment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTMLSegment.java 2001/04/18 03:18:35 1.2
+++ HTMLSegment.java 2001/11/09 18:35:14 1.3
@@ -19,8 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+
/**
* Represents the parse tree for a segment of HTML.
* @author Russell Gold
Index: HttpException.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HttpException.java 2001/11/08 22:07:52 1.3
+++ HttpException.java 2001/11/09 18:35:14 1.4
@@ -19,8 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.util.Properties;
-import java.io.*;
import java.net.URL;
@@ -75,6 +73,5 @@
private URL _url;
private String _responseMessage;
-
}
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- HttpUnitOptions.java 2001/10/15 18:25:59 1.11
+++ HttpUnitOptions.java 2001/11/09 18:35:14 1.12
@@ -261,9 +261,9 @@
//--------------------------------- private members --------------------------------------
- private static String DEFAULT_CONTENT_TYPE = "text/plain";
- private static String DEFAULT_CONTENT_HEADER = DEFAULT_CONTENT_TYPE;
- private static String DEFAULT_CHARACTER_SET = "iso-8859-1";
+ private static final String DEFAULT_CONTENT_TYPE = "text/plain";
+ private static final String DEFAULT_CONTENT_HEADER = DEFAULT_CONTENT_TYPE;
+ private static final String DEFAULT_CHARACTER_SET = "iso-8859-1";
private static boolean _parserWarningsEnabled;
Index: HttpWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HttpWebResponse.java 2001/11/08 22:07:52 1.15
+++ HttpWebResponse.java 2001/11/09 18:35:14 1.16
@@ -102,8 +102,8 @@
//------------------------------------- private members -------------------------------------
- final private static String END_OF_LINE = System.getProperty( "line.separator" );
- final private static String FILE_ENCODING = System.getProperty( "file.encoding" );
+ private final static String END_OF_LINE = System.getProperty( "line.separator" );
+ private final static String FILE_ENCODING = System.getProperty( "file.encoding" );
private int _responseCode = HttpURLConnection.HTTP_OK;
Index: IllegalRequestParameterException.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/IllegalRequestParameterException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IllegalRequestParameterException.java 2000/09/15 16:38:44 1.1
+++ IllegalRequestParameterException.java 2001/11/09 18:35:14 1.2
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* 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
@@ -19,9 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.util.Properties;
-import java.io.*;
-
/**
* This exception is thrown on an attempt to set a form parameter in a way not possible from a browser.
Index: MimeEncodedMessageBody.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/MimeEncodedMessageBody.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MimeEncodedMessageBody.java 2001/07/31 16:08:59 1.8
+++ MimeEncodedMessageBody.java 2001/11/09 18:35:14 1.9
@@ -23,8 +23,6 @@
import java.io.OutputStream;
import java.io.InputStream;
-import java.net.URLConnection;
-
import java.util.Dictionary;
import java.util.Enumeration;
@@ -68,21 +66,21 @@
writeLn( outputStream, "Content-Disposition: form-data; name=\"" + name + '"' ); // XXX need to handle non-ascii names here
writeLn( outputStream, "Content-Type: text/plain; charset=" + getRequest().getCharacterSet() );
writeLn( outputStream, "" );
- writeLn( outputStream, values[i], getRequest().getCharacterSet() );
+ writeLn( outputStream, values[ i ], getRequest().getCharacterSet() );
}
}
Dictionary files = getPostRequest().getSelectedFiles();
+ byte[] buffer = new byte[ 8 * 1024 ];
for (Enumeration e = files.keys(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- WebRequest.UploadFileSpec spec = (WebRequest.UploadFileSpec) files.get( name );
+ String name = (String) e.nextElement();
+ WebRequest.UploadFileSpec spec = (WebRequest.UploadFileSpec) files.get( name );
writeLn( outputStream, "--" + BOUNDARY );
writeLn( outputStream, "Content-Disposition: form-data; name=\"" + encode( name ) + "\"; filename=\"" + encode( spec.getFileName() ) + '"' ); // XXX need to handle non-ascii names here
writeLn( outputStream, "Content-Type: " + spec.getContentType() );
writeLn( outputStream, "" );
InputStream in = spec.getInputStream();
- byte[] buffer = new byte[8 * 1024];
int count = 0;
do {
outputStream.write( buffer, 0, count );
@@ -91,7 +89,7 @@
in.close();
writeLn( outputStream, "" );
- }
+ }
writeLn( outputStream, "--" + BOUNDARY + "--" );
}
Index: NodeUtils.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NodeUtils.java 2001/07/31 16:08:59 1.6
+++ NodeUtils.java 2001/11/09 18:35:14 1.7
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* 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
@@ -19,10 +19,14 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
import java.util.Stack;
-import java.util.Vector;
-import org.w3c.dom.*;
/**
* Some common utilities for manipulating DOM nodes.
Index: PostMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PostMethodWebRequest.java 2001/10/19 18:26:29 1.17
+++ PostMethodWebRequest.java 2001/11/09 18:35:14 1.18
@@ -24,11 +24,7 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
import java.net.URL;
-import java.net.URLConnection;
import java.util.Dictionary;
import java.util.Hashtable;
Index: ReceivedPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ReceivedPage.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ReceivedPage.java 2001/10/26 15:41:04 1.15
+++ ReceivedPage.java 2001/11/09 18:35:14 1.16
@@ -102,7 +102,7 @@
matches.addElement( NodeUtils.getNodeAttribute( nl.item(i), "content" ) );
}
}
- String result[] = new String[ matches.size() ];
+ String[] result = new String[ matches.size() ];
matches.copyInto( result );
return result;
}
Index: SubmitButton.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SubmitButton.java 2001/07/31 16:08:59 1.3
+++ SubmitButton.java 2001/11/09 18:35:14 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* 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
@@ -19,12 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
+import org.w3c.dom.Node;
-import java.util.*;
-
-import org.w3c.dom.*;
-
/**
* This class represents a suubmit button in an HTML form.
**/
@@ -97,10 +93,10 @@
//------------------------------------------ private members ----------------------------------
- Node _node;
- String _name;
- String _value;
- boolean _isImageButton;
+ private Node _node;
+ private String _name;
+ private String _value;
+ private boolean _isImageButton;
private SubmitButton() {
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TableCell.java 2001/04/02 01:53:21 1.6
+++ TableCell.java 2001/11/09 18:35:14 1.7
@@ -21,10 +21,8 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.Stack;
-import java.util.Vector;
-
-import org.w3c.dom.*;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
Index: WebFrame.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebFrame.java 2000/10/11 19:15:11 1.3
+++ WebFrame.java 2001/11/09 18:35:14 1.4
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* 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
@@ -21,12 +21,8 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.Stack;
-import java.util.Vector;
+import org.w3c.dom.Node;
-import org.w3c.dom.*;
-
-
/**
* A frame in a web page.
**/
@@ -66,10 +62,10 @@
//----------------------------------- private fields and methods -----------------------------------
- Node _element;
+ private Node _element;
- URL _baseURL;
+ private URL _baseURL;
- String _name;
+ private String _name;
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WebLink.java 2001/11/05 15:50:38 1.10
+++ WebLink.java 2001/11/09 18:35:14 1.11
@@ -21,12 +21,10 @@
*******************************************************************************************************************/
import java.net.URL;
-import java.util.Vector;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
@@ -34,7 +32,7 @@
* structure of the link (as a DOM), or create a {@tag WebRequest} to simulate clicking
* on the link.
*
- * @author Russell Gold
+ * @author <a href="mailto:rus...@ac...">Russell Gold</a>
* @author <a href="mailto:ben...@av...>Benoit Xhenseval</a>
**/
public class WebLink extends WebRequestSource {
@@ -54,8 +52,8 @@
* Strips a URL from its parameters
**/
private String getBareURL() {
- String url = getURLString();
- int questionMarkIndex = url.indexOf("?");
+ final String url = getURLString();
+ final int questionMarkIndex = url.indexOf("?");
if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) {
return url.substring(0, questionMarkIndex);
}
@@ -77,8 +75,8 @@
* Gets all parameters from a URL
**/
private String getParametersString() {
- String url = getURLString();
- int questionMarkIndex = url.indexOf("?");
+ final String url = getURLString();
+ final int questionMarkIndex = url.indexOf("?");
if (questionMarkIndex >= 1 && questionMarkIndex < url.length() - 1) {
return url.substring(questionMarkIndex + 1);
}
@@ -101,10 +99,11 @@
* add a pair key-value to the hashtable, creates an array of values if param already exists.
**/
private void stripOneParameter( Hashtable params, String param ) {
- int index = param.indexOf( "=" );
- String value = (index < 0 || index == param.length() - 1)
- ? ""
- : HttpUnitUtils.decode( param.substring( index + 1 ) );
+ final int index = param.indexOf( "=" );
+ String value = ((index < 0) ? null
+ : ((index == param.length() - 1)
+ ? ""
+ : HttpUnitUtils.decode( param.substring( index + 1 ) )));
String key = (index < 0) ? param : HttpUnitUtils.decode( param.substring( 0, index ) );
params.put( key, withNewValue( (String[]) params.get( key ), value ) );
}
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- WebRequest.java 2001/11/08 22:07:52 1.27
+++ WebRequest.java 2001/11/09 18:35:14 1.28
@@ -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
@@ -61,7 +61,7 @@
/**
- * Sets the file for a parameter upload in a web request.
+ * Sets the file for a parameter upload in a web request.
**/
public void selectFile( String parameterName, File file ) {
assertFileParameter( parameterName );
@@ -140,8 +140,8 @@
_parameters.remove( name );
}
+
-
/**
* Returns the final URL associated with this web request.
**/
@@ -189,8 +189,8 @@
protected WebRequest( String urlString ) {
this( (URL) null, urlString );
}
-
-
+
+
/**
* Constructs a web request using a base URL and a relative URL string.
**/
@@ -225,8 +225,8 @@
}
}
-
+
/**
* Constructs a web request using a base request and a relative URL string.
**/
@@ -272,7 +272,7 @@
return _sourceForm.getCharacterSet();
}
}
-
+
/**
* Performs any additional processing necessary to complete the request.
@@ -446,8 +446,8 @@
private void appendParameter( StringBuffer sb, String name, String value, boolean moreToCome ) {
- sb.append( encode( name ) ).append( '=' );
- sb.append( encode( value ) );
+ sb.append( encode( name ) );
+ if (value != null) sb.append( '=' ).append( encode( value ) );
if (moreToCome) sb.append( '&' );
}
@@ -587,14 +587,14 @@
}
- private static void registerSSLProtocolHandler() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ private static void registerSSLProtocolHandler() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
String list = System.getProperty( PROTOCOL_HANDLER_PKGS );
Method setMethod = System.class.getMethod( "setProperty", new Class[] { String.class, String.class } );
if (list == null || list.length() == 0) {
setMethod.invoke( null, new String[] { PROTOCOL_HANDLER_PKGS, SSL_PROTOCOL_HANDLER } );
} else if (list.indexOf( SSL_PROTOCOL_HANDLER ) < 0) {
setMethod.invoke( null, new String[] { PROTOCOL_HANDLER_PKGS, SSL_PROTOCOL_HANDLER + " | " + list } );
- }
+ }
}
|
|
From: Russell G. <rus...@us...> - 2001-11-09 18:35:17
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv30213/test/com/meterware/httpunit
Modified Files:
Base64Test.java FileUploadTest.java HttpRequestStream.java
HttpUnitSuite.java MessageBodyRequestTest.java
PseudoServer.java PseudoServlet.java WebLinkTest.java
WebResource.java
Log Message:
Coding style cleanup
Index: Base64Test.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/Base64Test.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Base64Test.java 2001/07/02 13:23:45 1.2
+++ Base64Test.java 2001/11/09 18:35:14 1.3
@@ -32,7 +32,7 @@
**/
public class Base64Test extends TestCase {
- public static void main(String args[]) {
+ public static void main( String[] args ) {
junit.textui.TestRunner.run( suite() );
}
Index: FileUploadTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FileUploadTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FileUploadTest.java 2001/10/19 18:26:29 1.8
+++ FileUploadTest.java 2001/11/09 18:35:14 1.9
@@ -19,18 +19,8 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.util.*;
-
import java.io.*;
-
-import org.w3c.dom.Document;
+import java.util.StringTokenizer;
import javax.activation.DataSource;
@@ -38,6 +28,8 @@
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
+import junit.framework.Test;
+import junit.framework.TestSuite;
/**
* A unit test of the file upload simulation capability.
Index: HttpRequestStream.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpRequestStream.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpRequestStream.java 2001/11/05 15:50:38 1.2
+++ HttpRequestStream.java 2001/11/09 18:35:14 1.3
@@ -19,11 +19,15 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
-import java.net.*;
-import java.io.*;
-import java.util.*;
+import java.util.StringTokenizer;
+import java.util.Hashtable;
class HttpRequestStream {
Index: HttpUnitSuite.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- HttpUnitSuite.java 2001/06/04 20:45:33 1.14
+++ HttpUnitSuite.java 2001/11/09 18:35:14 1.15
@@ -29,33 +29,33 @@
**/
public class HttpUnitSuite {
- public static void main(String args[]) {
+ public static void main( String[] args ) {
junit.textui.TestRunner.run( suite() );
}
public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest( WebPageTest.suite() );
- suite.addTest( WebLinkTest.suite() );
- suite.addTest( HtmlTablesTest.suite() );
- suite.addTest( WebFormTest.suite() );
- suite.addTest( WebFrameTest.suite() );
- suite.addTest( RequestTargetTest.suite() );
- suite.addTest( FormParametersTest.suite() );
- suite.addTest( FormSubmitTest.suite() );
- suite.addTest( Base64Test.suite() );
- suite.addTest( PseudoServerTest.suite() );
- suite.addTest( MessageBodyRequestTest.suite() );
- addOptionalTestCase( suite, "com.meterware.httpunit.XMLPageTest" );
- addOptionalTestCase( suite, "com.meterware.httpunit.FileUploadTest" );
- return suite;
+ TestSuite result = new TestSuite();
+ result.addTest( WebPageTest.suite() );
+ result.addTest( WebLinkTest.suite() );
+ result.addTest( HtmlTablesTest.suite() );
+ result.addTest( WebFormTest.suite() );
+ result.addTest( WebFrameTest.suite() );
+ result.addTest( RequestTargetTest.suite() );
+ result.addTest( FormParametersTest.suite() );
+ result.addTest( FormSubmitTest.suite() );
+ result.addTest( Base64Test.suite() );
+ result.addTest( PseudoServerTest.suite() );
+ result.addTest( MessageBodyRequestTest.suite() );
+ addOptionalTestCase( result, "com.meterware.httpunit.XMLPageTest" );
+ addOptionalTestCase( result, "com.meterware.httpunit.FileUploadTest" );
+ return result;
}
- private static void addOptionalTestCase( TestSuite suite, String testCaseName ) {
+ private static void addOptionalTestCase( TestSuite testSuite, String testCaseName ) {
try {
- suite.addTest( new TestSuite( Class.forName( testCaseName ) ) );
+ testSuite.addTest( new TestSuite( Class.forName( testCaseName ) ) );
} catch (ClassNotFoundException e) {
System.out.println( "Note: test suite " + testCaseName + " not found; skipping." );
}
Index: MessageBodyRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/MessageBodyRequestTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MessageBodyRequestTest.java 2001/06/11 21:21:09 1.2
+++ MessageBodyRequestTest.java 2001/11/09 18:35:14 1.3
@@ -19,24 +19,13 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
-import java.net.URL;
-
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-
-import java.util.*;
-
-import java.io.*;
-
-import org.w3c.dom.Document;
-
-import javax.activation.DataSource;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMultipart;
/**
Index: PseudoServer.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServer.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PseudoServer.java 2001/07/17 12:50:47 1.15
+++ PseudoServer.java 2001/11/09 18:35:14 1.16
@@ -19,11 +19,20 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
+import java.io.InterruptedIOException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
-import java.net.*;
-import java.io.*;
-import java.util.*;
+import java.net.HttpURLConnection;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
/**
* A basic simulated web-server for testing the HttpUnit library.
Index: PseudoServlet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServlet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PseudoServlet.java 2001/06/11 21:21:09 1.5
+++ PseudoServlet.java 2001/11/09 18:35:14 1.6
@@ -19,8 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.util.Dictionary;
-
import java.io.Reader;
/**
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebLinkTest.java 2001/11/05 18:54:51 1.15
+++ WebLinkTest.java 2001/11/09 18:35:14 1.16
@@ -301,7 +301,7 @@
WebLink link = mapPage.getLinks()[0];
WebRequest wr = link.getRequest();
assertMatchingSet( "Request parameter names", new String[] { "arg1", "valueless" }, toStringArray( wr.getParameterNames() ) );
- assertEquals( "Value of arg1", "", wr.getParameter( "arg1" ) );
+ assertEquals( "Value of arg1", null, wr.getParameter( "arg1" ) );
}
Index: WebResource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebResource.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebResource.java 2001/07/17 12:50:47 1.5
+++ WebResource.java 2001/11/09 18:35:14 1.6
@@ -19,11 +19,9 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.util.Vector;
/**
|
|
From: Russell G. <rus...@us...> - 2001-11-09 18:35:17
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv30213/doc
Modified Files:
release_notes.txt
Log Message:
Coding style cleanup
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- release_notes.txt 2001/11/08 22:07:52 1.64
+++ release_notes.txt 2001/11/09 18:35:14 1.65
@@ -10,10 +10,18 @@
Limitations: HttpUnit does not support JavaScript
Revision History:
+ 9-Nov-2001
+
Acknowledgements:
- Thanks to Bradley Smith for implementing getParameterNames in ServletUnit.
+ Thanks to Dave Glowacki for finding and fixing another problem with parsing of link parameter names without values.
+
+Problems Fixed:
+ 1. Links with parameters with no "=" were being treated as though they had "="
8-Nov-2001
+Acknowledgements:
+ Thanks to Bradley Smith for implementing getParameterNames in ServletUnit.
+
Problems fixed:
1. ServletUnit was not decoding its request parameters
2. ServletUnit's HttpRequest.getParameterNames method was not implemented
@@ -23,7 +31,7 @@
2. Disabled submit buttons may no longer be selected from a form
3. When enabled, parameter validation now prevents changes to readonly controls.
4. It is now possible to obtain the reason message associated with the status code, either from
- HttpException.getResponseMessage() or if exceptions are disabled, from WebResponse.getResponseMessage()
+ HttpException.getResponseMessageweb() or if exceptions are disabled, from WebResponse.getResponseMessage()
5-Nov-2001
|
|
From: Russell G. <rus...@us...> - 2001-11-08 22:07:55
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv5733/test/com/meterware/httpunit
Modified Files:
FormParametersTest.java
Log Message:
Added support for web.xml, response messages, and readonly controls
Index: FormParametersTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FormParametersTest.java 2001/10/19 19:16:57 1.6
+++ FormParametersTest.java 2001/11/08 22:07:53 1.7
@@ -54,7 +54,7 @@
}
- public void testDisabledChoiceParameterValidation() throws Exception {
+ public void testChoiceParameterValidationBypass() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Select name=colors><Option>blue<Option>red</Select>" +
"<Select name=fish><Option value=red>snapper<Option value=pink>salmon</select>" +
@@ -72,7 +72,7 @@
}
- public void testEnabledChoiceParameterValidation() throws Exception {
+ public void testChoiceParameterValidation() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Select name=colors><Option>blue<Option>red</Select>" +
"<Select name=fish><Option value=red>snapper<Option value=pink>salmon</select>" +
@@ -97,7 +97,7 @@
}
- public void testDisabledTextParameterValidation() throws Exception {
+ public void testTextParameterValidationBypass() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=color>" +
"<Input type=password name=password>" +
@@ -115,7 +115,7 @@
}
- public void testEnabledTextParameterValidation() throws Exception {
+ public void testTextParameterValidation() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=color>" +
"<Input type=password name=password>" +
@@ -153,7 +153,7 @@
}
- public void testDisabledRadioButtonValidation() throws Exception {
+ public void testRadioButtonValidationBypass() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=radio name=color value=red>" +
"<Input type=radio name=color value=blue>" +
@@ -167,7 +167,7 @@
}
- public void testEnabledRadioButtonValidation() throws Exception {
+ public void testRadioButtonValidation() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=radio name=color value=red>" +
"<Input type=radio name=color value=blue>" +
@@ -204,6 +204,42 @@
request.setParameter( "color", new String[] { "red", "blue" } );
validateSetParameterRejected( request, "color", "on", "setting checkbox to an incorrect value" );
validateSetParameterRejected( request, "color", new String[] { "green", "red" }, "setting checkbox to an incorrect value" );
+ }
+
+
+ public void testReadOnlyControls() throws Exception {
+ defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
+ "<Input readonly type=checkbox name=color value=red checked>" +
+ "<Input type=checkbox name=color value=blue>" +
+ "<Input type=radio name=species value=hippo readonly>" +
+ "<Input type=radio name=species value=kangaroo checked>" +
+ "<Input type=radio name=species value=lemur>" +
+ "<textarea name='big' readonly rows=2 cols=40>stop me</textarea>" +
+ "<Input type=text name=age value=12 readonly value='12'>" +
+ "<Input type=submit name=change disabled></form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getForms()[0];
+ WebRequest request = page.getForms()[0].getRequest();
+
+ assertMatchingSet( "selected color", new String[] { "red" }, form.getParameterValues( "color" ) );
+ assertEquals( "selected animal", "kangaroo", form.getParameterValue( "species" ) );
+ assertEquals( "age", "12", form.getParameterValue( "age" ) );
+
+ assertNull( "Found disabled button", form.getSubmitButton( "change" ) );
+ assertMatchingSet( "color choices", new String[] { "red", "blue" }, form.getOptionValues( "color" ) );
+ assertMatchingSet( "species choices", new String[] { "kangaroo", "lemur" }, form.getOptionValues( "species" ) );
+
+ validateSetParameterRejected( request, "color", "blue", "unchecking 'red'" );
+ validateSetParameterRejected( request, "color", new String[] { "blue" }, "unchecking 'red'" );
+ validateSetParameterRejected( request, "species", "hippo", "selecting 'hippo'" );
+ validateSetParameterRejected( request, "age", "15", "changing a disabled text parameter value" );
+ validateSetParameterRejected( request, "big", "go-go", "changing a disabled textarea parameter value" );
+
+ request.setParameter( "color", "red" );
+ request.setParameter( "color", new String[] { "red", "blue" } );
+ request.setParameter( "species", "lemur" );
+ request.setParameter( "age", "12" );
+ request.setParameter( "big", "stop me" );
}
|
|
From: Russell G. <rus...@us...> - 2001-11-08 22:07:55
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv5733/test/com/meterware/servletunit
Modified Files:
ServletUnitSuite.java StatelessTest.java
Added Files:
WebXMLTest.java
Log Message:
Added support for web.xml, response messages, and readonly controls
--- NEW FILE ---
//-----------------------------------------------------------------------------
// Copyright (c) 2001 by Hewlett-Packard Company. All rights reserved.
//-----------------------------------------------------------------------------
package com.meterware.servletunit;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.ByteArrayInputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import junit.framework.TestSuite;
import junit.framework.TestCase;
public class WebXMLTest extends TestCase {
public static void main(String args[]) {
junit.textui.TestRunner.run( suite() );
}
public static TestSuite suite() {
return new TestSuite( WebXMLTest.class );
}
public WebXMLTest( String name ) {
super( name );
}
public void testBasicAccess() throws Exception {
String config = "<?xml version='1.0' encoding='ISO-8859-1'?>" +
"<web-app>" +
" <servlet><servlet-name>Simple</servlet-name>" +
" <servlet-class>" + SimpleGetServlet.class.getName() + "</servlet-class></servlet>" +
" <servlet-mapping><servlet-name>Simple</servlet-name>" +
" <url-pattern>/SimpleServlet</url-pattern></servlet-mapping>" +
"</web-app>";
ServletRunner sr = new ServletRunner( new ByteArrayInputStream( config.getBytes() ) );
WebRequest request = new GetMethodWebRequest( "http://localhost/SimpleServlet" );
WebResponse response = sr.getResponse( request );
assertNotNull( "No response received", response );
assertEquals( "content type", "text/html", response.getContentType() );
assertEquals( "requested resource", SimpleGetServlet.RESPONSE_TEXT, response.getText() );
}
private final static String DOCTYPE = "<!DOCTYPE web-app PUBLIC " +
" \"-//Sun Microsystems, Inc.//DTD WebApplication 2.2//EN\" " +
" \"http://java.sun/com/j2ee/dtds/web-app_2_2.dtd\">";
//===============================================================================================================
static class SimpleGetServlet extends HttpServlet {
static String RESPONSE_TEXT = "the desired content\r\n";
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
resp.setContentType( "text/html" );
PrintWriter pw = resp.getWriter();
pw.print( RESPONSE_TEXT );
pw.close();
}
}
}
Index: ServletUnitSuite.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ServletUnitSuite.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServletUnitSuite.java 2000/12/13 21:56:03 1.2
+++ ServletUnitSuite.java 2001/11/08 22:07:53 1.3
@@ -43,6 +43,7 @@
suite.addTest( SessionTest.suite() );
suite.addTest( NavigationTest.suite() );
suite.addTest( ConfigTest.suite() );
+ suite.addTest( WebXMLTest.suite() );
return suite;
}
Index: StatelessTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/StatelessTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StatelessTest.java 2001/06/18 20:21:30 1.2
+++ StatelessTest.java 2001/11/08 22:07:53 1.3
@@ -99,11 +99,11 @@
ServletRunner sr = new ServletRunner();
sr.registerServlet( resourceName, ParameterServlet.class.getName() );
- WebRequest request = new GetMethodWebRequest( "http://localhost/" + resourceName + "?color=red" );
+ WebRequest request = new GetMethodWebRequest( "http://localhost/" + resourceName + "?color=dark+red" );
WebResponse response = sr.getResponse( request );
assertNotNull( "No response received", response );
assertEquals( "content type", "text/plain", response.getContentType() );
- assertEquals( "requested resource", "You selected red", response.getText() );
+ assertEquals( "requested resource", "You selected dark red", response.getText() );
}
public void testSimplePost() throws Exception {
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv5733/src/com/meterware/servletunit
Modified Files:
ServletRunner.java ServletUnitClient.java
ServletUnitHttpRequest.java ServletUnitHttpResponse.java
ServletUnitWebResponse.java
Log Message:
Added support for web.xml, response messages, and readonly controls
Index: ServletRunner.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServletRunner.java 2001/06/18 20:21:30 1.5
+++ ServletRunner.java 2001/11/08 22:07:53 1.6
@@ -21,6 +21,8 @@
*******************************************************************************************************************/
import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -28,6 +30,7 @@
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.Dictionary;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
@@ -40,6 +43,12 @@
import com.meterware.httpunit.*;
import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
+import org.apache.xerces.parsers.DOMParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
@@ -47,6 +56,63 @@
**/
public class ServletRunner {
+ /**
+ * Default constructor, which defines no servlets.
+ */
+ public ServletRunner() {}
+
+
+ /**
+ * Constructor which expects the full path to the web.xml for the application.
+ **/
+ public ServletRunner( String webXMLFileSpec ) throws IOException, SAXException {
+ DOMParser parser = new DOMParser();
+ parser.parse( webXMLFileSpec );
+
+ registerServlets( parser.getDocument() );
+ }
+
+
+ /**
+ * Constructor which expects an input stream containing the web.xml for the application.
+ **/
+ public ServletRunner( InputStream webXML ) throws IOException, SAXException {
+ DOMParser parser = new DOMParser();
+ parser.parse( new InputSource( webXML ) );
+
+ registerServlets( parser.getDocument() );
+ }
+
+
+ private void registerServlets( Document document ) throws SAXException {
+ Hashtable nameToClass = new Hashtable();
+ NodeList nl = document.getElementsByTagName( "servlet" );
+ for (int i = 0; i < nl.getLength(); i++) registerServletClass( nameToClass, (Element) nl.item(i) );
+ nl = document.getElementsByTagName( "servlet-mapping" );
+ for (int i = 0; i < nl.getLength(); i++) registerServlet( nameToClass, (Element) nl.item(i) );
+ }
+
+
+ private void registerServletClass( Dictionary mapping, Element servletElement ) throws SAXException {
+ mapping.put( getChildNodeValue( servletElement, "servlet-name" ),
+ getChildNodeValue( servletElement, "servlet-class" ) );
+ }
+
+
+ private void registerServlet( Dictionary mapping, Element servletElement ) throws SAXException {
+ registerServlet( getChildNodeValue( servletElement, "url-pattern" ),
+ (String) mapping.get( getChildNodeValue( servletElement, "servlet-name" ) ) );
+ }
+
+
+ private String getChildNodeValue( Element root, String childNodeName ) throws SAXException {
+ NodeList nl = root.getElementsByTagName( childNodeName );
+ if (nl.getLength() != 1) throw new SAXException( "Node <" + root.getNodeName() + "> has no child named <" + childNodeName + ">" );
+ Node childNode = nl.item(0).getFirstChild();
+ if (childNode == null) throw new SAXException( "No value specified for <" + childNodeName + "> node" );
+ if (childNode.getNodeType() != Node.TEXT_NODE) throw new SAXException( "No text value found for <" + childNodeName + "> node" );
+ return childNode.getNodeValue();
+ }
/**
* Registers a servlet class to be run.
@@ -78,20 +144,20 @@
Servlet getServlet( URL url ) {
String className = (String) _servlets.get( getServletName( url.getFile() ) );
- if (className == null) throw new HttpNotFoundException( url.toExternalForm() );
+ if (className == null) throw new HttpNotFoundException( url );
try {
Class servletClass = Class.forName( className );
if (!Servlet.class.isAssignableFrom( servletClass )) {
- throw new HttpInternalErrorException( url.toExternalForm() );
+ throw new HttpInternalErrorException( url );
}
return (Servlet) servletClass.newInstance();
} catch (ClassNotFoundException e) {
- throw new HttpNotFoundException( url.toExternalForm() );
+ throw new HttpNotFoundException( url, e );
} catch (IllegalAccessException e) {
- throw new HttpInternalErrorException( url.toExternalForm() );
+ throw new HttpInternalErrorException( url, e );
} catch (InstantiationException e) {
- throw new HttpInternalErrorException( url.toExternalForm() );
+ throw new HttpInternalErrorException( url, e );
}
}
Index: ServletUnitClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServletUnitClient.java 2001/06/06 13:25:04 1.1
+++ ServletUnitClient.java 2001/11/08 22:07:53 1.2
@@ -24,6 +24,7 @@
import com.meterware.httpunit.WebClient;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
+import com.meterware.httpunit.GetMethodWebRequest;
import java.io.IOException;
@@ -52,6 +53,14 @@
/**
+ * Creates and returns a new invocation context from a GET request.
+ **/
+ public InvocationContext newInvocation( String requestString ) throws MalformedURLException {
+ return newInvocation( new GetMethodWebRequest( requestString ) );
+ }
+
+
+ /**
* Creates and returns a new invocation context to test calling of servlet methods.
**/
public InvocationContext newInvocation( WebRequest request ) throws MalformedURLException {
@@ -90,7 +99,7 @@
try {
invocation.getServlet().service( invocation.getRequest(), invocation.getResponse() );
} catch (ServletException e) {
- throw new HttpInternalErrorException( request.getURL().toExternalForm() );
+ throw new HttpInternalErrorException( request.getURL(), e );
}
return invocation.getServletResponse();
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServletUnitHttpRequest.java 2001/10/25 19:23:17 1.3
+++ ServletUnitHttpRequest.java 2001/11/08 22:07:53 1.4
@@ -33,6 +33,7 @@
import javax.servlet.http.*;
import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.HttpUnitUtils;
/**
@@ -338,8 +339,7 @@
* been read.
**/
public Enumeration getParameterNames() {
- throwNotImplementedYet();
- return null;
+ return _parameters.keys();
}
@@ -647,15 +647,10 @@
private void addParameter( String name, String encodedValue ) {
String[] values = (String[]) _parameters.get( name );
if (values == null) {
- _parameters.put( name, new String[] { decode( encodedValue ) } );
+ _parameters.put( name, new String[] { HttpUnitUtils.decode( encodedValue ) } );
} else {
- _parameters.put( name, extendedArray( values, decode( encodedValue ) ) );
+ _parameters.put( name, extendedArray( values, HttpUnitUtils.decode( encodedValue ) ) );
}
- }
-
-
- private String decode( String encodedValue ) {
- return encodedValue; // FIXME
}
Index: ServletUnitHttpResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServletUnitHttpResponse.java 2001/07/19 17:43:50 1.5
+++ ServletUnitHttpResponse.java 2001/11/08 22:07:53 1.6
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000, Russell Gold
+* 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
@@ -120,7 +120,7 @@
* (<body></body>).
**/
public void sendError( int sc ) throws IOException {
- throw new RuntimeException( "sendError not implemented" );
+ sendError( sc, "" );
}
@@ -134,7 +134,14 @@
* (<body></body>).
**/
public void sendError(int sc, String msg) throws IOException {
- throw new RuntimeException( "sendError not implemented" );
+ setStatus( sc );
+ _statusMessage = msg;
+
+ _writer = null;
+ _servletStream = null;
+
+ setContentType( "text/html" );
+ getWriter().println( "<html><head><title>" + msg + "</title></head><body>" + msg + "</body></html>" );
}
@@ -145,8 +152,8 @@
* is an error, the <code>sendError</code> method should be used
* instead.
**/
- public void setStatus(int sc) {
- throw new RuntimeException( "setStatus not implemented" );
+ public void setStatus( int sc ) {
+ _status = sc;
}
@@ -156,7 +163,7 @@
* use sendError(int, String). Sets the status code and message for this response.
**/
public void setStatus( int sc, String msg ) {
- throw new RuntimeException( "setStatus not implemented" );
+ setStatus( sc );
}
@@ -411,6 +418,14 @@
}
+ /**
+ * Returns the message associated with this response's status.
+ **/
+ String getMessage() {
+ return _statusMessage;
+ }
+
+
public String[] getHeaderFieldNames() {
if (!_headersComplete) completeHeaders();
Vector names = new Vector();
@@ -446,6 +461,8 @@
private ByteArrayOutputStream _outputStream;
private int _status = SC_OK;
+
+ private String _statusMessage = "OK";
private Hashtable _headers = new Hashtable();
Index: ServletUnitWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitWebResponse.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletUnitWebResponse.java 2001/07/19 17:43:50 1.6
+++ ServletUnitWebResponse.java 2001/11/08 22:07:53 1.7
@@ -67,6 +67,14 @@
}
+ /**
+ * Returns the response message associated with this response.
+ **/
+ public String getResponseMessage() {
+ return _response.getMessage();
+ }
+
+
public String[] getHeaderFieldNames() {
return _response.getHeaderFieldNames();
}
|
|
From: Russell G. <rus...@us...> - 2001-11-08 22:07:55
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv5733/src/com/meterware/httpunit Modified Files: HttpException.java HttpInternalErrorException.java HttpNotFoundException.java HttpUnitUtils.java HttpWebResponse.java WebClient.java WebForm.java WebRequest.java WebResponse.java Log Message: Added support for web.xml, response messages, and readonly controls Index: HttpException.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HttpException.java 2000/11/21 20:44:58 1.2 +++ HttpException.java 2001/11/08 22:07:52 1.3 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000, Russell Gold +* 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 @@ -21,6 +21,7 @@ *******************************************************************************************************************/ import java.util.Properties; import java.io.*; +import java.net.URL; /** @@ -36,19 +37,25 @@ } - HttpException( int responseCode, String reason ) { - _reason = reason; + HttpException( int responseCode, String responseMessage, URL baseURL ) { + _responseMessage = responseMessage; _responseCode = responseCode; + _url = baseURL; } public String getMessage() { StringBuffer sb = new StringBuffer( "Error on HTTP request: " ); sb.append( _responseCode ); - if (_reason != null) { + if (_responseMessage != null) { + sb.append( " " ); + sb.append( _responseMessage ); + sb.append( "" ); + } + if (_url != null) { sb.append( " [" ); - sb.append( _reason ); - sb.append( " ]" ); + sb.append( _url.toExternalForm() ); + sb.append( "]" ); } return sb.toString(); } @@ -59,9 +66,15 @@ } + public String getResponseMessage() { + return _responseMessage; + } + + private int _responseCode; + private URL _url; - private String _reason; + private String _responseMessage; } Index: HttpInternalErrorException.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpInternalErrorException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HttpInternalErrorException.java 2000/11/21 20:44:58 1.3 +++ HttpInternalErrorException.java 2001/11/08 22:07:52 1.4 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000, Russell Gold +* 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 @@ -20,18 +20,24 @@ * *******************************************************************************************************************/ import java.net.HttpURLConnection; +import java.net.URL; /** * This exception is thrown when an internal error is found on the server. * @author Seth Ladd + * @author Russell Gold **/ public class HttpInternalErrorException extends HttpException { - public HttpInternalErrorException( String url ) { - super( HttpURLConnection.HTTP_INTERNAL_ERROR, url ); + public HttpInternalErrorException( URL url ) { + super( HttpURLConnection.HTTP_INTERNAL_ERROR, "Internal Error", url ); } + + public HttpInternalErrorException( URL url, Throwable t ) { + super( HttpURLConnection.HTTP_INTERNAL_ERROR, t.toString(), url ); + } } Index: HttpNotFoundException.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpNotFoundException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HttpNotFoundException.java 2000/11/21 20:44:58 1.3 +++ HttpNotFoundException.java 2001/11/08 22:07:52 1.4 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000, Russell Gold +* 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 @@ -20,6 +20,7 @@ * *******************************************************************************************************************/ import java.net.HttpURLConnection; +import java.net.URL; /** @@ -30,8 +31,12 @@ public class HttpNotFoundException extends HttpException { - public HttpNotFoundException( String url ) { - super( HttpURLConnection.HTTP_NOT_FOUND, url ); + public HttpNotFoundException( URL url ) { + super( HttpURLConnection.HTTP_NOT_FOUND, "Not found", url ); + } + + public HttpNotFoundException( URL url, Throwable t ) { + super( HttpURLConnection.HTTP_NOT_FOUND, t.toString(), url ); } Index: HttpUnitUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HttpUnitUtils.java 2001/11/05 15:50:38 1.2 +++ HttpUnitUtils.java 2001/11/08 22:07:52 1.3 @@ -48,7 +48,7 @@ * Returns an interpretation of the specified URL-encoded string. * FIXME: currently assumes iso-8859-1 character set. **/ - static String decode( String byteString ) { + public static String decode( String byteString ) { StringBuffer sb = new StringBuffer(); char[] chars = byteString.toCharArray(); char[] hexNum = { '0', '0', '0' }; Index: HttpWebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- HttpWebResponse.java 2001/07/19 17:43:50 1.14 +++ HttpWebResponse.java 2001/11/08 22:07:52 1.15 @@ -67,6 +67,14 @@ } + /** + * Returns the response message associated with this response. + **/ + public String getResponseMessage() { + return _responseMessage; + } + + public String[] getHeaderFieldNames() { Vector names = new Vector(); for (Enumeration e = _headers.keys(); e.hasMoreElements();) { @@ -98,22 +106,26 @@ final private static String FILE_ENCODING = System.getProperty( "file.encoding" ); - private int _responseCode = HttpURLConnection.HTTP_OK; + private int _responseCode = HttpURLConnection.HTTP_OK; + private String _responseMessage = "OK"; private Hashtable _headers = new Hashtable(); - private int getResponseCode( URLConnection connection, String statusHeader ) { - if (statusHeader == null) throw new HttpNotFoundException( connection.getURL().toExternalForm() ); + private void readResponseHeader( URLConnection connection ) { + if (connection.getHeaderField(0) == null) throw new HttpNotFoundException( connection.getURL() ); - StringTokenizer st = new StringTokenizer( statusHeader ); + StringTokenizer st = new StringTokenizer( connection.getHeaderField(0) ); st.nextToken(); if (!st.hasMoreTokens()) { - return HttpURLConnection.HTTP_OK; + _responseCode = HttpURLConnection.HTTP_OK; + _responseMessage = "OK"; } else try { - return Integer.parseInt( st.nextToken() ); + _responseCode = Integer.parseInt( st.nextToken() ); + _responseMessage = st.hasMoreTokens() ? st.nextToken() : ""; } catch (NumberFormatException e) { - return HttpURLConnection.HTTP_INTERNAL_ERROR; + _responseCode = HttpURLConnection.HTTP_INTERNAL_ERROR; + _responseMessage = "Cannot parse response header"; } } @@ -121,9 +133,10 @@ private void readHeaders( URLConnection connection ) { loadHeaders( connection ); if (connection instanceof HttpURLConnection) { - _responseCode = getResponseCode( connection, connection.getHeaderField(0) ); + readResponseHeader( connection ); } else { _responseCode = HttpURLConnection.HTTP_OK; + _responseMessage = "OK"; if (connection.getContentType().startsWith( "text" )) { setContentTypeHeader( connection.getContentType() + "; charset=" + FILE_ENCODING ); } Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WebClient.java 2001/08/06 20:19:41 1.9 +++ WebClient.java 2001/11/08 22:07:52 1.10 @@ -256,11 +256,11 @@ throw new AuthorizationRequiredException( response.getHeaderField( "WWW-Authenticate" ) ); } else if (!HttpUnitOptions.getExceptionsThrownOnErrorStatus()) { } else if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { - throw new HttpInternalErrorException( response.getURL().toExternalForm() ); + throw new HttpInternalErrorException( response.getURL() ); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { - throw new HttpNotFoundException( response.getURL().toExternalForm() ); + throw new HttpNotFoundException( response.getURL() ); } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { - throw new HttpException( response.getResponseCode(), response.getURL().toExternalForm() ); + throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() ); } } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- WebForm.java 2001/11/05 18:54:51 1.29 +++ WebForm.java 2001/11/08 22:07:52 1.30 @@ -136,16 +136,16 @@ NodeList nl = ((Element) getNode()).getElementsByTagName( "input" ); for (int i = 0; i < nl.getLength(); i++) { - if (NodeUtils.getNodeAttribute( nl.item(i), "type" ).equalsIgnoreCase( "submit" ) - || NodeUtils.getNodeAttribute( nl.item(i), "type" ).equalsIgnoreCase( "image" )) { + if ((hasMatchingAttribute( nl.item(i), "type", "submit" ) || hasMatchingAttribute( nl.item(i), "type", "image" )) + && nl.item(i).getAttributes().getNamedItem( "disabled" ) == null) { _buttonVector.addElement( new SubmitButton( nl.item(i) ) ); } } nl = ((Element) getNode()).getElementsByTagName( "button" ); for (int i = 0; i < nl.getLength(); i++) { - if (NodeUtils.getNodeAttribute( nl.item(i), "type" ).equalsIgnoreCase( "submit" ) - || NodeUtils.getNodeAttribute( nl.item(i), "type" ).equalsIgnoreCase( "" )) { + if ((hasMatchingAttribute( nl.item(i), "type", "submit" ) || hasMatchingAttribute( nl.item(i), "type", "" )) + && nl.item(i).getAttributes().getNamedItem( "disabled" ) == null) { _buttonVector.addElement( new SubmitButton( nl.item(i) ) ); } } @@ -155,6 +155,11 @@ } + private boolean hasMatchingAttribute( Node node, String attributeName, String attributeValue ) { + return NodeUtils.getNodeAttribute( node, attributeName ).equalsIgnoreCase( attributeValue ); + } + + /** * Returns the submit button defined in this form with the specified name. * If more than one such button exists, will return the first found. @@ -400,6 +405,17 @@ } + /** + * Returns the values which *must* for the specified parameter name. + **/ + String[] getRequiredValues( String name ) { + Object result = getParameterRequiredValues().get( name ); + if (result instanceof String[]) return (String[]) result; + if (result instanceof String) return new String[] { (String) result }; + return new String[0]; + } + + //---------------------------------- private members -------------------------------- /** The type of a parameter which accepts any text. **/ @@ -496,6 +512,46 @@ return _defaults; } + private Hashtable _required; + + private Hashtable getParameterRequiredValues() { + if (_required == null) { + NamedNodeMap[] parameters = getParameters(); + Hashtable required = new Hashtable(); + for (int i = 0; i < parameters.length; i++) { + String name = getValue( parameters[i].getNamedItem( "name" ) ); + String value = getValue( parameters[i].getNamedItem( "value" ) ); + String type = getValue( parameters[i].getNamedItem( "type" ) ).toUpperCase(); + if (type == null || type.length() == 0) type = "TEXT"; + if (parameters[i].getNamedItem( "readonly" ) == null) continue; + + if (type.equals( "TEXT" ) || type.equals( "HIDDEN" ) || type.equals( "PASSWORD" )) { + required.put( name, value ); + } else if (type.equals( "RADIO" ) && parameters[i].getNamedItem( "checked" ) != null) { + required.put( name, value ); + } else if (type.equals( "CHECKBOX" ) && parameters[i].getNamedItem( "checked" ) != null) { + if (value.length() == 0) value = "on"; + String[] currentDefaults = (String[]) required.get( name ); + if (currentDefaults == null) { + required.put( name, new String[] { value } ); + } else { + required.put( name, withNewValue( currentDefaults, value ) ); + } + } + } + HTMLSelectElement[] selections = getSelections(); + for (int i = 0; i < selections.length; i++) { + if (selections[i].isDisabled()) required.put( selections[i].getName(), selections[i].getSelected() ); + } + HTMLTextAreaElement[] textAreas = getTextAreas(); + for (int i = 0; i < textAreas.length; i++) { + if (textAreas[i].isReadOnly()) required.put( textAreas[i].getName(), textAreas[i].getValue() ); + } + _required = required; + } + return _required; + } + private Hashtable getParameterOptions() { if (_options == null) { @@ -520,7 +576,9 @@ String type = getValue( parameters[i].getNamedItem( "type" ) ).toUpperCase(); if (type == null || type.length() == 0) type = "TEXT"; - if (type.equals( "RADIO" ) || type.equals( "CHECKBOX" )) { + if ((type.equals( "RADIO" ) || type.equals( "CHECKBOX" )) + && (parameters[i].getNamedItem( "readonly" ) == null + || parameters[i].getNamedItem( "checked" ) != null)) { if (value.length() == 0 && type.equals( "CHECKBOX" )) value = "on"; String[] radioOptions = (String[]) options.get( name ); if (radioOptions == null) { @@ -739,6 +797,11 @@ } + boolean isDisabled() { + return _node.getAttributes().getNamedItem( "disabled" ) != null; + } + + private String getOptionValue( Node optionNode ) { NamedNodeMap nnm = optionNode.getAttributes(); if (nnm.getNamedItem( "value" ) != null) { @@ -776,6 +839,10 @@ String getValue() { return NodeUtils.asText(_node.getChildNodes() ); + } + + boolean isReadOnly() { + return _node.getAttributes().getNamedItem( "readonly" ) != null; } } Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- WebRequest.java 2001/10/19 19:16:57 1.26 +++ WebRequest.java 2001/11/08 22:07:52 1.27 @@ -487,6 +487,12 @@ private void validateParameterValue( String name, String value ) { if (_sourceForm == null) return; + validateOneParameterValue( name, value ); + validateRequiredValues( name, new String[] { value } ); + } + + + private void validateOneParameterValue( String name, String value ) { if (_sourceForm.isTextParameter( name )) return; if (_sourceForm.isFileParameter( name )) throw new IllegalFileParameterException( name ); if (!inArray( name, _sourceForm.getParameterNames() )) throw new NoSuchParameterException( name ); @@ -503,8 +509,17 @@ throw new TextParameterCountException( name, _sourceForm.getNumTextParameters( name ) ); } } + + for (int i = 0; i < values.length; i++) validateOneParameterValue( name, values[i] ); + validateRequiredValues( name, values ); + } + - for (int i = 0; i < values.length; i++) validateParameterValue( name, values[i] ); + private void validateRequiredValues( String name, String[] values ) { + String[] required = _sourceForm.getRequiredValues( name ); + for (int i = 0; i < required.length; i++) { + if (!inArray( required[i], values )) throw new MissingParameterValueException( name, required[i], values ); + } } @@ -642,6 +657,41 @@ private String _parameterName; private String _badValue; private String[] _allowedValues; +} + + +//============================= exception class MissingParameterValueException ====================================== + + +/** + * This exception is thrown on an attempt to remove a required value from a form parameter. + **/ +class MissingParameterValueException extends IllegalRequestParameterException { + + + MissingParameterValueException( String parameterName, String missingValue, String[] proposed ) { + _parameterName = parameterName; + _missingValue = missingValue; + _proposedValues = proposed; + } + + + public String getMessage() { + StringBuffer sb = new StringBuffer(); + sb.append( "Parameter '" ).append( _parameterName ).append( "' must have the value '" ); + sb.append( _missingValue ).append( "'. Attempted to set it to: { " ); + for (int i = 0; i < _proposedValues.length; i++) { + if (i != 0) sb.append( ", " ); + sb.append( _proposedValues[i] ); + } + sb.append( " }" ); + return sb.toString(); + } + + + private String _parameterName; + private String _missingValue; + private String[] _proposedValues; } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- WebResponse.java 2001/11/05 18:54:51 1.51 +++ WebResponse.java 2001/11/08 22:07:52 1.52 @@ -160,6 +160,13 @@ /** + * Returns the response message associated with this response. + **/ + abstract + public String getResponseMessage(); + + + /** * Returns the content type of this response. **/ public String getContentType() { @@ -948,6 +955,14 @@ **/ public int getResponseCode() { return HttpURLConnection.HTTP_OK; + } + + + /** + * Returns the response message associated with this response. + **/ + public String getResponseMessage() { + return "OK"; } |
|
From: Russell G. <rus...@us...> - 2001-11-08 22:07:55
|
Update of /cvsroot/httpunit/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv5733
Modified Files:
build.xml
Log Message:
Added support for web.xml, response messages, and readonly controls
Index: build.xml
===================================================================
RCS file: /cvsroot/httpunit/httpunit/build.xml,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- build.xml 2001/11/05 18:54:51 1.32
+++ build.xml 2001/11/08 22:07:52 1.33
@@ -25,7 +25,8 @@
<property name="web.dir" value="web" />
<property name="packages" value="com.meterware.*" />
<property name="test.class" value="com.meterware.httpunit.HttpUnitSuite" />
-
+ <property name="servlet.test.class" value="com.meterware.servletunit.ServletUnitSuite" />
+
<!-- =================================================================== -->
<!-- Defines the classpath used for compilation and test. -->
<!-- =================================================================== -->
@@ -102,7 +103,21 @@
</target>
-<!-- =================================================================== -->
+<!-- =================================================================== -->
+<!-- Runs the test code -->
+<!-- =================================================================== -->
+<target name="servlettest" depends="testcompile">
+ <java classname="${servlet.test.class}" fork="yes" >
+ <classpath>
+ <path refid="base.classpath" />
+ <pathelement location="${build.classes}" />
+ <pathelement location="${test.classes}" />
+ </classpath>
+ </java>
+</target>
+
+
+<!-- =================================================================== -->
<!-- Creates the jar archive -->
<!-- =================================================================== -->
<target name="jar" depends="compile">
|
|
From: Russell G. <rus...@us...> - 2001-11-08 22:07:55
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv5733/doc Modified Files: release_notes.txt Log Message: Added support for web.xml, response messages, and readonly controls Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- release_notes.txt 2001/11/05 18:54:51 1.63 +++ release_notes.txt 2001/11/08 22:07:52 1.64 @@ -10,6 +10,20 @@ Limitations: HttpUnit does not support JavaScript Revision History: +Acknowledgements: + Thanks to Bradley Smith for implementing getParameterNames in ServletUnit. + + 8-Nov-2001 +Problems fixed: + 1. ServletUnit was not decoding its request parameters + 2. ServletUnit's HttpRequest.getParameterNames method was not implemented + +Additions: + 1. ServletUnit now handles web.xml partially, supporting mapping of single paths to a servlet class + 2. Disabled submit buttons may no longer be selected from a form + 3. When enabled, parameter validation now prevents changes to readonly controls. + 4. It is now possible to obtain the reason message associated with the status code, either from + HttpException.getResponseMessage() or if exceptions are disabled, from WebResponse.getResponseMessage() 5-Nov-2001 |
|
From: Russell G. <rus...@us...> - 2001-11-05 18:54:54
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv31303/test/com/meterware/servletunit
Modified Files:
ServletUnitTest.java SessionTest.java
Log Message:
Cleaned up JDK 1.1 issues, added some WebForm enhancements
Index: ServletUnitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ServletUnitTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServletUnitTest.java 2000/11/21 20:44:59 1.1
+++ ServletUnitTest.java 2001/11/05 18:54:51 1.2
@@ -41,6 +41,10 @@
super( name );
}
+ public static void assertTrue( String comment, boolean expression ) {
+ assert( comment, expression );
+ }
+
//------------------------------------ protected members ------------------------------------------
Index: SessionTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/SessionTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SessionTest.java 2001/11/05 15:50:38 1.2
+++ SessionTest.java 2001/11/05 18:54:51 1.3
@@ -33,7 +33,7 @@
/**
* Tests the HttpSession implementation.
**/
-public class SessionTest extends TestCase {
+public class SessionTest extends ServletUnitTest {
public static void main(String args[]) {
junit.textui.TestRunner.run( suite() );
@@ -79,6 +79,7 @@
assertTrue( "Session is still marked as new", !context.getSession( session.getId() ).isNew() );
}
+
}
|
|
From: Russell G. <rus...@us...> - 2001-11-05 18:54:54
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv31303/test/com/meterware/httpunit
Modified Files:
WebFormTest.java WebLinkTest.java
Log Message:
Cleaned up JDK 1.1 issues, added some WebForm enhancements
Index: WebFormTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFormTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WebFormTest.java 2001/10/26 14:00:10 1.13
+++ WebFormTest.java 2001/11/05 18:54:51 1.14
@@ -117,6 +117,8 @@
assertEquals( "First checkbox", "", form.getParameterValue( "first" ) );
assertEquals( "Second checkbox", "on", form.getParameterValue( "second" ) );
+ assertTrue( "Did not find parameter 'first'", form.hasParameterNamed( "first" ) );
+ assertTrue( "Did not find parameter with prefix 'sec'", form.hasParameterStartingWithPrefix( "sec" ) );
}
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- WebLinkTest.java 2001/11/05 15:50:38 1.14
+++ WebLinkTest.java 2001/11/05 18:54:51 1.15
@@ -28,7 +28,6 @@
import java.util.Vector;
import java.util.Enumeration;
-import java.util.ArrayList;
/**
@@ -224,10 +223,10 @@
request = links[1].getRequest();
assertNotNull( request );
e = request.getParameterNames();
- assertTrue( e.hasMoreElements() );
+ assertTrue( "No parameter found", e.hasMoreElements() );
String paramName = (String)e.nextElement();
assertNotNull(paramName);
- assertTrue(!e.hasMoreElements());
+ assertTrue( "More than one parameter found", !e.hasMoreElements());
assertEquals("param1",paramName);
assertEquals("value1",request.getParameter(paramName));
@@ -235,10 +234,10 @@
request = links[2].getRequest();
assertNotNull( request );
e = request.getParameterNames();
- assertTrue( e.hasMoreElements() );
+ assertTrue( "No parameters found", e.hasMoreElements() );
paramName = (String)e.nextElement();
assertNotNull(paramName);
- assertTrue(e.hasMoreElements());
+ assertTrue( "Only one parameter found", e.hasMoreElements());
String paramName2 = (String)e.nextElement();
assertNotNull(paramName2);
assertTrue("different names",!paramName.equals(paramName2));
@@ -251,7 +250,7 @@
request = links[3].getRequest();
assertNotNull( request );
e = request.getParameterNames();
- assertTrue( e.hasMoreElements() );
+ assertTrue( "No parameters found", e.hasMoreElements() );
paramName = (String)e.nextElement();
assertNotNull(paramName);
String[] values = request.getParameterValues("param1");
@@ -262,10 +261,10 @@
request = links[4].getRequest();
assertNotNull( request );
e = request.getParameterNames();
- assertTrue( e.hasMoreElements() );
+ assertTrue( "No parameters found", e.hasMoreElements() );
paramName = (String)e.nextElement();
assertNotNull(paramName);
- assertTrue( e.hasMoreElements() );
+ assertTrue( "Only one parameter found", e.hasMoreElements() );
paramName2 = (String)e.nextElement();
assertNotNull(paramName2);
assertTrue("different names",!paramName.equals(paramName2));
@@ -307,9 +306,11 @@
private String[] toStringArray( Enumeration e ) {
- ArrayList al = new ArrayList();
- while (e.hasMoreElements()) al.add( e.nextElement() );
- return (String[]) al.toArray( new String[ al.size() ] );
+ Vector v = new Vector();
+ while (e.hasMoreElements()) v.addElement( e.nextElement() );
+ String[] result = new String[ v.size() ];
+ v.copyInto( result );
+ return result;
}
|
|
From: Russell G. <rus...@us...> - 2001-11-05 18:54:54
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv31303/src/com/meterware/httpunit
Modified Files:
WebForm.java WebResponse.java
Log Message:
Cleaned up JDK 1.1 issues, added some WebForm enhancements
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WebForm.java 2001/10/25 14:51:05 1.28
+++ WebForm.java 2001/11/05 18:54:51 1.29
@@ -58,6 +58,34 @@
/**
+ * Returns true if a parameter with given name exists in this form.
+ **/
+ public boolean hasParameterNamed( String soughtName ) {
+ NamedNodeMap[] parameters = getParameters();
+
+ for (int i = 0; i < parameters.length; i++) {
+ String name = getValue( parameters[ i ].getNamedItem( "name" ) );
+ if (name.equals( soughtName )) return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Returns true if a parameter starting with given name exists,
+ **/
+ public boolean hasParameterStartingWithPrefix( String prefix ) {
+ NamedNodeMap[] parameters = getParameters();
+
+ for (int i = 0; i < parameters.length; i++) {
+ String name = getValue( parameters[i].getNamedItem( "name" ) );
+ if (name.startsWith( prefix )) return true;
+ }
+ return false;
+ }
+
+
+ /**
* Returns an array containing the names of the parameters defined for this form,
* in the order in which they appear.
**/
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- WebResponse.java 2001/10/25 14:51:05 1.50
+++ WebResponse.java 2001/11/05 18:54:51 1.51
@@ -627,7 +627,7 @@
String tokensToAdd = "";
int numTokens = tokens.size();
for (int i=numTokens - 1; i >= 0; i--) {
- String token = (String) tokens.get(i);
+ String token = (String) tokens.elementAt(i);
int equalsIndex = token.indexOf('=');
// if this token has an equals sign (=) in it
@@ -647,7 +647,7 @@
// cookie attribute value
if ( !isTokenReservedWord(token,version) ) {
tokensToAdd = token + tokensToAdd;
- String preceedingToken = (String) tokens.get(i - 1);
+ String preceedingToken = (String) tokens.elementAt(i - 1);
char lastChar = preceedingToken.charAt(preceedingToken.length()-1);
if (lastChar != '=') {
tokensToAdd = ","+ tokensToAdd;
@@ -689,7 +689,7 @@
try {
while (st.nextToken() != StreamTokenizer.TT_EOF) {
- tokens.add( st.sval.trim() );
+ tokens.addElement( st.sval.trim() );
}
}
catch (IOException ioe) {
|
|
From: Russell G. <rus...@us...> - 2001-11-05 18:54:54
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv31303/doc
Modified Files:
release_notes.txt
Log Message:
Cleaned up JDK 1.1 issues, added some WebForm enhancements
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- release_notes.txt 2001/11/05 15:50:38 1.62
+++ release_notes.txt 2001/11/05 18:54:51 1.63
@@ -16,12 +16,17 @@
Acknowledgements:
Thanks to Oliver Imbusch for finding and fixing a problem with parsing of encoded link parameter names and values.
Thanks to Paul Frantz for finding and fixing a problem with parsing of link parameter names without values.
+ Thanks to Didier Besset for new WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix
Problems Fixed:
1. Links with parameters whose names were encoded were being mis-parsed
2. Links with empty parameter values were being mis-parsed
- 3. All references to TestCase.assert except for one have been renamed to assertTrue in order to prepare for JDK 1.4
- and JUnit 3.7 compatibility. HttpUnitTestCase implements assertTrue to continue support for JUnit 3.6 and earlier.
+ 3. Most references to TestCase.assert have been renamed to assertTrue in order to prepare for JDK 1.4 and JUnit 3.7
+ compatibility. HttpUnitTest and ServletUnitTest implement assertTrue to continue support for JUnit 3.6 and earlier.
+ 4. Some incompatibilities with JDK 1.1 had been inadvertantly introduced.
+
+Additions:
+ 1. It is now possible to check a WebForm for the presence of a named parameter.
25-Oct-2001 1.2.7
|
|
From: Russell G. <rus...@us...> - 2001-11-05 18:54:54
|
Update of /cvsroot/httpunit/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv31303
Modified Files:
build.xml
Log Message:
Cleaned up JDK 1.1 issues, added some WebForm enhancements
Index: build.xml
===================================================================
RCS file: /cvsroot/httpunit/httpunit/build.xml,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- build.xml 2001/10/25 17:31:41 1.31
+++ build.xml 2001/11/05 18:54:51 1.32
@@ -24,7 +24,6 @@
<property name="classpath" value="" />
<property name="web.dir" value="web" />
<property name="packages" value="com.meterware.*" />
- <property name="build.compiler" value="classic" />
<property name="test.class" value="com.meterware.httpunit.HttpUnitSuite" />
<!-- =================================================================== -->
|
|
From: Russell G. <rus...@us...> - 2001-11-05 15:50:41
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv10126/test/com/meterware/httpunit
Modified Files:
HttpRequestStream.java WebLinkTest.java
Log Message:
Corrected errors with link parameter parsing
Index: HttpRequestStream.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpRequestStream.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpRequestStream.java 2001/06/11 21:21:09 1.1
+++ HttpRequestStream.java 2001/11/05 15:50:38 1.2
@@ -149,7 +149,7 @@
while (st.hasMoreTokens()) {
String name = st.nextToken();
if (st.hasMoreTokens()) {
- addParameter( parameters, decode( name ), decode( st.nextToken() ) );
+ addParameter( parameters, HttpUnitUtils.decode( name ), HttpUnitUtils.decode( st.nextToken() ) );
}
}
return parameters;
@@ -166,29 +166,6 @@
values[ oldValues.length ] = value;
parameters.put( name, values );
}
- }
-
-
- private String decode( String byteString ) {
- StringBuffer sb = new StringBuffer();
- char[] chars = byteString.toCharArray();
- char[] hexNum = { '0', '0', '0' };
-
- int i = 0;
- while (i < chars.length) {
- if (chars[i] == '+') {
- i++;
- sb.append( ' ' );
- } else if (chars[i] == '%') {
- i++;
- hexNum[1] = chars[i++];
- hexNum[2] = chars[i++];
- sb.append( (char) Integer.parseInt( new String( hexNum ), 16 ) );
- } else {
- sb.append( chars[i++] );
- }
- }
- return sb.toString();
}
}
Index: WebLinkTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebLinkTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WebLinkTest.java 2001/10/26 15:41:04 1.13
+++ WebLinkTest.java 2001/11/05 15:50:38 1.14
@@ -28,6 +28,7 @@
import java.util.Vector;
import java.util.Enumeration;
+import java.util.ArrayList;
/**
@@ -273,6 +274,42 @@
assertMatchingSet("Values for param1",new String[] {"value1", "value3"}, values);
assertMatchingSet("Values form param2",new String[] {"value2"}, request.getParameterValues("param2"));
assertEquals("value2",request.getParameter("param2"));
+ }
+
+
+ public void testEncodedLinkParameters() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "encodedLinks", "<html><head><title>Encode Test</title></head>" +
+ "<body>" +
+ "<a href=\"/request?%24dollar=%25percent&%23hash=%26ampersand\">request</a>" +
+ "</body></html>" );
+ WebResponse mapPage = wc.getResponse( getHostPath() + "/encodedLinks.html" );
+ WebLink link = mapPage.getLinks()[0];
+ WebRequest wr = link.getRequest();
+ assertMatchingSet( "Request parameter names", new String[] { "$dollar", "#hash" }, toStringArray( wr.getParameterNames() ) );
+ assertEquals( "Value of $dollar", "%percent", wr.getParameter( "$dollar" ) );
+ assertEquals( "Value of #hash", "&ersand", wr.getParameter( "#hash" ) );
+ }
+
+
+ public void testValuelessLinkParameters() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "encodedLinks", "<html><head><title>Encode Test</title></head>" +
+ "<body>" +
+ "<a href=\"/request?arg1&valueless=\">request</a>" +
+ "</body></html>" );
+ WebResponse mapPage = wc.getResponse( getHostPath() + "/encodedLinks.html" );
+ WebLink link = mapPage.getLinks()[0];
+ WebRequest wr = link.getRequest();
+ assertMatchingSet( "Request parameter names", new String[] { "arg1", "valueless" }, toStringArray( wr.getParameterNames() ) );
+ assertEquals( "Value of arg1", "", wr.getParameter( "arg1" ) );
+ }
+
+
+ private String[] toStringArray( Enumeration e ) {
+ ArrayList al = new ArrayList();
+ while (e.hasMoreElements()) al.add( e.nextElement() );
+ return (String[]) al.toArray( new String[ al.size() ] );
}
|
|
From: Russell G. <rus...@us...> - 2001-11-05 15:50:41
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv10126/doc Modified Files: release_notes.txt Log Message: Corrected errors with link parameter parsing Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- release_notes.txt 2001/10/25 19:23:17 1.61 +++ release_notes.txt 2001/11/05 15:50:38 1.62 @@ -11,6 +11,18 @@ Revision History: + 5-Nov-2001 + +Acknowledgements: + Thanks to Oliver Imbusch for finding and fixing a problem with parsing of encoded link parameter names and values. + Thanks to Paul Frantz for finding and fixing a problem with parsing of link parameter names without values. + +Problems Fixed: + 1. Links with parameters whose names were encoded were being mis-parsed + 2. Links with empty parameter values were being mis-parsed + 3. All references to TestCase.assert except for one have been renamed to assertTrue in order to prepare for JDK 1.4 + and JUnit 3.7 compatibility. HttpUnitTestCase implements assertTrue to continue support for JUnit 3.6 and earlier. + 25-Oct-2001 1.2.7 Acknowledgements: |
|
From: Russell G. <rus...@us...> - 2001-11-05 15:50:41
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv10126/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java SessionTest.java
Log Message:
Corrected errors with link parameter parsing
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpServletRequestTest.java 2000/11/21 20:44:59 1.1
+++ HttpServletRequestTest.java 2001/11/05 15:50:38 1.2
@@ -125,7 +125,7 @@
HttpServletRequest request = new ServletUnitHttpRequest( wr, new ServletUnitContext() );
assertNull( "attribute should not be defined yet", request.getAttribute( "unset" ) );
- assert( "attribute enumeration should be empty", !request.getAttributeNames().hasMoreElements() );
+ assertTrue( "attribute enumeration should be empty", !request.getAttributeNames().hasMoreElements() );
}
@@ -139,9 +139,9 @@
assertEquals( "attribute one", value, request.getAttribute( "one" ) );
Enumeration names = request.getAttributeNames();
- assert( "attribute enumeration should not be empty", names.hasMoreElements() );
+ assertTrue( "attribute enumeration should not be empty", names.hasMoreElements() );
assertEquals( "contents in enumeration", "one", names.nextElement() );
- assert( "attribute enumeration should now be empty", !names.hasMoreElements() );
+ assertTrue( "attribute enumeration should now be empty", !names.hasMoreElements() );
}
@@ -169,7 +169,7 @@
session = request.getSession();
assertNotNull( "No session created", session );
- assert( "Session not marked as new", session.isNew() );
+ assertTrue( "Session not marked as new", session.isNew() );
}
Index: SessionTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/SessionTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SessionTest.java 2000/11/21 20:44:59 1.1
+++ SessionTest.java 2001/11/05 15:50:38 1.2
@@ -60,10 +60,10 @@
ServletUnitContext context = new ServletUnitContext();
ServletUnitHttpSession session = context.newSession();
assertNotNull( "Session is null", session );
- assert( "Session is not marked as new", session.isNew() );
+ assertTrue( "Session is not marked as new", session.isNew() );
ServletUnitHttpSession session2 = context.newSession();
- assert( "New session has the same ID", !session.getId().equals( session2.getId() ) );
- assert( "Different session returned", session.equals( context.getSession( session.getId() ) ) );
+ assertTrue( "New session has the same ID", !session.getId().equals( session2.getId() ) );
+ assertTrue( "Different session returned", session.equals( context.getSession( session.getId() ) ) );
}
@@ -71,12 +71,12 @@
ServletUnitContext context = new ServletUnitContext();
ServletUnitHttpSession session = context.newSession();
long accessedAt = session.getLastAccessedTime();
- assert( "Session is not marked as new", session.isNew() );
+ assertTrue( "Session is not marked as new", session.isNew() );
try { Thread.currentThread().sleep( 50 ); } catch (InterruptedException e) {};
assertEquals( "Initial access time", accessedAt, context.getSession( session.getId() ).getLastAccessedTime() );
session.access();
- assert( "Last access time not changed", accessedAt != context.getSession( session.getId() ).getLastAccessedTime() );
- assert( "Session is still marked as new", !context.getSession( session.getId() ).isNew() );
+ assertTrue( "Last access time not changed", accessedAt != context.getSession( session.getId() ).getLastAccessedTime() );
+ assertTrue( "Session is still marked as new", !context.getSession( session.getId() ).isNew() );
}
|