httpunit-commit Mailing List for httpunit (Page 32)
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...> - 2003-03-24 03:22:20
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv28617/test/com/meterware/httpunit
Modified Files:
HtmlTablesTest.java
Log Message:
small fixes
Index: HtmlTablesTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- HtmlTablesTest.java 26 Feb 2003 03:02:02 -0000 1.16
+++ HtmlTablesTest.java 24 Mar 2003 03:22:11 -0000 1.17
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
-* Copyright (c) 2000-2002, Russell Gold
+* Copyright (c) 2000-2003, 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,15 +19,13 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import com.meterware.httpunit.parsing.HTMLParserFactory;
-
import junit.framework.TestSuite;
/**
* A unit test of the table handling code.
*
- * @author <a href="mailto:rus...@ac...">Russell Gold</a>
+ * @author <a href="mailto:rus...@ht...">Russell Gold</a>
* @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a>
**/
public class HtmlTablesTest extends HttpUnitTest {
@@ -155,6 +153,7 @@
assertEquals( "Colors", table.getCellAsText( 0, 0 ) );
assertEquals( "Colors", table.getCellAsText( 0, 1 ) );
assertEquals( "Names", table.getCellAsText( 0, 2 ) );
+ assertSame( table.getTableCell( 0, 0 ), table.getTableCell( 0, 1 ) );
}
@@ -166,6 +165,7 @@
assertEquals( "gules", table.getCellAsText( 1, 1 ) );
assertEquals( "gules", table.getCellAsText( 2, 1 ) );
assertEquals( "vert", table.getCellAsText( 2, 2 ) );
+ assertSame( table.getTableCell( 1, 1 ), table.getTableCell( 2, 1 ) );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-23 01:43:22
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv2570/test/com/meterware/httpunit
Modified Files:
WebClientTest.java WebFrameTest.java
Log Message:
Use request URL to select cookies, not connection URL
Index: WebClientTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WebClientTest.java 19 Mar 2003 19:08:59 -0000 1.13
+++ WebClientTest.java 23 Mar 2003 01:43:15 -0000 1.14
@@ -350,12 +350,25 @@
defineResource( "whereAmI", new PseudoServlet() {
public WebResource getGetResponse() throws IOException {
- return new WebResource( "found host header: " + getHeader( "Host" ) );
+ WebResource webResource = new WebResource( "found host header: " + getHeader( "Host" ) );
+ webResource.addHeader( "Set-Cookie: type=short" );
+ return webResource;
}
} );
+ defineResource( "checkCookies", new PseudoServlet() {
+ public WebResource getGetResponse() throws IOException {
+ return new WebResource( "found cookies: " + getHeader( "Cookie" ) );
+ }
+ } );
+
+
WebResponse wr = wc.getResponse( "http://meterware.com:" + getHostPort() + "/whereAmI" );
assertEquals( "Submitted host header", "found host header: meterware.com:" + getHostPort(), wr.getText() );
+ assertEquals( "Returned cookie 'type'", "short", wc.getCookieValue( "type" ) );
+
+ wr = wc.getResponse( "http://meterware.com:" + getHostPort() + "/checkCookies" );
+ assertEquals( "Submitted cookie header", "found cookies: type=short", wr.getText() );
}
Index: WebFrameTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebFrameTest.java 27 Feb 2003 23:36:04 -0000 1.15
+++ WebFrameTest.java 23 Mar 2003 01:43:15 -0000 1.16
@@ -328,6 +328,7 @@
defineWebPage( "Linker", "<form action=redirect.html target=_self><input type=text name=sample value=z></form>" );
defineResource( "redirect.html?sample=z", "", HttpURLConnection.HTTP_MOVED_PERM );
addResourceHeader( "redirect.html?sample=z", "Location: " + getHostPath() + "/Target.html" );
+ addResourceHeader( "redirect.html?sample=z", "Connection: close" ); // TODO see why this is needed and remove it
_wc.getResponse( getHostPath() + "/Frames.html" );
WebResponse response = _wc.getResponse( _wc.getFrameContents( "red" ).getForms()[0].getRequest() );
@@ -340,6 +341,7 @@
public void testSubFrameRedirect() throws Exception {
defineResource( "Linker.html", "", HttpURLConnection.HTTP_MOVED_PERM );
addResourceHeader( "Linker.html", "Location: " + getHostPath() + "/Target.html" );
+ addResourceHeader( "Linker.html", "Connection: close" ); // TODO see why this is needed and remove it
_wc.getResponse( getHostPath() + "/Frames.html" );
assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, _wc.getFrameNames() );
|
|
From: Russell G. <rus...@us...> - 2003-03-23 01:43:20
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv2570/src/com/meterware/httpunit
Modified Files:
WebConversation.java
Log Message:
Use request URL to select cookies, not connection URL
Index: WebConversation.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- WebConversation.java 20 Mar 2003 15:21:57 -0000 1.31
+++ WebConversation.java 23 Mar 2003 01:43:15 -0000 1.32
@@ -55,7 +55,8 @@
**/
protected WebResponse newResponse( WebRequest request, String frameName ) throws MalformedURLException, IOException {
URLConnection connection = openConnection( getRequestURL( request ) );
- sendHeaders( connection, request.getHeaderDictionary() );
+ sendHeaders( connection, getHeaderFields( request.getURL() ) );
+ sendHeaders( connection, request.getHeaderDictionary() );
request.completeRequest( connection );
return new HttpWebResponse( this, frameName, request.getURL(), connection, getExceptionsThrownOnErrorStatus() );
}
@@ -80,13 +81,7 @@
URLConnection connection = url.openConnection();
if (connection instanceof HttpURLConnection) ((HttpURLConnection) connection).setInstanceFollowRedirects( false );
connection.setUseCaches( false );
- sendHeaders( connection );
return connection;
- }
-
-
- private void sendHeaders( URLConnection connection ) {
- sendHeaders( connection, getHeaderFields( connection.getURL() ) );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-20 15:22:00
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv28039/src/com/meterware/httpunit
Modified Files:
DNSListener.java WebConversation.java
Log Message:
DNS lookup cleanup
Index: DNSListener.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/DNSListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DNSListener.java 19 Mar 2003 19:08:58 -0000 1.1
+++ DNSListener.java 20 Mar 2003 15:21:57 -0000 1.2
@@ -10,6 +10,8 @@
/**
* Returns the IP address as a string for the specified host name.
+ * Note: no validation is done to verify that the returned value is an actual IP address or
+ * that the passed host name was not an IP address.
**/
String getIpAddress( String hostName );
Index: WebConversation.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WebConversation.java 19 Mar 2003 19:43:46 -0000 1.30
+++ WebConversation.java 20 Mar 2003 15:21:57 -0000 1.31
@@ -67,7 +67,9 @@
String hostName = request.getURL().getHost();
setHeaderField( "Host", hostName + ':' + request.getURL().getPort() );
- return new URL( request.getURL().getProtocol(), dnsListener.getIpAddress( hostName ), request.getURL().getPort(), request.getURL().getFile() );
+ String actualHost = dnsListener.getIpAddress( hostName );
+ if (HttpUnitOptions.isLoggingHttpHeaders()) System.out.println( "Rerouting request to :: " + actualHost );
+ return new URL( request.getURL().getProtocol(), actualHost, request.getURL().getPort(), request.getURL().getFile() );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-20 14:51:26
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv7386/doc
Modified Files:
faq.html release_notes.txt
Log Message:
minor fixes
Index: faq.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/faq.html,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- faq.html 16 Mar 2003 14:10:24 -0000 1.26
+++ faq.html 20 Mar 2003 14:50:51 -0000 1.27
@@ -17,18 +17,19 @@
<LI><A HREF="#proxy">Can I use HttpUnit through a proxy server?</A></LI>
<LI><A HREF="#charset">Why isn't HttpUnit handling my non-English pages?</A></LI>
<LI><A HREF="#badType">The server is not sending a valid content type. How do I test HTML pages anyway?</A></LI>
+<LI><A HREF="#timeout">How does HttpUnit handle request timeouts?</A></LI>
-</ol><ol start=8>
+</ol><ol start=9>
<LI><A HREF="#buttons">HttpUnit is not finding the buttons and parameters in my forms. What is wrong?</A></LI>
<LI><A HREF="#hidden">Why can't I change hidden parameters?</A></LI>
-</ol><ol start=10>
+</ol><ol start=11>
<LI><A HREF="#javascript">How do I use HttpUnit to test my pages that use JavaScript?</A></LI>
<LI><A HREF="#norhino">JavaScript is not being executed at all. Why not?</A></LI>
<li><a href="#unsupported">How do I handle a page that uses JavaScript features that HttpUnit does not support?</a></li>
<li><a href="#text">I called document.write() in my page, but getText() does not show the results! Why not?</a></li>
-</ol><ol start=14>
+</ol><ol start=15>
<LI><A HREF="#session">How can I see the servlet session between calls?</A></LI>
<li><a href="#JSP">Can I use JSPs with ServletUnit?</a></li>
</OL>
@@ -91,6 +92,10 @@
it, as most servers do. If yours is not, you can
call<blockquote><code>HttpUnitOptions.setDefaultContentType( "text/html" );</code></blockquote>before running your tests.
If you are using JUnit, call this method in your <code>setUp()</code> method.
+
+<A name="#timeout"><h3>How does HttpUnit handle request timeouts?</h3></A>
+Badly. Unfortunately, through JDK 1.3, HttpURLConnection (used by HttpUnit to access web servers) has no support for
+timeouts. This is changed in JDK 1.4, but HttpUnit does not support the new feature as yet.
<h2>Form Handling Problems</h2>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.280
retrieving revision 1.281
diff -u -r1.280 -r1.281
--- release_notes.txt 19 Mar 2003 19:08:57 -0000 1.280
+++ release_notes.txt 20 Mar 2003 14:50:52 -0000 1.281
@@ -13,6 +13,10 @@
Revision History:
+ 20-Mar-2003
+Problems fixed:
+ 1. ServletUnit had not implemented HttpServletRequest.getContentLength();
+
19-Mar-2003
Acknowledgements:
Thanks to Brendan Boesen for correcting the session invalidation problem.
|
|
From: Russell G. <rus...@us...> - 2003-03-20 14:50:59
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv7386/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java
Log Message:
minor fixes
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- HttpServletRequestTest.java 19 Mar 2003 14:48:21 -0000 1.16
+++ HttpServletRequestTest.java 20 Mar 2003 14:50:54 -0000 1.17
@@ -24,6 +24,9 @@
import java.util.Map;
import java.util.Locale;
import java.net.MalformedURLException;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.BufferedInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -33,6 +36,7 @@
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.PutMethodWebRequest;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -60,7 +64,7 @@
public void testHeaderAccess() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setHeaderField( "sample", "value" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "sample header value", "value", request.getHeader( "sample") );
@@ -79,7 +83,7 @@
public void testGetDefaultProperties() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertNull( "Authorization incorrectly specified", request.getAuthType() );
assertNull( "Character encoding incorrectly specified", request.getCharacterEncoding() );
@@ -89,7 +93,7 @@
public void testSetSingleValuedParameter() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
@@ -100,7 +104,7 @@
public void testSetMultiValuedParameter() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
@@ -112,7 +116,7 @@
public void testParameterMap() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
@@ -125,7 +129,7 @@
public void testSetQueryString() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
wr.setParameter( "age", "12" );
wr.setParameter( "color", new String[] { "red", "blue" } );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
@@ -135,7 +139,7 @@
public void testInlineSingleValuedParameter() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "age parameter", "12", request.getParameter( "age" ) );
@@ -144,7 +148,7 @@
public void testInlineMultiValuedParameter() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) );
@@ -153,16 +157,30 @@
}
- public void notestInlineQueryString() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
+ public void notestInlineQueryString() throws Exception { // TODO make this work
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple?color=red&color=blue&age=12" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertEquals( "query string", "color=red&color=blue&age=12", request.getQueryString() );
}
+ public void testRequestMessageBody() throws Exception {
+ String body = "12345678901234567890";
+ InputStream stream = new ByteArrayInputStream( body.getBytes( "UTF-8" ) );
+ WebRequest wr = new PutMethodWebRequest( "http://localhost/simple", stream, "text/plain" );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), body.getBytes() );
+
+ assertEquals( "Request content length", body.length(), request.getContentLength() );
+ BufferedInputStream bis = new BufferedInputStream( request.getInputStream() );
+ byte[] buffer = new byte[ request.getContentLength() ];
+ bis.read( buffer );
+ assertEquals( "Request content", body, new String( buffer ) );
+ }
+
+
public void testDefaultAttributes() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
assertNull( "attribute should not be defined yet", request.getAttribute( "unset" ) );
@@ -171,7 +189,7 @@
public void testNonDefaultAttributes() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
Object value = new Integer(1);
@@ -187,7 +205,7 @@
public void testDuplicateAttributes() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
request.setAttribute( "one", new Integer(1) );
@@ -197,7 +215,7 @@
public void testNullAttributeValue() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
request.setAttribute( "one", "One" );
@@ -208,7 +226,7 @@
public void testDefaultCookies() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
Cookie[] cookies = request.getCookies();
assertNull( "Unexpected cookies found", cookies );
@@ -216,7 +234,7 @@
public void testSetCookies() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
request.addCookie( new Cookie( "flavor", "vanilla" ) );
@@ -227,8 +245,8 @@
assertEquals( "Cookie value", "vanilla", cookies[0].getValue() );
}
- public void testGetSessionForFirstTime() throws MalformedURLException {
+ public void testGetSessionForFirstTime() throws MalformedURLException {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitContext context = new ServletUnitContext();
assertEquals( "Initial number of sessions in context", 0, context.getSessionIDs().size() );
@@ -252,7 +270,7 @@
* will cause a session to be made available.
*/
public void testRetrieveSession() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitContext context = new ServletUnitContext();
ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
@@ -297,7 +315,7 @@
* Obtains a new session, invalidates it, and verifies that
*/
public void testSessionInvalidation() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitContext context = new ServletUnitContext();
HttpSession originalSession = context.newSession();
@@ -326,7 +344,7 @@
* Verifies that a request with a bad session ID causes a new session to be generated only when explicitly requested.
*/
public void testGetSessionWithBadCookie() throws Exception {
- WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitContext context = new ServletUnitContext();
ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
@@ -378,7 +396,8 @@
assertTrue( "Request not marked as secure", request.isSecure() );
}
- private void verifyLocales(ServletUnitHttpRequest request, Locale[] expectedLocales) {
+
+ private void verifyLocales( ServletUnitHttpRequest request, Locale[] expectedLocales ) {
assertNotNull( "No default locale found", request.getLocale() );
assertEquals( "default locale", expectedLocales[0], request.getLocale() );
|
|
From: Russell G. <rus...@us...> - 2003-03-20 14:50:58
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv7386/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java
Log Message:
minor fixes
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- ServletUnitHttpRequest.java 19 Mar 2003 14:48:21 -0000 1.27
+++ ServletUnitHttpRequest.java 20 Mar 2003 14:50:53 -0000 1.28
@@ -290,7 +290,7 @@
* length is not known.
**/
public int getContentLength() {
- return -1;
+ return getIntHeader( "Content-length" );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-20 14:50:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv7386/src/com/meterware/httpunit
Modified Files:
HttpWebResponse.java
Log Message:
minor fixes
Index: HttpWebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- HttpWebResponse.java 22 Oct 2002 22:59:25 -0000 1.28
+++ HttpWebResponse.java 20 Mar 2003 14:50:53 -0000 1.29
@@ -115,7 +115,17 @@
public String toString() {
- return "HttpWebResponse [url=" + getURL() + "; headers=" + _headers + "]";
+ StringBuffer sb = new StringBuffer( "HttpWebResponse [url=" );
+ sb.append( getURL() ).append( "; headers=" );
+ for (Enumeration e = _headers.keys(); e.hasMoreElements(); ) {
+ Object key = e.nextElement();
+ String[] values = (String[]) _headers.get( key );
+ for (int i = 0; i < values.length; i++) {
+ sb.append( "\n " ).append( key ).append( ": " ).append( values[i] );
+ }
+ }
+ sb.append( " ]" );
+ return sb.toString();
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 19:43:50
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv4801/src/com/meterware/httpunit
Modified Files:
WebConversation.java
Log Message:
Disable HTTP URL Connection per instance, not globally
Index: WebConversation.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- WebConversation.java 19 Mar 2003 19:08:58 -0000 1.29
+++ WebConversation.java 19 Mar 2003 19:43:46 -0000 1.30
@@ -73,13 +73,10 @@
//---------------------------------- private members --------------------------------
- static {
- HttpURLConnection.setFollowRedirects( false );
- }
-
private URLConnection openConnection( URL url ) throws MalformedURLException, IOException {
URLConnection connection = url.openConnection();
+ if (connection instanceof HttpURLConnection) ((HttpURLConnection) connection).setInstanceFollowRedirects( false );
connection.setUseCaches( false );
sendHeaders( connection );
return connection;
|
|
From: Russell G. <rus...@us...> - 2003-03-19 19:09:04
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20577/test/com/meterware/httpunit
Modified Files:
WebClientTest.java
Log Message:
Add support for DNS override
Index: WebClientTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebClientTest.java 19 Mar 2003 16:31:23 -0000 1.12
+++ WebClientTest.java 19 Mar 2003 19:08:59 -0000 1.13
@@ -342,4 +342,21 @@
}
+ public void testDNSOverride() throws Exception {
+ WebConversation wc = new WebConversation();
+ wc.getClientProperties().setDnsListener( new DNSListener() {
+ public String getIpAddress( String hostName ) { return "127.0.0.1"; }
+ });
+
+ defineResource( "whereAmI", new PseudoServlet() {
+ public WebResource getGetResponse() throws IOException {
+ return new WebResource( "found host header: " + getHeader( "Host" ) );
+ }
+ } );
+
+ WebResponse wr = wc.getResponse( "http://meterware.com:" + getHostPort() + "/whereAmI" );
+ assertEquals( "Submitted host header", "found host header: meterware.com:" + getHostPort(), wr.getText() );
+ }
+
+
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 19:09:02
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv20577/src/com/meterware/httpunit
Modified Files:
ClientProperties.java WebConversation.java
Added Files:
DNSListener.java
Log Message:
Add support for DNS override
--- NEW FILE ---
package com.meterware.httpunit;
/**
* A listener for DNS Requests. Users may implement this interface to bypass the normal DNS lookup.
*
* @author <a href="rus...@ht...">Russell Gold</a>
**/
public interface DNSListener {
/**
* Returns the IP address as a string for the specified host name.
**/
String getIpAddress( String hostName );
}
Index: ClientProperties.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ClientProperties.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClientProperties.java 16 Mar 2003 17:22:38 -0000 1.5
+++ ClientProperties.java 19 Mar 2003 19:08:58 -0000 1.6
@@ -210,6 +210,22 @@
}
+ /**
+ * Specifies a listener for DNS requests from the client.
+ */
+ public void setDnsListener( DNSListener dnsListener ) {
+ _dnsListener = dnsListener;
+ }
+
+
+ /**
+ * Returns the listener for DNS requests to be used by the client.
+ */
+ DNSListener getDnsListener() {
+ return _dnsListener;
+ }
+
+
static ClientProperties cloneProperties() {
return new ClientProperties( getDefaultProperties() );
}
@@ -228,6 +244,8 @@
private boolean _acceptGzip = true;
private boolean _autoRedirect = true;
private boolean _autoRefresh = false;
+
+ private DNSListener _dnsListener;
private static ClientProperties _defaultProperties = new ClientProperties();
Index: WebConversation.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WebConversation.java 21 Feb 2003 19:28:04 -0000 1.28
+++ WebConversation.java 19 Mar 2003 19:08:58 -0000 1.29
@@ -54,10 +54,20 @@
* Creates a web response object which represents the response to the specified web request.
**/
protected WebResponse newResponse( WebRequest request, String frameName ) throws MalformedURLException, IOException {
- URLConnection connection = openConnection( request.getURL() );
+ URLConnection connection = openConnection( getRequestURL( request ) );
sendHeaders( connection, request.getHeaderDictionary() );
request.completeRequest( connection );
return new HttpWebResponse( this, frameName, request.getURL(), connection, getExceptionsThrownOnErrorStatus() );
+ }
+
+
+ private URL getRequestURL( WebRequest request ) throws MalformedURLException {
+ DNSListener dnsListener = getClientProperties().getDnsListener();
+ if (dnsListener == null) return request.getURL();
+
+ String hostName = request.getURL().getHost();
+ setHeaderField( "Host", hostName + ':' + request.getURL().getPort() );
+ return new URL( request.getURL().getProtocol(), dnsListener.getIpAddress( hostName ), request.getURL().getPort(), request.getURL().getFile() );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 19:09:01
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv20577/doc
Modified Files:
release_notes.txt
Log Message:
Add support for DNS override
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -r1.279 -r1.280
--- release_notes.txt 19 Mar 2003 17:41:03 -0000 1.279
+++ release_notes.txt 19 Mar 2003 19:08:57 -0000 1.280
@@ -24,6 +24,8 @@
Additions:
1. PseudoServer now handles persistent connections.
+ 2. ClientProperties now supports a listener which allows for the override of DNS mapping, allowing a client
+ to supply an actual IP address for a host programatically. The original Host header will be retained.
17-Mar-2003
Problems fixed:
|
|
From: Russell G. <rus...@us...> - 2003-03-19 19:06:13
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv19188/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
fix document.close bugfix
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- JavaScript.java 19 Mar 2003 17:41:04 -0000 1.48
+++ JavaScript.java 19 Mar 2003 19:05:38 -0000 1.49
@@ -541,8 +541,9 @@
public void jsFunction_close() {
- getDelegate().replaceText( getWriteBuffer().toString(), _mimeType == null ? "text/html" : _mimeType );
- getWriteBuffer().setLength(0);
+ if (getDelegate().replaceText( getWriteBuffer().toString(), _mimeType == null ? "text/html" : _mimeType )) {
+ getWriteBuffer().setLength(0);
+ }
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 19:05:45
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv19188/src/com/meterware/httpunit
Modified Files:
HTMLPage.java WebResponse.java
Log Message:
fix document.close bugfix
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- HTMLPage.java 9 Mar 2003 20:35:46 -0000 1.26
+++ HTMLPage.java 19 Mar 2003 19:05:39 -0000 1.27
@@ -199,8 +199,8 @@
Scriptable() {}
- public void replaceText( String text, String contentType ) {
- getResponse().replaceText( text, contentType );
+ public boolean replaceText( String text, String contentType ) {
+ return getResponse().replaceText( text, contentType );
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- WebResponse.java 12 Mar 2003 15:40:08 -0000 1.113
+++ WebResponse.java 19 Mar 2003 19:05:40 -0000 1.114
@@ -728,8 +728,8 @@
}
- void replaceText( String text, String contentType ) {
- if (_parsingPage) return;
+ boolean replaceText( String text, String contentType ) {
+ if (_parsingPage) return false;
_responseText = text;
_inputStream = null;
_page = null;
@@ -746,6 +746,7 @@
} catch (MalformedURLException e) {
throw new RuntimeException( "Failure while attempting to reparse text: " + e );
}
+ return true;
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 17:41:09
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv7612/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java
Log Message:
from Andrew Bickerton: reopening a document now overwrites rather than appending
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DocumentScriptingTest.java 16 Mar 2003 18:55:34 -0000 1.8
+++ DocumentScriptingTest.java 19 Mar 2003 17:41:05 -0000 1.9
@@ -280,6 +280,8 @@
WebWindow ww = wc.getOpenWindow( "sample");
assertEquals( "Generated page", "You made it!", ww.getCurrentPage().getText() );
assertEquals( "Content Type", "text/plain", ww.getCurrentPage().getContentType() );
+ link.click();
+ assertEquals( "Generated page", "You made it!", ww.getCurrentPage().getText() );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 17:41:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv7612/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
from Andrew Bickerton: reopening a document now overwrites rather than appending
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- JavaScript.java 9 Mar 2003 20:35:47 -0000 1.47
+++ JavaScript.java 19 Mar 2003 17:41:04 -0000 1.48
@@ -542,6 +542,7 @@
public void jsFunction_close() {
getDelegate().replaceText( getWriteBuffer().toString(), _mimeType == null ? "text/html" : _mimeType );
+ getWriteBuffer().setLength(0);
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 17:41:08
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv7612/doc
Modified Files:
release_notes.txt
Log Message:
from Andrew Bickerton: reopening a document now overwrites rather than appending
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.278
retrieving revision 1.279
diff -u -r1.278 -r1.279
--- release_notes.txt 19 Mar 2003 15:26:04 -0000 1.278
+++ release_notes.txt 19 Mar 2003 17:41:03 -0000 1.279
@@ -16,8 +16,12 @@
19-Mar-2003
Acknowledgements:
Thanks to Brendan Boesen for correcting the session invalidation problem.
+ Thanks to Andrew Bickerton for correcting the document.write append problem.
+
Problems fixed:
1. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
+ 2. calling document.write on a closed document was appending to rather than replacing its contents.
+
Additions:
1. PseudoServer now handles persistent connections.
|
|
From: Russell G. <rus...@us...> - 2003-03-19 16:31:27
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv7379/test/com/meterware/httpunit
Modified Files:
WebClientTest.java
Log Message:
Be sure to reset the status for a new response
Index: WebClientTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- WebClientTest.java 16 Mar 2003 17:22:38 -0000 1.11
+++ WebClientTest.java 19 Mar 2003 16:31:23 -0000 1.12
@@ -301,6 +301,7 @@
WebResponse response = wc.getResponse( getHostPath() + '/' + redirectName );
assertEquals( "requested resource", resourceValue, response.getText().trim() );
assertEquals( "content type", "text/html", response.getContentType() );
+ assertEquals( "status", HttpURLConnection.HTTP_OK, response.getResponseCode() );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 16:31:27
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver
In directory sc8-pr-cvs1:/tmp/cvs-serv7379/src/com/meterware/pseudoserver
Modified Files:
PseudoServer.java
Log Message:
Be sure to reset the status for a new response
Index: PseudoServer.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/PseudoServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PseudoServer.java 19 Mar 2003 15:26:06 -0000 1.8
+++ PseudoServer.java 19 Mar 2003 16:31:23 -0000 1.9
@@ -334,6 +334,8 @@
void restart() {
_headersWritten = false;
_headers.clear();
+ _responseCode = HttpURLConnection.HTTP_OK;
+ _responseText = "OK";
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 15:26:11
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver
In directory sc8-pr-cvs1:/tmp/cvs-serv12686/src/com/meterware/pseudoserver
Modified Files:
HttpRequest.java HttpUserAgentTest.java PseudoServer.java
WebResource.java
Log Message:
Support persistent connections
Index: HttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpRequest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpRequest.java 19 Mar 2003 03:38:06 -0000 1.2
+++ HttpRequest.java 19 Mar 2003 15:26:06 -0000 1.3
@@ -4,12 +4,12 @@
*
* Copyright (c) 2001-2003, 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
@@ -54,7 +54,7 @@
_command = st.nextToken();
_uri = st.nextToken();
_protocol = st.nextToken();
-
+
if (!_command.equals( "GET" ) && !_command.equals( "POST" ) && !_command.equals( "PUT" )) {
throw new UnknownMethodException( _command );
}
@@ -192,14 +192,17 @@
boolean wantsKeepAlive() {
+ /**
return false;
-// if ("Keep-alive".equalsIgnoreCase( getConnectionHeader() )) {
-// return true;
-// } else if (_protocol.equals( "HTTP/1.1" )) {
-// return !"Close".equalsIgnoreCase( getConnectionHeader() );
-// } else {
-// return false;
-// }
+ /**/
+ if ("Keep-alive".equalsIgnoreCase( getConnectionHeader() )) {
+ return true;
+ } else if (_protocol.equals( "HTTP/1.1" )) {
+ return !"Close".equalsIgnoreCase( getConnectionHeader() );
+ } else {
+ return false;
+ }
+ /**/
}
Index: HttpUserAgentTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpUserAgentTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HttpUserAgentTest.java 7 Mar 2003 05:04:02 -0000 1.8
+++ HttpUserAgentTest.java 19 Mar 2003 15:26:06 -0000 1.9
@@ -100,6 +100,11 @@
}
+ protected void setServerDebug( boolean enabled ) {
+ _server.setDebug( enabled );
+ }
+
+
protected String getHostPath() {
return _hostPath;
}
Index: PseudoServer.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/PseudoServer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PseudoServer.java 19 Mar 2003 03:38:06 -0000 1.7
+++ PseudoServer.java 19 Mar 2003 15:26:06 -0000 1.8
@@ -157,12 +157,19 @@
}
+ public void setDebug( boolean debug ) {
+ _debug = debug;
+ }
+
+
//------------------------------------- private members ---------------------------------------
private Hashtable _resources = new Hashtable();
private boolean _active = true;
+ private boolean _debug;
+
private String asResourceName( String rawName ) {
if (rawName.startsWith( "/" )) {
@@ -210,6 +217,7 @@
socket.setSoTimeout( 1000 );
socket.setTcpNoDelay( true );
+ if (_debug) System.out.println( "** Created server thread: " + hashCode() );
final BufferedInputStream inputStream = new BufferedInputStream( socket.getInputStream() );
final HttpResponseStream outputStream = new HttpResponseStream( socket.getOutputStream() );
@@ -221,12 +229,14 @@
try { Thread.sleep(10); } catch (InterruptedException e) {}
}
}
+ if (_debug) System.out.println( "** Closing server thread: " + hashCode() );
outputStream.close();
socket.close();
}
private boolean respondToRequest( HttpRequest request, HttpResponseStream response ) {
+ if (_debug) System.out.println( "** Server thread " + hashCode() + " handling request: " + request );
boolean keepAlive = request.wantsKeepAlive();
try {
response.restart();
@@ -241,6 +251,7 @@
}
String[] headers = resource.getHeaders();
for (int i = 0; i < headers.length; i++) {
+ if (_debug) System.out.println( "** Server thread " + hashCode() + " sending header: " + headers[i] );
response.addHeader( headers[i] );
}
response.write( resource );
Index: WebResource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/WebResource.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebResource.java 19 Mar 2003 03:38:06 -0000 1.5
+++ WebResource.java 19 Mar 2003 15:26:06 -0000 1.6
@@ -98,6 +98,7 @@
_stream = stream;
_contentType = contentType;
_responseCode = responseCode;
+ addHeader( "Connection: close" );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 15:26:11
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv12686/doc
Modified Files:
release_notes.txt
Log Message:
Support persistent connections
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.277
retrieving revision 1.278
diff -u -r1.277 -r1.278
--- release_notes.txt 19 Mar 2003 14:48:20 -0000 1.277
+++ release_notes.txt 19 Mar 2003 15:26:04 -0000 1.278
@@ -18,6 +18,8 @@
Thanks to Brendan Boesen for correcting the session invalidation problem.
Problems fixed:
1. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
+Additions:
+ 1. PseudoServer now handles persistent connections.
17-Mar-2003
Problems fixed:
|
|
From: Russell G. <rus...@us...> - 2003-03-19 14:48:26
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv9962/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java
Log Message:
No longer replace invalid session without being asked
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HttpServletRequestTest.java 16 Mar 2003 14:14:39 -0000 1.15
+++ HttpServletRequestTest.java 19 Mar 2003 14:48:21 -0000 1.16
@@ -266,33 +266,59 @@
}
+ public void testAccessForbiddenToInvalidSession() throws Exception {
+ ServletUnitContext context = new ServletUnitContext();
+
+ HttpSession session = context.newSession();
+ session.setAttribute( "Initial", new Integer( 1 ) );
+ Enumeration attributeNames = session.getAttributeNames();
+ assertTrue( attributeNames.hasMoreElements() );
+ assertEquals( "Initial", attributeNames.nextElement() );
+
+ session.invalidate();
+
+ try {
+ session.getAttributeNames().hasMoreElements();
+ fail( "Should not be able to access an invalid session's attributes" );
+ } catch (IllegalStateException ex) {
+ }
+
+ try {
+ session.getAttribute( "Initial" );
+ fail( "Should not be able to access an invalid session's attributes" );
+ } catch (IllegalStateException ex) {
+ }
+ }
+
+
/**
* Verifies that a request for a session when the current one is invalid will result in a new session.
- * @throws Exception
+ *
+ * Obtains a new session, invalidates it, and verifies that
*/
public void testSessionInvalidation() throws Exception {
WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
ServletUnitContext context = new ServletUnitContext();
+ HttpSession originalSession = context.newSession();
+ String originalID = originalSession.getId();
+
ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
- request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, context.newSession().getId() ) );
+ request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) );
+ originalSession.setAttribute( "Initial", new Integer( 1 ) );
+ Enumeration attributeNames = originalSession.getAttributeNames();
+ assertTrue( attributeNames.hasMoreElements() );
+ assertEquals( "Initial", attributeNames.nextElement() );
- HttpSession session = request.getSession( /* create */ false );
- String originalID = session.getId();
- session.setAttribute( "Initial", new Integer(1) );
+ originalSession.invalidate();
- request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
- request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) );
- session = request.getSession();
- assertEquals( "Retrieved session ID", originalID, session.getId() );
- assertEquals( "Attribute", new Integer(1), session.getAttribute( "Initial" ) );
+ assertNull( "Invalidated session returned", request.getSession( false ) );
- session.invalidate();
- request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
- request.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, originalID ) );
- session = request.getSession();
- assertNull( "Attribute should not exist", session.getAttribute( "Initial" ) );
- assertFalse( "New session not created", originalID.equals( session.getId() ) );
+ HttpSession newSession = request.getSession( true );
+ assertNotNull( "getSession(true) did not return a session", newSession );
+ assertNotSame( "getSession(true) returned the original invalidated session", originalSession, newSession );
+ assertSame( "session returned by getSession(false)", newSession, request.getSession( false ) );
+ assertSame( "Session in context with new ID", newSession, context.getSession( newSession.getId() ) );
}
|
|
From: Russell G. <rus...@us...> - 2003-03-19 14:48:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory sc8-pr-cvs1:/tmp/cvs-serv9962/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java
Log Message:
No longer replace invalid session without being asked
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ServletUnitHttpRequest.java 17 Mar 2003 17:37:04 -0000 1.26
+++ ServletUnitHttpRequest.java 19 Mar 2003 14:48:21 -0000 1.27
@@ -237,7 +237,12 @@
if (_session == null && getRequestedSessionId() != null) {
_session = _context.getSession( getRequestedSessionId() );
}
- if (_session == null ? create : _session.isInvalid()) {
+
+ if (_session != null && _session.isInvalid()) {
+ _session = null;
+ }
+
+ if (_session == null && create) {
_session = _context.newSession();
}
return _session;
|
|
From: Russell G. <rus...@us...> - 2003-03-19 14:48:25
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv9962/doc
Modified Files:
release_notes.txt
Log Message:
No longer replace invalid session without being asked
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.276
retrieving revision 1.277
diff -u -r1.276 -r1.277
--- release_notes.txt 17 Mar 2003 17:37:00 -0000 1.276
+++ release_notes.txt 19 Mar 2003 14:48:20 -0000 1.277
@@ -13,6 +13,12 @@
Revision History:
+ 19-Mar-2003
+Acknowledgements:
+ Thanks to Brendan Boesen for correcting the session invalidation problem.
+Problems fixed:
+ 1. ServletUnit was creating a new session if the current one was not valid, even if "create" was not specified.
+
17-Mar-2003
Problems fixed:
1. The Content-Length header was not being sent with requests in ServletUnit.
|
|
From: Russell G. <rus...@us...> - 2003-03-19 03:45:57
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv8325/test/com/meterware/httpunit
Modified Files:
WebPageTest.java
Log Message:
Continuing work towards persistent connection support
Index: WebPageTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- WebPageTest.java 16 Mar 2003 17:22:38 -0000 1.29
+++ WebPageTest.java 19 Mar 2003 03:38:07 -0000 1.30
@@ -55,12 +55,6 @@
}
- public void tearDown() throws Exception {
- super.tearDown();
- HttpUnitOptions.resetDefaultCharacterSet();
- }
-
-
public void testNoResponse() throws Exception {
WebConversation wc = new WebConversation();
try {
@@ -393,6 +387,7 @@
HttpUnitOptions.setCheckContentLength( true );
String page = "abcdefghijklmnop";
defineResource( "alphabet.html", page, "text/plain" );
+ addResourceHeader( "alphabet.html", "Connection: close" );
addResourceHeader( "alphabet.html", "Content-length: 26" );
WebConversation wc = new WebConversation();
|