httpunit-commit Mailing List for httpunit (Page 14)
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...> - 2004-09-26 01:30:51
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22324/test/com/meterware/httpunit Modified Files: WebClientTest.java Log Message: patch #1015466: HTTP 1.1 messages without specified lengths are now handled with a read timeout of .5 sec Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- WebClientTest.java 22 Sep 2004 02:02:10 -0000 1.22 +++ WebClientTest.java 26 Sep 2004 01:30:37 -0000 1.23 @@ -359,6 +359,7 @@ private class CompressedPseudoServlet extends PseudoServlet { private String _responseText; + private boolean _suppressLengthHeader; public CompressedPseudoServlet( String responseText ) { @@ -366,11 +367,18 @@ } + public CompressedPseudoServlet( String responseText, boolean suppressLengthHeader ) { + this( responseText ); + _suppressLengthHeader = suppressLengthHeader; + } + + public WebResource getGetResponse() throws IOException { if (!userAcceptsGZIP()) { return new WebResource( _responseText.getBytes(), "text/plain" ); } else { WebResource result = new WebResource( getCompressedContents(), "text/plain" ); + if (_suppressLengthHeader) result.suppressAutomaticLengthHeader(); result.addHeader( "Content-Encoding: gzip" ); return result; } @@ -396,6 +404,20 @@ } + public void testGZIPUndefinedLengthHandling() throws Exception { + String expectedResponse = "Here is my answer. It needs to be reasonably long to make compression smaller " + + "than the raw message. It should be obvious when you reach that point. " + + "Of course it is more than that - it needs to be long enough to cause a problem."; + defineResource( "Compressed.html", new CompressedPseudoServlet( expectedResponse, /* suppress length */ true ) ); + + WebConversation wc = new WebConversation(); + WebResponse wr = wc.getResponse( getHostPath() + "/Compressed.html" ); + assertEquals( "Content-Encoding header", "gzip", wr.getHeaderField( "Content-encoding" ) ); + assertEquals( "Content-Type", "text/plain", wr.getContentType() ); + assertEquals( "Content", expectedResponse, wr.getText().trim() ); + } + + public void testClientListener() throws Exception { defineWebPage( "Target", "This is another page with <a href=Form.html target='_top'>one link</a>" ); defineWebPage( "Form", "This is a page with a simple form: " + |
From: Russell G. <rus...@us...> - 2004-09-26 01:30:49
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22324/src/com/meterware/pseudoserver Modified Files: WebResource.java Log Message: patch #1015466: HTTP 1.1 messages without specified lengths are now handled with a read timeout of .5 sec Index: WebResource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/WebResource.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- WebResource.java 17 Sep 2003 01:21:15 -0000 1.8 +++ WebResource.java 26 Sep 2004 01:30:37 -0000 1.9 @@ -77,6 +77,11 @@ } + public void suppressAutomaticLengthHeader() { + _hasExplicitContentLengthHeader = true; + } + + WebResource( String contents, int responseCode ) { this( contents, DEFAULT_CONTENT_TYPE, responseCode ); } |
From: Russell G. <rus...@us...> - 2004-09-24 20:31:39
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25329/test/com/meterware/servletunit Modified Files: WebXMLTest.java Log Message: make sure test directory exists before using it... Index: WebXMLTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- WebXMLTest.java 24 Sep 2004 19:13:45 -0000 1.23 +++ WebXMLTest.java 24 Sep 2004 20:31:27 -0000 1.24 @@ -70,7 +70,9 @@ private File createWebXml( WebXMLString wxs ) throws IOException { - File webXml = new File( "examples/META-INF/web.xml" ); + File dir = new File( "build/META-INF" ); + dir.mkdirs(); + File webXml = new File( dir, "web.xml" ); FileOutputStream fos = new FileOutputStream( webXml ); fos.write( wxs.asText().getBytes() ); fos.close(); |
From: Russell G. <rus...@us...> - 2004-09-24 20:13:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22211/src/com/meterware/pseudoserver Modified Files: HttpUserAgentTest.java Log Message: patch #1026566 The Cookie class now implements hashCode properly. Index: HttpUserAgentTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpUserAgentTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- HttpUserAgentTest.java 27 Aug 2003 02:16:06 -0000 1.13 +++ HttpUserAgentTest.java 24 Sep 2004 20:13:16 -0000 1.14 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002-2003, Russell Gold + * Copyright (c) 2002-2004, 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 @@ -279,6 +279,12 @@ return getClass().equals( o.getClass() ) && equals( (QuerySpec) o ); } + + public int hashCode() { + return _path.hashCode() ^ _parameters.size(); + } + + private String _path; private String _fullString; private Vector _parameters = new Vector(); |
From: Russell G. <rus...@us...> - 2004-09-24 20:13:25
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22211/src/com/meterware/httpunit/cookies Modified Files: Cookie.java Log Message: patch #1026566 The Cookie class now implements hashCode properly. Index: Cookie.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/Cookie.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Cookie.java 12 Sep 2004 06:08:23 -0000 1.5 +++ Cookie.java 24 Sep 2004 20:13:16 -0000 1.6 @@ -117,21 +117,16 @@ } - public boolean equals( Object obj ) { - return obj.getClass() == getClass() && equals( (Cookie) obj ); - } - - - boolean mayBeSentTo( URL url ) { - if (getDomain() == null) return true; - if (_expiredTime != 0 && _expiredTime <= System.currentTimeMillis()) return false; - - return acceptHost( getDomain(), url.getHost() ) && acceptPath( getPath(), url.getPath() ); + public int hashCode() { + int hashCode = _name.hashCode(); + if (_domain != null) hashCode ^= _domain.hashCode(); + if (_path != null) hashCode ^= _path.hashCode(); + return hashCode; } - private boolean acceptPath( String pathPattern, String hostPath ) { - return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern ); + public boolean equals( Object obj ) { + return obj.getClass() == getClass() && equals( (Cookie) obj ); } @@ -147,6 +142,19 @@ } + boolean mayBeSentTo( URL url ) { + if (getDomain() == null) return true; + if (_expiredTime != 0 && _expiredTime <= System.currentTimeMillis()) return false; + + return acceptHost( getDomain(), url.getHost() ) && acceptPath( getPath(), url.getPath() ); + } + + + private boolean acceptPath( String pathPattern, String hostPath ) { + return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern ); + } + + private static boolean acceptHost( String hostPattern, String hostName ) { return hostPattern.equalsIgnoreCase( hostName ) || (hostPattern.startsWith( "." ) && hostName.endsWith( hostPattern )); |
From: Russell G. <rus...@us...> - 2004-09-24 20:13:25
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22211/doc Modified Files: release_notes.txt Log Message: patch #1026566 The Cookie class now implements hashCode properly. Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.373 retrieving revision 1.374 diff -u -r1.373 -r1.374 --- release_notes.txt 24 Sep 2004 19:13:36 -0000 1.373 +++ release_notes.txt 24 Sep 2004 20:13:16 -0000 1.374 @@ -14,8 +14,13 @@ Revision History: 24-Sep-2004: + Acknowledgements: + Thanks to Dave Brosius for adding hashCode to Cookie and QuerySpec + Problems fixed: 1. bug #1034067: ServletConfig.getServletName now returns the name specified in web.xml for registered servlets. + Additions: + 1. patch #1026566 The Cookie class now implements hashCode properly. 23-Sep-2004: Additions: |
From: Russell G. <rus...@us...> - 2004-09-24 19:14:16
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12266/doc Modified Files: release_notes.txt Log Message: bug #1034067: corrected ServletConfig.name initialization Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.372 retrieving revision 1.373 diff -u -r1.372 -r1.373 --- release_notes.txt 23 Sep 2004 22:48:19 -0000 1.372 +++ release_notes.txt 24 Sep 2004 19:13:36 -0000 1.373 @@ -13,6 +13,10 @@ Revision History: +24-Sep-2004: + Problems fixed: + 1. bug #1034067: ServletConfig.getServletName now returns the name specified in web.xml for registered servlets. + 23-Sep-2004: Additions: 1. ServletUnit now implements HttpSession.getServletContext(). |
From: Russell G. <rus...@us...> - 2004-09-24 19:13:55
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12266/test/com/meterware/servletunit Modified Files: WebXMLTest.java Log Message: bug #1034067: corrected ServletConfig.name initialization Index: WebXMLTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- WebXMLTest.java 26 Aug 2004 23:11:33 -0000 1.22 +++ WebXMLTest.java 24 Sep 2004 19:13:45 -0000 1.23 @@ -60,7 +60,7 @@ wxs.addServlet( "/SimpleServlet", SimpleGetServlet.class ); File webXml = createWebXml( wxs ); - ServletRunner sr = new ServletRunner( webXml.getAbsolutePath() ); + ServletRunner sr = new ServletRunner( webXml ); WebRequest request = new GetMethodWebRequest( "http://localhost/SimpleServlet" ); WebResponse response = sr.getResponse( request ); assertNotNull( "No response received", response ); @@ -126,6 +126,7 @@ ServletUnitClient client = sr.newClient(); InvocationContext ic = client.newInvocation( "http://localhost/SimpleServlet" ); ServletConfig servletConfig = ic.getServlet().getServletConfig(); + assertEquals( "Servlet name", "simple", servletConfig.getServletName() ); assertNull( "init parameter 'gender' should be null", servletConfig.getInitParameter( "gender" ) ); assertEquals( "init parameter via config", "red", ic.getServlet().getServletConfig().getInitParameter( "color" ) ); assertEquals( "init parameter directly", "12", ((HttpServlet) ic.getServlet()).getInitParameter( "age" ) ); |
From: Russell G. <rus...@us...> - 2004-09-24 19:13:55
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12266/src/com/meterware/servletunit Modified Files: ServletUnitServletConfig.java WebApplication.java Log Message: bug #1034067: corrected ServletConfig.name initialization Index: ServletUnitServletConfig.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletConfig.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ServletUnitServletConfig.java 19 Feb 2003 19:17:57 -0000 1.7 +++ ServletUnitServletConfig.java 24 Sep 2004 19:13:37 -0000 1.8 @@ -33,8 +33,8 @@ class ServletUnitServletConfig implements ServletConfig { - ServletUnitServletConfig( Servlet servlet, WebApplication application, Hashtable initParams ) { - _name = servlet.getClass().getName(); + ServletUnitServletConfig( String name, WebApplication application, Hashtable initParams ) { + _name = name; _initParameters = initParams; _context = application.getServletContext(); } Index: WebApplication.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- WebApplication.java 26 Aug 2004 23:11:33 -0000 1.24 +++ WebApplication.java 24 Sep 2004 19:13:45 -0000 1.25 @@ -573,7 +573,8 @@ if (_servlet == null) { Class servletClass = Class.forName( getClassName() ); _servlet = (Servlet) servletClass.newInstance(); - _servlet.init( new ServletUnitServletConfig( _servlet, WebApplication.this, getInitParams() ) ); + String servletName = _servletName != null ? _servletName : _servlet.getClass().getName(); + _servlet.init( new ServletUnitServletConfig( servletName, WebApplication.this, getInitParams() ) ); } return _servlet; |
From: Russell G. <rus...@us...> - 2004-09-24 02:24:29
|
Update of /cvsroot/httpunit/httpunit/doc/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12270 Modified Files: HttpUnit.jpg Log Message: Replace corrupted image Index: HttpUnit.jpg =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/images/HttpUnit.jpg,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 Binary files /tmp/cvshdKk36 and /tmp/cvsMQOp37 differ |
From: Russell G. <rus...@us...> - 2004-09-23 22:48:37
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3794/test/com/meterware/servletunit Modified Files: ConfigTest.java HttpServletRequestTest.java ServletAccessTest.java SessionTest.java Log Message: Implemented HttpSession.getServletContext() Index: ConfigTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ConfigTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ConfigTest.java 3 Mar 2004 01:12:51 -0000 1.5 +++ ConfigTest.java 23 Sep 2004 22:48:20 -0000 1.6 @@ -101,6 +101,16 @@ } + public void testServletContextAccess() throws Exception { + ServletRunner sr = new ServletRunner(); + sr.registerServlet( "SimpleServlet", ConfigServlet.class.getName() ); + ServletUnitClient client = sr.newClient(); + InvocationContext ic = client.newInvocation( "http://localhost/SimpleServlet" ); + ServletContext context = ic.getServlet().getServletConfig().getServletContext(); + assertSame( "Context from session", context, ic.getRequest().getSession().getServletContext() ); + } + + private void checkMimeType( ServletContext context, String fileName, String expectedMimeType ) { assertEquals( "mime type for " + fileName, expectedMimeType, context.getMimeType( fileName ) ); } Index: HttpServletRequestTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- HttpServletRequestTest.java 8 Aug 2004 17:41:11 -0000 1.23 +++ HttpServletRequestTest.java 23 Sep 2004 22:48:20 -0000 1.24 @@ -46,6 +46,9 @@ **/ public class HttpServletRequestTest extends ServletUnitTest { + private ServletUnitContext _context; + + public static void main(String args[]) { junit.textui.TestRunner.run( suite() ); } @@ -61,10 +64,23 @@ } + protected void setUp() throws Exception { + super.setUp(); + _context = new ServletUnitContext( null, null, new SessionListenerDispatcher() { + public void sendSessionCreated( HttpSession session ) {} + public void sendSessionDestroyed( HttpSession session ) {} + public void sendAttributeAdded( HttpSession session, String name, Object value ) {} + public void sendAttributeReplaced( HttpSession session, String name, Object oldValue ) {} + public void sendAttributeRemoved( HttpSession session, String name, Object oldValue ) {} + } ); + + } + + public void testHeaderAccess() throws Exception { 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertEquals( "sample header value", "value", request.getHeader( "sample") ); assertContains( "Header names", "sample", request.getHeaderNames() ); @@ -87,7 +103,7 @@ public void testGetDefaultProperties() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertNull( "Authorization incorrectly specified", request.getAuthType() ); assertNull( "Character encoding incorrectly specified", request.getCharacterEncoding() ); assertEquals( "Parameters unexpectedly specified", "", request.getQueryString() ); @@ -99,7 +115,7 @@ 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertEquals( "age parameter", "12", request.getParameter( "age" ) ); assertNull( "unset parameter should be null", request.getParameter( "unset" ) ); @@ -110,7 +126,7 @@ 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) ); assertMatchingSet( "color parameter", new String[] { "red", "blue" }, request.getParameterValues( "color" ) ); @@ -122,7 +138,7 @@ 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); Map map = request.getParameterMap(); assertMatchingSet( "age parameter", new String[] { "12" }, (Object[]) map.get( "age" ) ); @@ -135,7 +151,7 @@ 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertEquals( "query string", "color=red&color=blue&age=12", request.getQueryString() ); } @@ -143,7 +159,7 @@ public void testInlineSingleValuedParameter() throws Exception { 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertEquals( "age parameter", "12", request.getParameter( "age" ) ); assertNull( "unset parameter should be null", request.getParameter( "unset" ) ); @@ -152,7 +168,7 @@ public void testInlineMultiValuedParameter() throws Exception { 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) ); assertMatchingSet( "color parameter", new String[] { "red", "blue" }, request.getParameterValues( "color" ) ); @@ -162,7 +178,7 @@ 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 ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertEquals( "query string", "color=red&color=blue&age=12", request.getQueryString() ); } @@ -172,7 +188,7 @@ 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() ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), body.getBytes() ); assertEquals( "Request content length", body.length(), request.getContentLength() ); BufferedInputStream bis = new BufferedInputStream( request.getInputStream() ); @@ -184,7 +200,7 @@ public void testDefaultAttributes() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertNull( "attribute should not be defined yet", request.getAttribute( "unset" ) ); assertTrue( "attribute enumeration should be empty", !request.getAttributeNames().hasMoreElements() ); @@ -193,7 +209,7 @@ public void testNonDefaultAttributes() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); Object value = new Integer(1); request.setAttribute( "one", value ); @@ -209,7 +225,7 @@ public void testDuplicateAttributes() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); request.setAttribute( "one", new Integer(1) ); request.setAttribute( "one", "One" ); @@ -219,7 +235,7 @@ public void testNullAttributeValue() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); request.setAttribute( "one", "One" ); assertEquals( "Initial attribute value", "One", request.getAttribute( "one" ) ); @@ -230,7 +246,7 @@ public void testDefaultCookies() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); Cookie[] cookies = request.getCookies(); assertNull( "Unexpected cookies found", cookies ); } @@ -239,7 +255,7 @@ public void testSetCookieViaRequestHeader() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); wr.setHeaderField( "Cookie", "flavor=vanilla,variety=sandwich"); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); Cookie[] cookies = request.getCookies(); assertNotNull( "No cookies found", cookies ); @@ -253,7 +269,7 @@ public void testGetSessionForFirstTime() throws MalformedURLException { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); - ServletUnitContext context = new ServletUnitContext(); + ServletUnitContext context = _context; assertEquals( "Initial number of sessions in context", 0, context.getSessionIDs().size() ); ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); @@ -275,7 +291,7 @@ * will cause a session to be made available. */ public void testRetrieveSession() throws Exception { - ServletUnitContext context = new ServletUnitContext(); + ServletUnitContext context = _context; final ServletUnitHttpSession session = context.newSession(); final String sessionID = session.getId(); @@ -291,7 +307,7 @@ public void testAccessForbiddenToInvalidSession() throws Exception { - ServletUnitContext context = new ServletUnitContext(); + ServletUnitContext context = _context; HttpSession session = context.newSession(); session.setAttribute( "Initial", new Integer( 1 ) ); @@ -321,7 +337,7 @@ * Obtains a new session, invalidates it, and verifies that */ public void testSessionInvalidation() throws Exception { - ServletUnitContext context = new ServletUnitContext(); + ServletUnitContext context = _context; HttpSession originalSession = context.newSession(); String originalID = originalSession.getId(); @@ -350,7 +366,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 { - ServletUnitContext context = new ServletUnitContext(); + ServletUnitContext context = _context; HttpSession originalSession = context.newSession(); String originalID = originalSession.getId(); @@ -370,7 +386,7 @@ public void testGetRequestURI() throws Exception { - ServletUnitContext context = new ServletUnitContext(); + ServletUnitContext context = _context; WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" ); ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY ); @@ -387,7 +403,7 @@ public void testDefaultLocale() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple"); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); Locale[] expectedLocales = new Locale[] { Locale.getDefault() }; verifyLocales( request, expectedLocales ); @@ -396,11 +412,11 @@ public void testSecureProperty() throws Exception { WebRequest wr = new GetMethodWebRequest( "http://localhost/simple"); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); assertFalse( "Incorrectly noted request as secure", request.isSecure() ); WebRequest secureReq = new GetMethodWebRequest( "https://localhost/simple"); - request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, secureReq, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, secureReq, _context, new Hashtable(), NO_MESSAGE_BODY ); assertTrue( "Request not marked as secure", request.isSecure() ); } @@ -423,7 +439,7 @@ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple"); wr.setHeaderField( "Accept-language", "fr, en;q=0.6, en-us;q=0.7" ); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY ); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), NO_MESSAGE_BODY ); verifyLocales( request, new Locale[] { Locale.FRENCH, Locale.US, Locale.ENGLISH } ); } @@ -433,7 +449,7 @@ String paramString = "param1=red¶m2=" + hebrewValue; WebRequest wr = new PostMethodWebRequest( "http://localhost/simple" ); wr.setHeaderField( "Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-8" ); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), paramString.getBytes( "ISO-8859-8" ) ); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), paramString.getBytes( "ISO-8859-8" ) ); assertEquals( "param1 value", "red", request.getParameter( "param1") ); assertEquals( "param2 value", hebrewValue, request.getParameter( "param2") ); } @@ -443,7 +459,7 @@ String hebrewValue = "\u05d0\u05d1\u05d2\u05d3"; String paramString = "param1=red¶m2=" + hebrewValue; WebRequest wr = new PostMethodWebRequest( "http://localhost/simple" ); - ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), paramString.getBytes( "ISO-8859-8" ) ); + ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, _context, new Hashtable(), paramString.getBytes( "ISO-8859-8" ) ); request.setCharacterEncoding( "ISO-8859-8" ); assertEquals( "param1 value", "red", request.getParameter( "param1") ); assertEquals( "param2 value", hebrewValue, request.getParameter( "param2") ); Index: ServletAccessTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ServletAccessTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServletAccessTest.java 20 Aug 2003 12:06:15 -0000 1.2 +++ ServletAccessTest.java 23 Sep 2004 22:48:20 -0000 1.3 @@ -1,9 +1,8 @@ package com.meterware.servletunit; - /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2001, Russell Gold + * Copyright (c) 2001-2004, 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 @@ -27,7 +26,7 @@ /** * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ public class ServletAccessTest extends ServletTestCase { Index: SessionTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/SessionTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SessionTest.java 3 Mar 2004 01:12:51 -0000 1.5 +++ SessionTest.java 23 Sep 2004 22:48:20 -0000 1.6 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000, Russell Gold +* Copyright (c) 2000-2004, 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 @@ -22,12 +22,19 @@ import junit.framework.Test; import junit.framework.TestSuite; +import javax.servlet.http.HttpSession; +import javax.servlet.ServletContext; + /** * Tests the HttpSession implementation. **/ public class SessionTest extends ServletUnitTest { + private ServletUnitContext _context; + private ServletContext _servletContext = new ServletUnitServletContext( null ); + + public static void main(String args[]) { junit.textui.TestRunner.run( suite() ); } @@ -43,40 +50,49 @@ } + protected void setUp() throws Exception { + super.setUp(); + _context = new ServletUnitContext( null, _servletContext, new SessionListenerDispatcher() { + public void sendSessionCreated( HttpSession session ) {} + public void sendSessionDestroyed( HttpSession session ) {} + public void sendAttributeAdded( HttpSession session, String name, Object value ) {} + public void sendAttributeReplaced( HttpSession session, String name, Object oldValue ) {} + public void sendAttributeRemoved( HttpSession session, String name, Object oldValue ) {} + } ); + + } + + public void testNoInitialState() throws Exception { - ServletUnitContext context = new ServletUnitContext(); - assertNull( "Session with incorrect ID", context.getSession( "12345" ) ); + assertNull( "Session with incorrect ID", _context.getSession( "12345" ) ); } public void testCreateSession() throws Exception { - ServletUnitContext context = new ServletUnitContext(); - ServletUnitHttpSession session = context.newSession(); + ServletUnitHttpSession session = _context.newSession(); assertNotNull( "Session is null", session ); assertTrue( "Session is not marked as new", session.isNew() ); - ServletUnitHttpSession session2 = context.newSession(); + ServletUnitHttpSession session2 = _context.newSession(); assertTrue( "New session has the same ID", !session.getId().equals( session2.getId() ) ); - assertTrue( "Different session returned", session.equals( context.getSession( session.getId() ) ) ); + assertTrue( "Different session returned", session.equals( _context.getSession( session.getId() ) ) ); } public void testSessionState() throws Exception { - ServletUnitContext context = new ServletUnitContext(); - ServletUnitHttpSession session = context.newSession(); + ServletUnitHttpSession session = _context.newSession(); long accessedAt = session.getLastAccessedTime(); assertTrue( "Session is not marked as new", session.isNew() ); try { Thread.sleep( 50 ); } catch (InterruptedException e) {}; - assertEquals( "Initial access time", accessedAt, context.getSession( session.getId() ).getLastAccessedTime() ); + assertEquals( "Initial access time", accessedAt, _context.getSession( session.getId() ).getLastAccessedTime() ); session.access(); - assertTrue( "Last access time not changed", accessedAt != context.getSession( session.getId() ).getLastAccessedTime() ); - assertTrue( "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() ); } public void testSessionAttributes() throws Exception { - ServletUnitContext context = new ServletUnitContext(); - ServletUnitHttpSession session = context.newSession(); + ServletUnitHttpSession session = _context.newSession(); session.setAttribute( "first", new Integer(1) ); session.setAttribute( "second", "two" ); session.setAttribute( "third", "III" ); @@ -89,6 +105,13 @@ } + public void testSessionContext() throws Exception { + ServletUnitHttpSession session = _context.newSession(); + assertNotNull( "No context returned", session.getServletContext() ); + assertSame( "Owning context", _servletContext, session.getServletContext() ); + } + + } |
From: Russell G. <rus...@us...> - 2004-09-23 22:48:37
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3794/src/com/meterware/servletunit Modified Files: ServletRunner.java ServletUnitContext.java ServletUnitHttpSession.java SessionListenerDispatcher.java Log Message: Implemented HttpSession.getServletContext() Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- ServletRunner.java 22 Sep 2004 03:15:22 -0000 1.28 +++ ServletRunner.java 23 Sep 2004 22:48:19 -0000 1.29 @@ -130,7 +130,7 @@ private void completeInitialization( String contextPath ) { - _context = new ServletUnitContext( contextPath, _application ); + _context = new ServletUnitContext( contextPath, _application.getServletContext(), _application ); _application.registerServlet( "*.jsp", _jspServletDescriptor.getClassName(), _jspServletDescriptor.getInitializationParameters( null, null ) ); } Index: ServletUnitContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitContext.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ServletUnitContext.java 9 Sep 2004 00:16:40 -0000 1.8 +++ ServletUnitContext.java 23 Sep 2004 22:48:19 -0000 1.9 @@ -19,29 +19,18 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ - - -import javax.servlet.http.HttpSession; +import javax.servlet.ServletContext; import java.util.*; import java.util.Hashtable; class ServletUnitContext { private SessionListenerDispatcher _listenerDispatcher; + private ServletContext _servletContext; - ServletUnitContext() { - this( null, new SessionListenerDispatcher() { - public void sendSessionCreated( HttpSession session ) {} - public void sendSessionDestroyed( HttpSession session ) {} - public void sendAttributeAdded( HttpSession session, String name, Object value ) {} - public void sendAttributeReplaced( HttpSession session, String name, Object oldValue ) {} - public void sendAttributeRemoved( HttpSession session, String name, Object oldValue ) {} - } ); - } - - - ServletUnitContext( String contextPath, SessionListenerDispatcher dispatcher ) { + ServletUnitContext( String contextPath, ServletContext servletContext, SessionListenerDispatcher dispatcher ) { + _servletContext = servletContext; _contextPath = (contextPath != null ? contextPath : ""); _listenerDispatcher = dispatcher; } @@ -87,7 +76,7 @@ * Creates a new session with a unique ID. **/ ServletUnitHttpSession newSession() { - ServletUnitHttpSession result = new ServletUnitHttpSession( _listenerDispatcher ); + ServletUnitHttpSession result = new ServletUnitHttpSession( _servletContext, _listenerDispatcher ); _sessions.put( result.getId(), result ); _listenerDispatcher.sendSessionCreated( result ); return result; Index: ServletUnitHttpSession.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpSession.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ServletUnitHttpSession.java 3 Mar 2004 01:12:51 -0000 1.11 +++ ServletUnitHttpSession.java 23 Sep 2004 22:48:19 -0000 1.12 @@ -35,10 +35,12 @@ final static public String SESSION_COOKIE_NAME = "JSESSION"; + private ServletContext _servletContext; private SessionListenerDispatcher _listenerDispatcher; - public ServletUnitHttpSession( SessionListenerDispatcher listenerDispatcher ) { + ServletUnitHttpSession( ServletContext servletContext, SessionListenerDispatcher listenerDispatcher ) { + _servletContext = servletContext; _listenerDispatcher = listenerDispatcher; } @@ -221,7 +223,7 @@ * @since 1.3 **/ public ServletContext getServletContext() { - return null; // XXX implement me + return _servletContext; } //-------------------------------------------- package members ------------------------------------------------- Index: SessionListenerDispatcher.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/SessionListenerDispatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SessionListenerDispatcher.java 15 Feb 2004 06:42:01 -0000 1.2 +++ SessionListenerDispatcher.java 23 Sep 2004 22:48:19 -0000 1.3 @@ -1,7 +1,4 @@ package com.meterware.servletunit; - -import javax.servlet.http.HttpSession; - /******************************************************************************************************************** * $Id$ * @@ -22,6 +19,7 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import javax.servlet.http.HttpSession; /** * |
From: Russell G. <rus...@us...> - 2004-09-23 22:48:37
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3794/doc Modified Files: release_notes.txt Log Message: Implemented HttpSession.getServletContext() Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.371 retrieving revision 1.372 diff -u -r1.371 -r1.372 --- release_notes.txt 22 Sep 2004 02:19:49 -0000 1.371 +++ release_notes.txt 23 Sep 2004 22:48:19 -0000 1.372 @@ -13,6 +13,10 @@ Revision History: +23-Sep-2004: + Additions: + 1. ServletUnit now implements HttpSession.getServletContext(). + 21-Sep-2004: Acknowledgements: Thanks to Bart Vanhaute for finding a fixing an infinite recursion problem with frame loading. |
From: Russell G. <rus...@us...> - 2004-09-22 03:15:33
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1617/sitedocs/doc Modified Files: faq.xml Log Message: faq and javascript additions Index: faq.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/faq.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- faq.xml 4 Jun 2004 01:20:03 -0000 1.7 +++ faq.xml 22 Sep 2004 03:15:21 -0000 1.8 @@ -28,7 +28,10 @@ <faq id="proxy"> <question>Can I use HttpUnit through a proxy server?</question> <answer><![CDATA[Yes. Call <a href="api/com/meterware/httpunit/WebClient.html#setProxyServer(java.lang.String, int)"> - <code>WebClient.setProxyServer( host, port )</code></a>before sending your request.]]></answer> + <code>WebClient.setProxyServer( host, port )</code></a>before sending your request, or if you + need to specify a username and password, call + <a href="api/com/meterware/httpunit/WebClient.html#setProxyServer(java.lang.String, int, java.lang.String, java.lang.String)"> + <code>WebClient.setProxyServer( host, port, username, password )</code></a>.]]></answer> </faq> <faq id="masquerade"> <question>How can I handle certificates from a test machine?</question> @@ -123,6 +126,18 @@ </faq> </section> + + <section title="Links and Images"> + <faq id="image links"> + <question>How do I find a link for a given image?</question> + <answer><![CDATA[It is not uncommon to encounter a structure such as + <a href="something"><img src=blah name=my_image></a>. The find this link, the first step + is to find the image, for which a number of methods are defined, allowing images to be found based on name, + src attribute, id, or alt text. Given the image, the link is easily obtained by calling + <a href="api/com/meterware/httpunit/WebImage.html#getLink()"><code>image.getLink()</code></a>]]></answer> + </faq> + </section> + <section title="JavaScript support"> <faq id="javascript"> <question>How do I use HttpUnit to test my pages that use JavaScript?</question> @@ -144,6 +159,30 @@ Rhino unfortunately does not provide a very helpful error message in such cases. Try removing statements from the function until you find out which one is causing the problem and then submit a request for the offending construct to be supported.</answer> </faq> + <faq id="alerts"> + <question>How do I test JavaScript alert boxes?</question> + <answer><![CDATA[HttpUnit automatically acts as though you have clicked the OK button and queues up a list of messages generated by + calls to the alert() function. You can see the messages by making successive calls to + <a href="api/com/meterware/httpunit/WebClient.html#popNextAlert()"><code>client.popNextAlert()</code></a>. + each of which will return the next alert message and remove it from the queue. You can at any time + call <a href="api/com/meterware/httpunit/WebClient.html#getNextAlert()"><code>client.getNextAlert()</code></a> + to see the next message without removing it. If there are no messages left in the queue, these methods + simply return an empty string.]]></answer> + </faq> + <faq id="dialogs"> + <question>How do I test JavaScript popup dialogs?</question> + <answer><![CDATA[You can register a <a href="api/com/meterware/httpunit/DialogResponder.html"><code>DialogResponder</code></a> + by calling <a href="api/com/meterware/httpunit/WebClient.html#setDialogResponder(DialogResponder)"> + <code>client.setDialogResponder( responder )</code></a>, specifying an object which should be invoked + whenever JavaScript code invokes a <code>prompt()</code> or <code>confirm()</code> function. The <code>DialogResponder</code> + interface has two methods. When a <code>confirm()</code> function is encountered, HttpUnit will invoke the + <a href="api/com/meterware/httpunit/DialogResponder.html#getConfirmation(java.lang.String)"><code>getConfirmation</code></a> + method, passing the prompt as a parameter. The method should return <code>true</code> to indicate the clicking of the OK + button or <code>false</code> to indicate that the CANCEL button was clicked.<p> + When a <code>prompt()</code> function is encountered, HttpUnit will invoke the + <a href="api/com/meterware/httpunit/DialogResponder.html#getUserResponse(java.lang.String, java.lang.String)"><code>getUserResponse</code></a> + method, passing the prompt and default response. The method should return the response appropriate for the test.]]></answer> + </faq> <faq id="unsupported"> <question>How do I handle a page that uses JavaScript features that HttpUnit does not support?</question> <answer><![CDATA[If you call |
From: Russell G. <rus...@us...> - 2004-09-22 03:15:33
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1617/src/com/meterware/servletunit Modified Files: ServletRunner.java Log Message: faq and javascript additions Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- ServletRunner.java 9 Sep 2004 00:16:40 -0000 1.27 +++ ServletRunner.java 22 Sep 2004 03:15:22 -0000 1.28 @@ -55,7 +55,7 @@ /** * Constructor which expects the full path to the web.xml for the * application. - * @deprecated as of 1.5.5, use {@link ServletRunner(File)} + * @deprecated as of 1.5.5, use {@link #ServletRunner(File)} * * @param webXMLFileSpec the full path to the web.xml file */ @@ -68,7 +68,7 @@ /** * Constructor which expects the full path to the web.xml for the * application and a context path under which to mount it. - * @deprecated as of 1.5.5, use {@link ServletRunner(File,String)} + * @deprecated as of 1.5.5, use {@link #ServletRunner(File,String)} * * @param webXMLFileSpec the full path to the web.xml file * @param contextPath the context path |
From: Russell G. <rus...@us...> - 2004-09-22 03:15:33
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1617/src/com/meterware/httpunit Modified Files: ParameterHolder.java ParsedHTML.java WebForm.java Log Message: faq and javascript additions Index: ParameterHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParameterHolder.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ParameterHolder.java 10 Aug 2004 20:28:52 -0000 1.8 +++ ParameterHolder.java 22 Sep 2004 03:15:22 -0000 1.9 @@ -88,16 +88,6 @@ /** - * Sets the single value of a file upload parameter in a form. - * A more convenient way to do this than using {@link #setParameter(String,UploadFileSpec[])} - * @since 1.5.5 - */ - public void setParameter( String name, File file ) { - setParameter( name, new UploadFileSpec[] { new UploadFileSpec( file ) } ); - } - - - /** * Sets the multiple values of a file upload parameter in a web request. **/ abstract Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- ParsedHTML.java 8 Aug 2004 17:45:31 -0000 1.59 +++ ParsedHTML.java 22 Sep 2004 03:15:22 -0000 1.60 @@ -148,7 +148,6 @@ /** * Returns the top-level block elements found in the page in the order in which they appear. - * @return */ public TextBlock[] getTextBlocks() { if (_blocks == null) { Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- WebForm.java 12 Sep 2004 03:31:58 -0000 1.98 +++ WebForm.java 22 Sep 2004 03:15:22 -0000 1.99 @@ -585,16 +585,6 @@ /** - * Sets the multiple values of a file upload parameter in a web request. - **/ - public void setParameter( String name, UploadFileSpec[] files ) { - FormParameter parameter = getParameter( name ); - if (parameter == null) throw new NoSuchParameterException( name ); - parameter.setFiles( files ); - } - - - /** * Sets the value of a parameter in this form. **/ public void setParameter( String name, String value ) { @@ -602,6 +592,10 @@ } + /** + * Sets the multiple values of a parameter in this form. This is generally used when there are multiple + * controls with the same name in the form. + */ public void setParameter( String name, final String[] values ) { FormParameter parameter = getParameter( name ); if (parameter == UNKNOWN_PARAMETER) throw new NoSuchParameterException( name ); @@ -610,6 +604,26 @@ /** + * Sets the multiple values of a file upload parameter in a web request. + **/ + public void setParameter( String name, UploadFileSpec[] files ) { + FormParameter parameter = getParameter( name ); + if (parameter == null) throw new NoSuchParameterException( name ); + parameter.setFiles( files ); + } + + + /** + * Sets the single value of a file upload parameter in this form. + * A more convenient way to do this than using {@link #setParameter(String,UploadFileSpec[])} + * @since 1.5.5 + */ + public void setParameter( String name, File file ) { + setParameter( name, new UploadFileSpec[] { new UploadFileSpec( file ) } ); + } + + + /** * Toggles the value of the specified checkbox parameter. * @param name the name of the checkbox parameter * @throws IllegalArgumentException if the specified parameter is not a checkbox or there is more than one |
From: Russell G. <rus...@us...> - 2004-09-22 02:19:59
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23398/src/com/meterware/httpunit Modified Files: FrameHolder.java Log Message: from Bart Vanhaute: fixed bug #1029139: infinite recursion in frameset page when a frame has src='#' Index: FrameHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- FrameHolder.java 8 Aug 2004 17:38:18 -0000 1.12 +++ FrameHolder.java 22 Sep 2004 02:19:49 -0000 1.13 @@ -180,7 +180,11 @@ HttpUnitOptions.getScriptingEngine().associate( response ); createSubFrames( frame, response.getFrameSelectors() ); WebRequest[] requests = response.getFrameRequests(); - for (int i = 0; i < requests.length; i++) response.getWindow().getSubframeResponse( requests[ i ], requestContext ); + for (int i = 0; i < requests.length; i++) { + if (requests[i].getURLString().length() != 0) { + response.getWindow().getSubframeResponse( requests[i], requestContext ); + } + } HttpUnitOptions.getScriptingEngine().load( response ); } } |
From: Russell G. <rus...@us...> - 2004-09-22 02:19:59
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23398/doc Modified Files: release_notes.txt Log Message: from Bart Vanhaute: fixed bug #1029139: infinite recursion in frameset page when a frame has src='#' Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.370 retrieving revision 1.371 diff -u -r1.370 -r1.371 --- release_notes.txt 22 Sep 2004 02:02:09 -0000 1.370 +++ release_notes.txt 22 Sep 2004 02:19:49 -0000 1.371 @@ -14,8 +14,13 @@ Revision History: 21-Sep-2004: + Acknowledgements: + Thanks to Bart Vanhaute for finding a fixing an infinite recursion problem with frame loading. + Problems fixed: 1. Proxy server settings no longer apply to the entire VM; however, accessing a proxy server is not thread-safe + 2. bug #1029139: infinite recursion in frameset page when a frame has src="#" + Additions: 1. A username and password may now be specified when accessing a proxy server. |
From: Russell G. <rus...@us...> - 2004-09-22 02:19:59
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23398/test/com/meterware/httpunit Modified Files: WebFrameTest.java Log Message: from Bart Vanhaute: fixed bug #1029139: infinite recursion in frameset page when a frame has src='#' Index: WebFrameTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- WebFrameTest.java 11 Jul 2004 02:38:34 -0000 1.20 +++ WebFrameTest.java 22 Sep 2004 02:19:49 -0000 1.21 @@ -467,5 +467,24 @@ } + + /** + * Verifies that an open call from a subframe can specify another frame name. + */ + public void testFrameWithHashSource() throws Exception { + defineResource( "Frames.html", + "<html><head><frameset>" + + " <frame name='banner' src='#'>" + + " <frame name='main' src='main.html'>" + + "</frameset></html>" ); + defineResource( "target.txt", "You made it!" ); + defineWebPage( "main", "<a id='banner' href='target.txt'>banner</a>" ); + + _wc.getResponse( getHostPath() + "/Frames.html" ); + WebLink link = (WebLink) _wc.getFrameContents( "main" ).getElementWithID( "banner" ); + assertNotNull( "No link found", link ); + } + + private WebConversation _wc; } |
From: Russell G. <rus...@us...> - 2004-09-22 02:02:19
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20540/doc Modified Files: release_notes.txt Log Message: Added authentication option for proxy server access Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.369 retrieving revision 1.370 diff -u -r1.369 -r1.370 --- release_notes.txt 12 Sep 2004 06:08:23 -0000 1.369 +++ release_notes.txt 22 Sep 2004 02:02:09 -0000 1.370 @@ -13,6 +13,12 @@ Revision History: +21-Sep-2004: + Problems fixed: + 1. Proxy server settings no longer apply to the entire VM; however, accessing a proxy server is not thread-safe + Additions: + 1. A username and password may now be specified when accessing a proxy server. + 12-Sep-2004: Problems fixed: 1. bug #1025968: Cookies with max-age attribute will now expire (max-age=0 is treated as immediate expiration) |
From: Russell G. <rus...@us...> - 2004-09-22 02:02:18
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20540/src/com/meterware/httpunit Modified Files: WebClient.java WebConversation.java Log Message: Added authentication option for proxy server access Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- WebClient.java 28 Jul 2004 09:02:25 -0000 1.60 +++ WebClient.java 22 Sep 2004 02:02:09 -0000 1.61 @@ -50,6 +50,7 @@ /** The current main window. **/ private WebWindow _mainWindow = new WebWindow( this ); private String _authorizationString; + private String _proxyAuthorizationString; public WebWindow getMainWindow() { @@ -225,25 +226,29 @@ **/ public void setAuthorization( String userName, String password ) { _authorizationString = "Basic " + Base64.encode( userName + ':' + password ); - setHeaderField( "Authorization", _authorizationString ); } /** - * Specifies a proxy server to use. Note that at present this is global to all web clients in the VM. + * Specifies a proxy server to use for requests from this client. */ public void setProxyServer( String proxyHost, int proxyPort ) { - System.setProperty( "proxyHost", proxyHost ); - System.setProperty( "proxyPort", Integer.toString( proxyPort ) ); } /** - * Clears the proxy server settings. Note that at present this is global to all web clients in the VM. + * Specifies a proxy server to use, along with a user and password for authentication. + */ + public void setProxyServer( String proxyHost, int proxyPort, String userName, String password ) { + setProxyServer( proxyHost, proxyPort ); + _proxyAuthorizationString = "Basic " + Base64.encode( userName + ':' + password ); + } + + + /** + * Clears the proxy server settings. */ public void clearProxyServer() { - System.getProperties().remove( "proxyHost" ); - System.getProperties().remove( "proxyPort" ); } @@ -402,7 +407,8 @@ result.put( "User-Agent", getClientProperties().getUserAgent() ); if (getClientProperties().isAcceptGzip()) result.put( "Accept-Encoding", "gzip" ); AddHeaderIfNotNull( result, "Cookie", _cookieJar.getCookieHeaderField( targetURL ) ); - AddHeaderIfNotNull( result, getAuthorizationHeaderName(), _authorizationString ); + AddHeaderIfNotNull( result, "Authorization", _authorizationString ); + AddHeaderIfNotNull( result, "Proxy-Authorization", _proxyAuthorizationString ); return result; } @@ -412,11 +418,6 @@ } - private String getAuthorizationHeaderName() { - return getProxyHost() != null ? "Proxy-Authorization" : "Authorization"; - } - - /** * Updates this web client based on a received response. This includes updating * cookies and frames. This method is required by ServletUnit, which cannot call the updateWindow method directly. Index: WebConversation.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- WebConversation.java 5 Jul 2004 15:25:51 -0000 1.37 +++ WebConversation.java 22 Sep 2004 02:02:09 -0000 1.38 @@ -28,6 +28,7 @@ import java.util.Dictionary; import java.util.Enumeration; +import java.util.Properties; /** @@ -39,6 +40,9 @@ **/ public class WebConversation extends WebClient { + private String _proxyHost; + private int _proxyPort; + /** * Creates a new web conversation. @@ -54,16 +58,36 @@ * Creates a web response object which represents the response to the specified web request. **/ protected WebResponse newResponse( WebRequest request, FrameSelector targetFrame ) throws MalformedURLException, IOException { - URLConnection connection = openConnection( getRequestURL( request ) ); - if (HttpUnitOptions.isLoggingHttpHeaders()) { - String urlString = request.getURLString(); - System.out.println( "\nConnecting to " + request.getURL().getHost() ); - System.out.println( "Sending:: " + request.getMethod() + " " + urlString ); + Properties savedProperties = (Properties) System.getProperties().clone(); + try { + if (_proxyHost != null) { + System.setProperty( "proxyHost", _proxyHost ); + System.setProperty( "proxyPort", Integer.toString( _proxyPort ) ); + } + URLConnection connection = openConnection( getRequestURL( request ) ); + if (HttpUnitOptions.isLoggingHttpHeaders()) { + String urlString = request.getURLString(); + System.out.println( "\nConnecting to " + request.getURL().getHost() ); + System.out.println( "Sending:: " + request.getMethod() + " " + urlString ); + } + sendHeaders( connection, getHeaderFields( request.getURL() ) ); + sendHeaders( connection, request.getHeaderDictionary() ); + request.completeRequest( connection ); + return new HttpWebResponse( this, targetFrame, request, connection, getExceptionsThrownOnErrorStatus() ); + } finally { + System.setProperties( savedProperties ); } - sendHeaders( connection, getHeaderFields( request.getURL() ) ); - sendHeaders( connection, request.getHeaderDictionary() ); - request.completeRequest( connection ); - return new HttpWebResponse( this, targetFrame, request, connection, getExceptionsThrownOnErrorStatus() ); + } + + + public void clearProxyServer() { + _proxyHost = null; + } + + + public void setProxyServer( String proxyHost, int proxyPort ) { + _proxyHost = proxyHost; + _proxyPort = proxyPort; } @@ -96,7 +120,11 @@ String key = (String) e.nextElement(); connection.setRequestProperty( key, (String) headers.get( key ) ); if (HttpUnitOptions.isLoggingHttpHeaders()) { - System.out.println( "Sending:: " + key + ": " + connection.getRequestProperty( key ) ); + if (key.equalsIgnoreCase( "authorization" ) || key.equalsIgnoreCase( "proxy-authorization") ) { + System.out.println( "Sending:: " + key + ": " + headers.get( key ) ); + } else { + System.out.println( "Sending:: " + key + ": " + connection.getRequestProperty( key ) ); + } } } } |
From: Russell G. <rus...@us...> - 2004-09-22 02:02:18
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20540/test/com/meterware/httpunit Modified Files: WebClientTest.java Log Message: Added authentication option for proxy server access Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- WebClientTest.java 28 Jul 2004 09:02:26 -0000 1.21 +++ WebClientTest.java 22 Sep 2004 02:02:10 -0000 1.22 @@ -53,7 +53,7 @@ super( name ); } - public void testNoSuchServer() throws Exception { + public void ntestNoSuchServer() throws Exception { WebConversation wc = new WebConversation(); try { @@ -245,6 +245,33 @@ } + public void testBasicAuthentication() throws Exception { + defineResource( "getAuthorization", new PseudoServlet() { + public WebResource getGetResponse() { + return new WebResource( getHeader( "Authorization" ), "text/plain" ); + } + } ); + + WebConversation wc = new WebConversation(); + wc.setAuthorization( "user", "password" ); + WebResponse wr = wc.getResponse( getHostPath() + "/getAuthorization" ); + assertEquals( "authorization", "Basic dXNlcjpwYXNzd29yZA==", wr.getText() ); + } + + + public void testProxyServerAccessWithAuthentication() throws Exception { + defineResource( "http://someserver.com/sample", new PseudoServlet() { + public WebResource getGetResponse() { + return new WebResource( getHeader( "Proxy-Authorization" ), "text/plain" ); + } + } ); + WebConversation wc = new WebConversation(); + wc.setProxyServer( "localhost", getHostPort(), "user", "password" ); + WebResponse wr = wc.getResponse( "http://someserver.com/sample" ); + assertEquals( "authorization", "Basic dXNlcjpwYXNzd29yZA==", wr.getText() ); + } + + public void testRefererHeader() throws Exception { String resourceName = "tellMe"; String linkSource = "fromLink"; |
From: Russell G. <rus...@us...> - 2004-09-12 06:08:33
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22576/test/com/meterware/httpunit/cookies Modified Files: CookieTest.java Log Message: bug #1025968: cookies with max-age set now expire as appropriate Index: CookieTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- CookieTest.java 28 Jul 2004 09:02:27 -0000 1.10 +++ CookieTest.java 12 Sep 2004 06:08:23 -0000 1.11 @@ -157,8 +157,8 @@ public void testHeaderGeneration() throws Exception { CookieJar jar = new CookieJar(); jar.putCookie( "zero", "nil" ); - jar.updateCookies( newJar( "www.meterware.com/servlets/standard/AServlet", "first=ready" ) ); - jar.updateCookies( newJar( "www.meterware.com/servlets/AnotherServlet", "second=set" ) ); + jar.updateCookies( newJar( "www.meterware.com/servlets/standard/AServlet", "first=ready, gone=expired;max-age=0" ) ); + jar.updateCookies( newJar( "www.meterware.com/servlets/AnotherServlet", "second=set;max-age=1000" ) ); jar.updateCookies( newJar( "www.httpunit.org", "zero=go; domain=.httpunit.org" ) ); jar.updateCookies( newJar( "meterware.com", "fourth=money" ) ); @@ -167,7 +167,7 @@ checkHeader( 3, jar, "zero=go", "fancy.httpunit.org/servlets/AskMe" ); HttpUserAgentTest.assertMatchingSet( "Cookie names", - new String[] { "zero", "zero", "first", "second", "fourth" }, + new String[] { "zero", "zero", "first", "second", "fourth", "gone" }, jar.getCookieNames() ); } |
From: Russell G. <rus...@us...> - 2004-09-12 06:08:33
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22576/src/com/meterware/httpunit/cookies Modified Files: Cookie.java Log Message: bug #1025968: cookies with max-age set now expire as appropriate Index: Cookie.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/Cookie.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Cookie.java 17 Jun 2003 11:08:25 -0000 1.4 +++ Cookie.java 12 Sep 2004 06:08:23 -0000 1.5 @@ -38,6 +38,8 @@ private String _domain; + private long _expiredTime; + /** * Constructs a cookie w/o any domain or path restrictions. @@ -52,15 +54,27 @@ this( name, value ); for (Iterator iterator = attributes.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); + String attributeValue = (String) attributes.get( key ); if (key.equalsIgnoreCase( "path" )) { - _path = (String) attributes.get( key ); + _path = attributeValue; } else if (key.equalsIgnoreCase( "domain" )) { - _domain = (String) attributes.get( key ); + _domain = attributeValue; + } else if (key.equalsIgnoreCase( "max-age" )) { + _expiredTime = System.currentTimeMillis() + getAgeInMsec( attributeValue ); } } } + private int getAgeInMsec( String maxAgeValue ) { + try { + return 1000 * Integer.parseInt( maxAgeValue ); + } catch (NumberFormatException e) { + return 0; + } + } + + /** * Returns the name of this cookie. */ @@ -110,6 +124,7 @@ boolean mayBeSentTo( URL url ) { if (getDomain() == null) return true; + if (_expiredTime != 0 && _expiredTime <= System.currentTimeMillis()) return false; return acceptHost( getDomain(), url.getHost() ) && acceptPath( getPath(), url.getPath() ); } |
From: Russell G. <rus...@us...> - 2004-09-12 06:08:32
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22576/doc Modified Files: release_notes.txt Log Message: bug #1025968: cookies with max-age set now expire as appropriate Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.368 retrieving revision 1.369 diff -u -r1.368 -r1.369 --- release_notes.txt 12 Sep 2004 03:31:57 -0000 1.368 +++ release_notes.txt 12 Sep 2004 06:08:23 -0000 1.369 @@ -13,6 +13,9 @@ Revision History: +12-Sep-2004: + Problems fixed: + 1. bug #1025968: Cookies with max-age attribute will now expire (max-age=0 is treated as immediate expiration) 10-Sep-2004: Problems fixed: 1. bug #1013045: Form, Link, and Image id tags are now recognizable from JavaScript where a name tag would be |