httpunit-commit Mailing List for httpunit (Page 4)
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: <wol...@us...> - 2009-08-19 10:08:08
|
Revision: 1041 http://httpunit.svn.sourceforge.net/httpunit/?rev=1041&view=rev Author: wolfgang_fahl Date: 2009-08-19 10:08:00 +0000 (Wed, 19 Aug 2009) Log Message: ----------- fixed BR 2637824 by Chris Wilson JavaScriptException still fatal with script exceptions off (Rhino) Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java Modified: trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java 2009-08-19 09:00:49 UTC (rev 1040) +++ trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java 2009-08-19 10:08:00 UTC (rev 1041) @@ -63,19 +63,23 @@ */ static public void handleScriptException( Exception e, String badScript ) { String errorMessage=badScript==null? e.getMessage():badScript + " failed: " + e; - - if (!(e instanceof EcmaError) && !(e instanceof EvaluatorException) && !(e instanceof ScriptException)) { - HttpUnitUtils.handleException(e); - throw new RuntimeException( errorMessage ); - } else if (JavaScript.isThrowExceptionsOnError()) { - HttpUnitUtils.handleException(e); - if (e instanceof ScriptException) - throw (ScriptException)e; - else - throw new ScriptException( errorMessage ); - } else { - _errorMessages.add( errorMessage ); - } + if (e instanceof EcmaError || + e instanceof EvaluatorException || + e instanceof ScriptException || + e instanceof JavaScriptException) { + if (JavaScript.isThrowExceptionsOnError()) { + HttpUnitUtils.handleException(e); + if (e instanceof ScriptException) + throw (ScriptException)e; + else + throw new ScriptException( errorMessage ); + } else { + _errorMessages.add( errorMessage ); + } + } else { + HttpUnitUtils.handleException(e); + throw new RuntimeException( errorMessage ); + } } //--------------------------------------- ScriptingEngine methods ------------------------------------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-19 09:01:01
|
Revision: 1040 http://httpunit.svn.sourceforge.net/httpunit/?rev=1040&view=rev Author: wolfgang_fahl Date: 2009-08-19 09:00:49 +0000 (Wed, 19 Aug 2009) Log Message: ----------- add test for HeadMethodWebRequest by Dan Lipofsky and fix the PseudoServer accordingly. Make sure GetMethodWebRequest sets the method attribute in the superClass. Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java trunk/httpunit/src/com/meterware/httpunit/HeadMethodWebRequest.java trunk/httpunit/src/com/meterware/httpunit/HeaderOnlyWebRequest.java trunk/httpunit/src/com/meterware/httpunit/WebRequest.java trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java Modified: trunk/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java 2009-08-19 07:06:57 UTC (rev 1039) +++ trunk/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java 2009-08-19 09:00:49 UTC (rev 1040) @@ -24,16 +24,52 @@ import java.net.URL; /** - * An HTTP request using the GET method. + * An HTTP request using the GET method. + * RFC 2616 http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html defines: + * + * 9.3 GET + * + * The GET method means retrieve whatever information (in the form of an entity) + * is identified by the Request-URI. If the Request-URI refers to a + * data-producing process, it is the produced data which shall be returned as + * the entity in the response and not the source text of the process, unless + * that text happens to be the output of the process. + * + * The semantics of the GET method change to a "conditional GET" if the request + * message includes an If-Modified-Since, If-Unmodified-Since, If-Match, + * If-None-Match, or If-Range header field. A conditional GET method requests + * that the entity be transferred only under the circumstances described by the + * conditional header field(s). The conditional GET method is intended to reduce + * unnecessary network usage by allowing cached entities to be refreshed without + * requiring multiple requests or transferring data already held by the client. + * + * The semantics of the GET method change to a "partial GET" if the request + * message includes a Range header field. A partial GET requests that only part + * of the entity be transferred, as described in section 14.35. The partial GET + * method is intended to reduce unnecessary network usage by allowing + * partially-retrieved entities to be completed without transferring data + * already held by the client. + * + * The response to a GET request is cacheable if and only if it meets the + * requirements for HTTP caching described in section 13. + * + * See section 15.1.3 for security considerations when used for forms. **/ public class GetMethodWebRequest extends HeaderOnlyWebRequest { + /** + * initialize me - set method to GET + */ + private void init() { + super.setMethod("GET"); + } /** * Constructs a web request using a specific absolute url string. **/ public GetMethodWebRequest( String urlString ) { super( urlString ); + init(); } @@ -42,6 +78,7 @@ **/ public GetMethodWebRequest( URL urlBase, String urlString ) { super( urlBase, urlString ); + init(); } @@ -50,17 +87,10 @@ **/ public GetMethodWebRequest( URL urlBase, String urlString, String target ) { super( urlBase, urlString, target ); + init(); } - /** - * Returns the HTTP method defined for this request. - **/ - public String getMethod() { - return "GET"; - } - - //--------------------------------------- package members --------------------------------------------- @@ -69,6 +99,7 @@ **/ GetMethodWebRequest( WebForm sourceForm ) { super( sourceForm ); + init(); } @@ -77,6 +108,7 @@ **/ GetMethodWebRequest( FixedURLWebRequestSource source ) { super( source ); + init(); } @@ -85,6 +117,7 @@ **/ GetMethodWebRequest( WebResponse referer, Element sourceElement, URL urlBase, String urlString, String target ) { super( referer, sourceElement, urlBase, urlString, target ); + init(); } @@ -93,6 +126,7 @@ **/ GetMethodWebRequest( URL urlBase, String urlString, FrameSelector frame ) { super( urlBase, urlString, frame ); + init(); } @@ -101,6 +135,7 @@ **/ GetMethodWebRequest( URL urlBase, String urlString, FrameSelector frame, String target ) { super( urlBase, urlString, frame, target ); + init(); } @@ -109,11 +144,8 @@ **/ GetMethodWebRequest( WebForm sourceForm, ParameterHolder parameterHolder, SubmitButton button, int x, int y ) { super( sourceForm, parameterHolder, button, x, y ); + init(); } -} - - - - +} \ No newline at end of file Modified: trunk/httpunit/src/com/meterware/httpunit/HeadMethodWebRequest.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HeadMethodWebRequest.java 2009-08-19 07:06:57 UTC (rev 1039) +++ trunk/httpunit/src/com/meterware/httpunit/HeadMethodWebRequest.java 2009-08-19 09:00:49 UTC (rev 1040) @@ -24,31 +24,61 @@ *******************************************************************************************************************/ /** - * A web request using the HEAD method. This request is used to obtain header information for a resource - * without necessarily waiting for the data to be computed or transmitted. - * + * A web request using the HEAD method. This request is used to obtain header + * information for a resource without necessarily waiting for the data to be + * computed or transmitted. + * + * RFC 2616 http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html defines: + * 9.4 HEAD + * + * The HEAD method is identical to GET except that the server MUST NOT return a + * message-body in the response. The metainformation contained in the HTTP + * headers in response to a HEAD request SHOULD be identical to the information + * sent in response to a GET request. This method can be used for obtaining + * metainformation about the entity implied by the request without transferring + * the entity-body itself. This method is often used for testing hypertext links + * for validity, accessibility, and recent modification. + * + * The response to a HEAD request MAY be cacheable in the sense that the + * information contained in the response MAY be used to update a previously + * cached entity from that resource. If the new field values indicate that the + * cached entity differs from the current entity (as would be indicated by a + * change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache + * MUST treat the cache entry as stale. + * * @author <a href="mailto:rus...@ht...">Russell Gold</a> - **/ + **/ public class HeadMethodWebRequest extends HeaderOnlyWebRequest { - /** - * Creates a new head request from a complete URL string. - * @param urlString the URL desired, including the protocol. - */ - public HeadMethodWebRequest( String urlString ) { - super( urlString ); - this.setMethod("HEAD"); - } + /** + * initialize me - set method to HEAD + */ + private void init() { + super.setMethod("HEAD"); + } + + /** + * Creates a new head request from a complete URL string. + * + * @param urlString + * the URL desired, including the protocol. + */ + public HeadMethodWebRequest(String urlString) { + super(urlString); + init(); + } + /** + * Creates a new head request using a relative URL and base. + * + * @param urlBase + * the base URL. + * @param urlString + * the relative URL + */ + public HeadMethodWebRequest(URL urlBase, String urlString) { + super(urlBase, urlString); + init(); + } - /** - * Creates a new head request using a relative URL and base. - * @param urlBase the base URL. - * @param urlString the relative URL - */ - public HeadMethodWebRequest( URL urlBase, String urlString ) { - super( urlBase, urlString ); - this.setMethod("HEAD"); - } - } Modified: trunk/httpunit/src/com/meterware/httpunit/HeaderOnlyWebRequest.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HeaderOnlyWebRequest.java 2009-08-19 07:06:57 UTC (rev 1039) +++ trunk/httpunit/src/com/meterware/httpunit/HeaderOnlyWebRequest.java 2009-08-19 09:00:49 UTC (rev 1040) @@ -50,11 +50,11 @@ } /** - * @param method the method to set - */ - public void setMethod(String method) { - this.method = method; - } + * @param method the method to set + */ + public void setMethod(String method) { + this.method = method; + } //-------------------------------- protected members --------------------------- Modified: trunk/httpunit/src/com/meterware/httpunit/WebRequest.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/WebRequest.java 2009-08-19 07:06:57 UTC (rev 1039) +++ trunk/httpunit/src/com/meterware/httpunit/WebRequest.java 2009-08-19 09:00:49 UTC (rev 1040) @@ -189,12 +189,12 @@ protected String method; - /** - * @return the method - */ - public String getMethod() { - return method; - } + /** + * @return the method + */ + public String getMethod() { + return method; + } /** Modified: trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java =================================================================== --- trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java 2009-08-19 07:06:57 UTC (rev 1039) +++ trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java 2009-08-19 09:00:49 UTC (rev 1040) @@ -404,11 +404,21 @@ } + /** + * get the resource for the given request by first trying to look it up in the cache + * then depending on the type of request PseudoServlet and the method / command e.g. GET/HEAD + * finally the extension of the uri ".zip" ".class" and ".jar" are handled + * @param request + * @return the WebResource or null if non of the recipes above will lead to a valid resource + * @throws IOException + */ private WebResource getResource( HttpRequest request ) throws IOException { Object resource = _resources.get( request.getURI() ); if (resource == null) resource = _resources.get( withoutParameters( request.getURI() ) ); - if (request.getCommand().equals( "GET" ) && resource instanceof WebResource) { + // check the method of the request + String command=request.getCommand(); + if ((command.equals( "GET" ) || command.equals("HEAD")) && resource instanceof WebResource) { return (WebResource) resource; } else if (resource instanceof PseudoServlet) { return getResource( (PseudoServlet) resource, request ); Modified: trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java 2009-08-19 07:06:57 UTC (rev 1039) +++ trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java 2009-08-19 09:00:49 UTC (rev 1040) @@ -153,8 +153,29 @@ assertNotNull( "No DOM created for document", dom ); assertTrue( "returned dom does not implement HTMLDocument, but is " + dom.getClass().getName(), dom instanceof HTMLDocument ); } + + /** + * add test for HeadMethodWebRequest + * @author Dan Lipofsky 2009-08-19 + * @throws Exception + */ + public void testHeadMethodWebRequest() throws Exception { + defineResource( "SimplePage.html", + "<html><head><title>A Sample Page</title></head>\n" + + "<body>Hello</body></html>\n" ); + HttpUnitOptions.setExceptionsThrownOnErrorStatus(true); + WebConversation wc = new WebConversation(); + // create a HeadMethodWebRequest + // see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html for definition + WebRequest request = new HeadMethodWebRequest( getHostPath() + "/SimplePage.html" ); + WebResponse simplePage = wc.getResponse( request ); + String text=simplePage.getText(); + // no body should be returned + assertEquals("",text); + } + public void testTitle() throws Exception { defineResource( "SimplePage.html", "<html><head><title>A Sample Page</title></head>\n" + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-19 07:07:05
|
Revision: 1039 http://httpunit.svn.sourceforge.net/httpunit/?rev=1039&view=rev Author: wolfgang_fahl Date: 2009-08-19 07:06:57 +0000 (Wed, 19 Aug 2009) Log Message: ----------- modify message on failure of getIncludes Scripts via src attributes to make sure the message is the same on all setting of Exception and ScriptError status flags Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java Modified: trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java 2009-08-18 17:16:34 UTC (rev 1038) +++ trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java 2009-08-19 07:06:57 UTC (rev 1039) @@ -410,8 +410,8 @@ } else { // in this case the text would be an error message // we do not return it but set the - ScriptException se=new ScriptException(response.getText()); - String badScript="?"; + ScriptException se=new ScriptException("reponseCode "+code+" on getIncludedScript for src='"+srcAttribute+"'"); + String badScript=null; // let scripting engine decide what to do with this exception (throw it or remember it ...) HttpUnitOptions.getScriptingEngine().handleScriptException(se, badScript); return ""; Modified: trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java 2009-08-18 17:16:34 UTC (rev 1038) +++ trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java 2009-08-19 07:06:57 UTC (rev 1039) @@ -39,6 +39,9 @@ private static ArrayList _errorMessages = new ArrayList(); + /** + * clear the list of error Messages + */ static public void clearErrorMessages() { _errorMessages.clear(); } @@ -59,7 +62,7 @@ * @param badScript - the script that caused the problem */ static public void handleScriptException( Exception e, String badScript ) { - final String errorMessage = badScript + " failed: " + e; + String errorMessage=badScript==null? e.getMessage():badScript + " failed: " + e; if (!(e instanceof EcmaError) && !(e instanceof EvaluatorException) && !(e instanceof ScriptException)) { HttpUnitUtils.handleException(e); Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-08-18 17:16:34 UTC (rev 1038) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-08-19 07:06:57 UTC (rev 1039) @@ -23,6 +23,8 @@ import com.meterware.httpunit.*; import junit.framework.Assert; +import junit.framework.AssertionFailedError; +import junit.framework.ComparisonFailure; import junit.framework.TestSuite; import junit.textui.TestRunner; @@ -200,7 +202,7 @@ * behaviour pointed out by Dan Lipofsky * @throws Exception */ - public void testBadJavascriptFile() throws Exception { + public void testBadJavascriptFile() { // define xyz.js to create a 404 error // we don't do this - it should be a default behaviour of the Pseudo Server! // defineResource( "xyz.js", "File does not exist: xyz.js", 404); @@ -212,12 +214,16 @@ HttpUnitOptions.getExceptionsThrownOnErrorStatus(); boolean originalScriptState= HttpUnitOptions.getExceptionsThrownOnScriptError(); + // make sure stackTraces are not printed on Exceptions + // uncomment this if you'd actually like to debug the following code boolean oldDebug= HttpUnitUtils.setEXCEPTION_DEBUG(false); - - // make sure exceptions are thrown - HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); - for (int i=0;i<2;i++) { - boolean throwScriptException=i==0; + AssertionFailedError failure=null; + // check 4 combinations of Exception and ScriptError status flags + for (int i=0;i<4;i++) { + boolean throwScriptException=(i%2)==0; // true on case 0 and 2 + boolean throwException=((i/2)%2)==0; // true on case 0 and 1 + String testDescription=("case "+i+" throwScriptException="+throwScriptException+" throwException="+throwException); + HttpUnitOptions.setExceptionsThrownOnErrorStatus(throwException); HttpUnitOptions.setExceptionsThrownOnScriptError(throwScriptException); HttpUnitOptions.clearScriptErrorMessages(); WebConversation wc = new WebConversation(); @@ -231,14 +237,19 @@ String[] errMsgs = HttpUnitOptions.getScriptErrorMessages(); assertTrue("There should be an error Message",errMsgs.length==1); String errMsg=errMsgs[0]; - assertEquals(errMsg,"? failed: com.meterware.httpunit.ScriptException: unable to find /xyz.js"); + assertEquals(testDescription,"reponseCode 404 on getIncludedScript for src='xyz.js'",errMsg); } } catch (ScriptException se) { assertTrue(throwScriptException); } catch (Exception e) { fail("there should be no exception when throwScriptException is "+throwScriptException); - } + } catch (AssertionFailedError afe) { + // continue looping on failed tests + failure=afe; + } } + if (failure!=null) + throw(failure); // Restore exceptions state HttpUnitOptions.setExceptionsThrownOnErrorStatus(originalState ); HttpUnitOptions.setExceptionsThrownOnScriptError(originalScriptState); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-18 17:16:47
|
Revision: 1038 http://httpunit.svn.sourceforge.net/httpunit/?rev=1038&view=rev Author: wolfgang_fahl Date: 2009-08-18 17:16:34 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Header added Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/HttpsProtocolSupport.java Modified: trunk/httpunit/src/com/meterware/httpunit/HttpsProtocolSupport.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HttpsProtocolSupport.java 2009-08-18 16:31:32 UTC (rev 1037) +++ trunk/httpunit/src/com/meterware/httpunit/HttpsProtocolSupport.java 2009-08-18 17:16:34 UTC (rev 1038) @@ -1,8 +1,9 @@ package com.meterware.httpunit; /******************************************************************************************************************** * $Id$ +* $URL$ * -* Copyright (c) 2003-2007, Russell Gold +* Copyright (c) 2003-2009, 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-18 16:31:38
|
Revision: 1037 http://httpunit.svn.sourceforge.net/httpunit/?rev=1037&view=rev Author: wolfgang_fahl Date: 2009-08-18 16:31:32 +0000 (Tue, 18 Aug 2009) Log Message: ----------- preparing release notes Modified Paths: -------------- trunk/httpunit/doc/release_notes.html Modified: trunk/httpunit/doc/release_notes.html =================================================================== --- trunk/httpunit/doc/release_notes.html 2009-08-18 16:08:16 UTC (rev 1036) +++ trunk/httpunit/doc/release_notes.html 2009-08-18 16:31:32 UTC (rev 1037) @@ -20,6 +20,28 @@ <h2>Revision History:</h2> +<h3>Version 1.7.x to be Released some time in the future</h3> +<h4>Acknowledgements:</h4> +<ul> + <li>Marc Guillemot for his change request to add the response to a HttpException</li> + <li>Robert Wadura for showing that trying to load included scripts that do not exist might abort entire requests - was already fixed in 1.7 but not mentioned in the release notes</li> + <li>Dan Lipofsky for pointing out some problems with JavaScript handling</li> +</ul> +<h4>Problems fixed:</h4> + <li>bug #<a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1055450&group_id=6550&atid=106550">1055450</a> - Error loading included script aborts entire request</li> +<h4>Additions:</h4> +<h5>Debugging</h5> +Whenever some code was changed it was made more debug and test-friendly. +<ul> + <li>One-lines have been modified to multiple lines to be able to inspect variables that hold temporary results</li> + <li>accessing private variables is sometimes done via getters and setters just to be able to better debug when the variable is set</li> +</ul> +<h5>Error handling</h5> +<ol> + <li>change request #<a href="http://sourceforge.net/tracker/index.php?func=detail&aid=914314&group_id=6550&atid=356550">914314</a>Add HttpException.getResponse for better reporting</li> +</ol> + + <h3>Version 1.7 Released 2008-05-20</h3> <h4>Acknowledgements:</h4> This project would almost certainly have remained dormant without the extraordinary contributions of our new committer, Wolfgang Fahl. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-18 16:08:26
|
Revision: 1036 http://httpunit.svn.sourceforge.net/httpunit/?rev=1036&view=rev Author: wolfgang_fahl Date: 2009-08-18 16:08:16 +0000 (Tue, 18 Aug 2009) Log Message: ----------- implemented CR [ 914314 ] to add getResponse to HttpException improved handling of undefined resources in PseudoServer getIncludedScript now handles 404 errors according to the HttpUnit Options settings for script error and exception handling (thanks to Dan Lipofsky for pointing this out) Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/HttpException.java trunk/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java trunk/httpunit/src/com/meterware/httpunit/HttpWebResponse.java trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java trunk/httpunit/src/com/meterware/httpunit/WebClient.java trunk/httpunit/src/com/meterware/httpunit/WebResponse.java trunk/httpunit/src/com/meterware/httpunit/dom/DomBasedScriptingEngineFactory.java trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScriptEngineFactory.java trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java trunk/httpunit/src/com/meterware/httpunit/scripting/ScriptingEngineFactory.java trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java Modified: trunk/httpunit/src/com/meterware/httpunit/HttpException.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HttpException.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/HttpException.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -128,5 +128,24 @@ private Throwable _cause; + + // see feature request [ 914314 ] Add HttpException.getResponse for better reporting + private WebResponse response; + + /** + * return the WebResponse associated with this Exception (if any) + * @return + */ + public WebResponse getResponse() { + return response; + } + + /** + * add the given response to this exception + * @param response + */ + public void setResponse(WebResponse response) { + this.response=response; + } } \ No newline at end of file Modified: trunk/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -505,6 +505,9 @@ public void clearErrorMessages() {} public ScriptingHandler createHandler( HTMLElement element ) { return ScriptableDelegate.NULL_SCRIPT_ENGINE; } public ScriptingHandler createHandler( WebResponse response ) { return ScriptableDelegate.NULL_SCRIPT_ENGINE; } + public void handleScriptException(Exception e, String badScript) { + // happily ignore and exception + } }; Modified: trunk/httpunit/src/com/meterware/httpunit/HttpWebResponse.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HttpWebResponse.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/HttpWebResponse.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2004, Russell Gold +* Copyright (c) 2000-2009, 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 @@ -58,8 +58,12 @@ /** make sure that any IO exception for HTML received page happens here, not later. **/ if (_responseCode < HttpURLConnection.HTTP_BAD_REQUEST || !throwExceptionOnError) { - defineRawInputStream( new BufferedInputStream( getInputStream( connection ) ) ); - if (getContentType().startsWith( "text" )) loadResponseText(); + InputStream inputStream = getInputStream( connection ); + defineRawInputStream( new BufferedInputStream( inputStream ) ); + String contentType = getContentType(); + if (contentType.startsWith( "text" )) { + loadResponseText(); + } } } @@ -81,7 +85,7 @@ InputStream result=null; // check whether there is an error stream if (isResponseOnErrorStream( connection )) { - result=((HttpURLConnection) connection).getErrorStream(); + result=((HttpURLConnection) connection).getErrorStream(); } else { // if there is no error stream it depends on the response code try { @@ -190,30 +194,40 @@ private int _responseCode = HttpURLConnection.HTTP_OK; - private String _responseMessage = "OK"; + private String _responseMessage = "OK"; + + /** + * set the responseCode to the given code and message + * @param code + * @param message + */ + private void setResponseCode(int code, String message) { + _responseCode = code; + _responseMessage=message; + } private Hashtable _headers = new Hashtable(); - - + /** + * read the response Header for the given connection and set the response code and + * message accordingly + * @param connection + * @throws IOException + */ private void readResponseHeader( HttpURLConnection connection ) throws IOException { if (!needStatusWorkaround()) { - _responseCode = connection.getResponseCode(); - _responseMessage = connection.getResponseMessage(); + setResponseCode(connection.getResponseCode(),connection.getResponseMessage()); } else { if (connection.getHeaderField(0) == null) throw new UnknownHostException( connection.getURL().toExternalForm() ); StringTokenizer st = new StringTokenizer( connection.getHeaderField(0) ); st.nextToken(); if (!st.hasMoreTokens()) { - _responseCode = HttpURLConnection.HTTP_OK; - _responseMessage = "OK"; + setResponseCode(HttpURLConnection.HTTP_OK,"OK"); } else try { - _responseCode = Integer.parseInt( st.nextToken() ); - _responseMessage = getRemainingTokens( st ); + setResponseCode(Integer.parseInt( st.nextToken()) ,getRemainingTokens( st )); } catch (NumberFormatException e) { - _responseCode = HttpURLConnection.HTTP_INTERNAL_ERROR; - _responseMessage = "Cannot parse response header"; + setResponseCode (HttpURLConnection.HTTP_INTERNAL_ERROR,"Cannot parse response header"); } } } @@ -238,8 +252,7 @@ if (connection instanceof HttpURLConnection) { readResponseHeader( (HttpURLConnection) connection ); } else { - _responseCode = HttpURLConnection.HTTP_OK; - _responseMessage = "OK"; + setResponseCode (HttpURLConnection.HTTP_OK, "OK"); if (connection.getContentType().startsWith( "text" )) { setContentTypeHeader( connection.getContentType() + "; charset=" + FILE_ENCODING ); } Modified: trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -25,6 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.html.*; +import java.net.HttpURLConnection; import java.net.URL; import java.util.*; import java.io.IOException; @@ -380,7 +381,7 @@ } else { try { return getIncludedScript( scriptLocation ); - } catch (IOException e) { + } catch (Exception e) { throw new RuntimeException( "Error loading included script: " + e ); } } @@ -391,13 +392,30 @@ * Returns the contents of an included script, given its src attribute. * @param srcAttribute the location of the script. * @return the contents of the script. - * @throws java.io.IOException if there is a problem retrieving the script + * @throws IOException if there is a problem retrieving the script */ String getIncludedScript( String srcAttribute ) throws IOException { WebRequest req = new GetMethodWebRequest( getBaseURL(), srcAttribute ); WebWindow window = getResponse().getWindow(); - if (window == null) throw new IllegalStateException( "Unable to retrieve script included by this response, since it was loaded by getResource(). Use getResponse() instead."); - return window.getResource( req ).getText(); + if (window == null) + throw new IllegalStateException( "Unable to retrieve script included by this response, since it was loaded by getResource(). Use getResponse() instead."); + WebResponse response = window.getResource( req ); + // check whether the Source is available + int code = response.getResponseCode(); + // if everything is o.k. + if (code<=HttpURLConnection.HTTP_BAD_REQUEST) { + // return the text + String result =response.getText(); + return result; + } else { + // in this case the text would be an error message + // we do not return it but set the + ScriptException se=new ScriptException(response.getText()); + String badScript="?"; + // let scripting engine decide what to do with this exception (throw it or remember it ...) + HttpUnitOptions.getScriptingEngine().handleScriptException(se, badScript); + return ""; + } } Modified: trunk/httpunit/src/com/meterware/httpunit/WebClient.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/WebClient.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/WebClient.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -623,17 +623,25 @@ * @parm response - the response to validate **/ private void validateHeaders( WebResponse response ) throws HttpException { - if (!getExceptionsThrownOnErrorStatus()) - return; - // see feature request [ 914314 ] Add HttpException.getResponse for better reporting - // for possible improvements here + HttpException exception=null; if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { - throw new HttpInternalErrorException( response.getURL() ); + exception=new HttpInternalErrorException( response.getURL() ); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { - throw new HttpNotFoundException( response.getResponseMessage(), response.getURL() ); + exception= new HttpNotFoundException( response.getResponseMessage(), response.getURL() ); } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { - throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() ); + exception= new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() ); } + // is there an exception? + if (exception!=null) { + // see feature request [ 914314 ] Add HttpException.getResponse for better reporting + exception.setResponse(response); + // shall we ignore errors? + if (!getExceptionsThrownOnErrorStatus()) { + return; + } else { + throw exception; + } + } } Modified: trunk/httpunit/src/com/meterware/httpunit/WebResponse.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/WebResponse.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/WebResponse.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -282,16 +282,17 @@ * which may be used to represent internal state of this object. **/ public String getText() throws IOException { - if (_responseText == null) loadResponseText(); + if (_responseText == null) + loadResponseText(); return _responseText; } - /** * Returns a buffered input stream for reading the contents of this reply. **/ public InputStream getInputStream() throws IOException { - if (_inputStream == null) _inputStream = new ByteArrayInputStream( getText().getBytes() ); + if (_inputStream == null) + _inputStream = new ByteArrayInputStream( getText().getBytes() ); return _inputStream; } @@ -1056,7 +1057,7 @@ private String _responseText; - private InputStream _inputStream; + private InputStream _inputStream; private final URL _pageURL; Modified: trunk/httpunit/src/com/meterware/httpunit/dom/DomBasedScriptingEngineFactory.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/dom/DomBasedScriptingEngineFactory.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/dom/DomBasedScriptingEngineFactory.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -26,6 +26,7 @@ import com.meterware.httpunit.scripting.ScriptingHandler; import com.meterware.httpunit.scripting.ScriptingEngine; import com.meterware.httpunit.HttpUnitUtils; +import com.meterware.httpunit.ScriptException; import com.meterware.httpunit.WebResponse; import com.meterware.httpunit.HTMLElement; @@ -38,6 +39,7 @@ import org.xml.sax.SAXException; import org.mozilla.javascript.Context; import org.mozilla.javascript.EcmaError; +import org.mozilla.javascript.EvaluatorException; import org.mozilla.javascript.Function; import org.mozilla.javascript.JavaScriptException; import org.mozilla.javascript.Scriptable; @@ -143,4 +145,14 @@ public ScriptingHandler createHandler( WebResponse response ) { return response.createDomScriptingHandler(); } + + + /** + * handle Exceptions + * @param e - the exception to handle + * @param badScript - the script that caused the problem + */ + public void handleScriptException( Exception e, String badScript ) { + ScriptingEngineImpl.handleScriptException(e, badScript); + } } Modified: trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScriptEngineFactory.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScriptEngineFactory.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScriptEngineFactory.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -82,6 +82,13 @@ public String[] getErrorMessages() { return ScriptingEngineImpl.getErrorMessages(); } + + /** + * delegate the handling for Script exceptions + */ + public void handleScriptException(Exception e, String badScript) { + ScriptingEngineImpl.handleScriptException(e, badScript); + } public void clearErrorMessages() { @@ -99,4 +106,6 @@ public ScriptingHandler createHandler( WebResponse response ) { return response.createJavascriptScriptingHandler(); } + + } Modified: trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/javascript/ScriptingEngineImpl.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -44,6 +44,10 @@ } + /** + * access to the list of error Messages that were collected + * @return the array with error Messages + */ static public String[] getErrorMessages() { return (String[]) _errorMessages.toArray( new String[ _errorMessages.size() ] ); } @@ -56,11 +60,15 @@ */ static public void handleScriptException( Exception e, String badScript ) { final String errorMessage = badScript + " failed: " + e; - if (!(e instanceof EcmaError) && !(e instanceof EvaluatorException)) { + + if (!(e instanceof EcmaError) && !(e instanceof EvaluatorException) && !(e instanceof ScriptException)) { HttpUnitUtils.handleException(e); throw new RuntimeException( errorMessage ); } else if (JavaScript.isThrowExceptionsOnError()) { HttpUnitUtils.handleException(e); + if (e instanceof ScriptException) + throw (ScriptException)e; + else throw new ScriptException( errorMessage ); } else { _errorMessages.add( errorMessage ); Modified: trunk/httpunit/src/com/meterware/httpunit/scripting/ScriptingEngineFactory.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/scripting/ScriptingEngineFactory.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/httpunit/scripting/ScriptingEngineFactory.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -64,6 +64,13 @@ * Clears the accumulated script error messages. */ public void clearErrorMessages(); + + /** + * handle Exceptions + * @param e - the exception to handle + * @param badScript - the script that caused the problem + */ + public void handleScriptException( Exception e, String badScript ); ScriptingHandler createHandler( HTMLElement elementBase ); Modified: trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java =================================================================== --- trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/src/com/meterware/pseudoserver/PseudoServer.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -100,6 +100,10 @@ } + /** + * create a PseudoServer with the given socketTimeout + * @param socketTimeout - the time out to use + */ public PseudoServer( int socketTimeout ) { _socketTimeout = socketTimeout; _serverNum = ++_numServers; @@ -197,9 +201,16 @@ /** * Defines a resource which will result in an error message. - **/ - public void setErrorResource( String name, int errorCode, String errorMessage ) { - _resources.put( asResourceName( name ), new WebResource( errorMessage, errorCode ) ); + * return it for further use + * @param name + * @param errorCode + * @param errorMessage + * @return the resource + */ + public WebResource setErrorResource( String name, int errorCode, String errorMessage ) { + WebResource resource = new WebResource( errorMessage, errorCode ); + _resources.put( asResourceName( name ), resource ); + return resource; } @@ -314,7 +325,9 @@ boolean keepAlive = respondToRequest( request, outputStream ); if (!keepAlive) break; while (_active && 0 == inputStream.available()) { - try { Thread.sleep( INPUT_POLL_INTERVAL ); } catch (InterruptedException e) {} + try { + Thread.sleep( INPUT_POLL_INTERVAL ); + } catch (InterruptedException e) {} } } } catch (IOException e) { @@ -329,6 +342,12 @@ } + /** + * respond to the given request + * @param request - the request + * @param response - the response stream + * @return + */ private boolean respondToRequest( HttpRequest request, HttpResponseStream response ) { debug( "Server thread handling request: " + request ); boolean keepAlive = isKeepAlive( request ); @@ -338,25 +357,39 @@ response.setProtocol( getResponseProtocol( request ) ); resource = getResource( request ); if (resource == null) { - response.setResponse( HttpURLConnection.HTTP_NOT_FOUND, "unable to find " + request.getURI() ); + // what resource could not be find? + String uri=request.getURI(); + // 404 - Not Found error code + int errorCode=HttpURLConnection.HTTP_NOT_FOUND; + // typical 404 error Message + String errorMessage="unable to find " + uri; + // make sure there is a resource and + // next time we'll take it from the resource Cache + resource=setErrorResource(uri, errorCode, errorMessage); + // set the errorCode for this response + response.setResponse(errorCode , errorMessage ); } else { - if (resource.closesConnection()) keepAlive = false; if (resource.getResponseCode() != HttpURLConnection.HTTP_OK) { response.setResponse( resource.getResponseCode(), "" ); - } - String[] headers = resource.getHeaders(); - for (int i = 0; i < headers.length; i++) { - debug( "Server thread sending header: " + headers[i] ); - response.addHeader( headers[i] ); - } + } } + if (resource.closesConnection()) keepAlive = false; + String[] headers = resource.getHeaders(); + for (int i = 0; i < headers.length; i++) { + debug( "Server thread sending header: " + headers[i] ); + response.addHeader( headers[i] ); + } } catch (UnknownMethodException e) { response.setResponse( HttpURLConnection.HTTP_BAD_METHOD, "unsupported method: " + e.getMethod() ); } catch (Throwable t) { t.printStackTrace(); response.setResponse( HttpURLConnection.HTTP_INTERNAL_ERROR, t.toString() ); } - try { response.write( resource ); } catch (IOException e) { System.out.println( "*** Failed to send reply: " + e ); } + try { + response.write( resource ); + } catch (IOException e) { + System.out.println( "*** Failed to send reply: " + e ); + } return keepAlive; } @@ -470,6 +503,11 @@ } + /** + * set the response to the given response Code + * @param responseCode + * @param responseText + */ void setResponse( int responseCode, String responseText ) { _responseCode = responseCode; _responseText = responseText; Modified: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -72,6 +72,10 @@ } + /** + * check access to resources that are not defined + * @throws Exception + */ public void testNotFound() throws Exception { WebConversation wc = new WebConversation(); WebRequest request = new GetMethodWebRequest( getHostPath() + "/nothing.htm" ); @@ -81,8 +85,50 @@ } catch (HttpNotFoundException e) { assertEquals( "Response code", HttpURLConnection.HTTP_NOT_FOUND, e.getResponseCode() ); assertEquals( "Response message", "unable to find /nothing.htm", e.getResponseMessage() ); + assertEquals( "Response text","",e.getResponse().getText()); } } + + /** + * check access to undefined resources + * @throws IOException + */ + public void testUndefinedResource() throws IOException { + boolean originalState = HttpUnitOptions + .getExceptionsThrownOnErrorStatus(); + // try two cases for throwException true on i==0, false on i==1 + for (int i = 0; i <2; i++) { + boolean throwException = i == 0; + HttpUnitOptions.setExceptionsThrownOnErrorStatus(throwException); + WebResponse response = null; + try { + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest(getHostPath() + + "/undefined"); + response = wc.getResponse(request); + if (throwException) { + fail("there should have been an exception here"); + } + } catch (HttpNotFoundException hnfe) { + assertTrue(throwException); + response=hnfe.getResponse(); + } catch (Exception e) { + fail("there should be no exception here"); + } + assertTrue(response != null); + assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response + .getResponseCode()); + if (throwException) { + assertEquals("with throwException="+throwException,"", response.getText()); + assertEquals("with throwException="+throwException,"unable to find /undefined",response.getResponseMessage()); + } else { + // FIXME what do we expect here and how do we get it! + assertEquals("with throwException="+throwException,"unable to find /undefined", response.getText()); + assertNull(response.getResponseMessage()); + } + } + HttpUnitOptions.setExceptionsThrownOnErrorStatus(originalState); + } public void testNotModifiedResponse() throws Exception { @@ -770,39 +816,6 @@ } /** - * check access to undefined resources - */ - public void testUndefinedResource() { - boolean originalState = HttpUnitOptions - .getExceptionsThrownOnErrorStatus(); - for (int i = 0; i < 1; i++) { - boolean throwException = i == 0; - HttpUnitOptions.setExceptionsThrownOnErrorStatus(throwException); - WebResponse response = null; - try { - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getHostPath() - + "/undefined"); - response = wc.getResponse(request); - if (throwException) { - fail("there should have been an exception here"); - } - assertTrue(response != null); - assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response - .getResponseCode()); - assertEquals(0, response.getContentLength()); - } catch (Exception e) { - if (throwException) { - assertTrue(e instanceof HttpNotFoundException); - } else { - fail("there should be no exception here"); - } - } - } - HttpUnitOptions.setExceptionsThrownOnErrorStatus(originalState); - } - - /** * test for bug report [ 1283878 ] FileNotFoundException using Sun JDK 1.5 on empty error pages * by Roger Lindsj\xF6 * @throws Exception Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-08-18 11:31:16 UTC (rev 1035) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-08-18 16:08:16 UTC (rev 1036) @@ -193,8 +193,59 @@ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); response.getLinkWith( "go" ).click(); assertEquals( "Alert message", "Cheese!", wc.popNextAlert() ); - } + } + /** + * test Detection of Javascript files that can not be found + * behaviour pointed out by Dan Lipofsky + * @throws Exception + */ + public void testBadJavascriptFile() throws Exception { + // define xyz.js to create a 404 error + // we don't do this - it should be a default behaviour of the Pseudo Server! + // defineResource( "xyz.js", "File does not exist: xyz.js", 404); + defineResource("OnCommand.html", + "<html><head>" + + "<script language='JavaScript' src='xyz.js'></script></head>" + + "<body>Hello</body></html>" ); + boolean originalState = + HttpUnitOptions.getExceptionsThrownOnErrorStatus(); + boolean originalScriptState= + HttpUnitOptions.getExceptionsThrownOnScriptError(); + boolean oldDebug= HttpUnitUtils.setEXCEPTION_DEBUG(false); + + // make sure exceptions are thrown + HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); + for (int i=0;i<2;i++) { + boolean throwScriptException=i==0; + HttpUnitOptions.setExceptionsThrownOnScriptError(throwScriptException); + HttpUnitOptions.clearScriptErrorMessages(); + WebConversation wc = new WebConversation(); + try { + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + // WebResponse response = wc.getResponse( getHostPath() + "/xyz.js" ); + // assertEquals( 404, response.getResponseCode() ); + if (throwScriptException) { + fail("there should have been an exception"); + } else { + String[] errMsgs = HttpUnitOptions.getScriptErrorMessages(); + assertTrue("There should be an error Message",errMsgs.length==1); + String errMsg=errMsgs[0]; + assertEquals(errMsg,"? failed: com.meterware.httpunit.ScriptException: unable to find /xyz.js"); + } + } catch (ScriptException se) { + assertTrue(throwScriptException); + } catch (Exception e) { + fail("there should be no exception when throwScriptException is "+throwScriptException); + } + } + // Restore exceptions state + HttpUnitOptions.setExceptionsThrownOnErrorStatus(originalState ); + HttpUnitOptions.setExceptionsThrownOnScriptError(originalScriptState); + HttpUnitUtils.setEXCEPTION_DEBUG(oldDebug); + } + + public void testJavaScriptURLInNewWindow() throws Exception { defineWebPage( "OnCommand", "<input type='button' id='nowindow' onClick='alert(\"hi\")'></input>\n" + "<input type='button' id='withwindow' onClick=\"window.open('javascript:alert(\\'hi\\')','_self')\"></input>" ); @@ -279,17 +330,20 @@ "<body>" + "<a href=\"javascript:sayCheese()\">go</a>" + "</body></html>" ); - HttpUnitOptions.setExceptionsThrownOnScriptError( true); - HttpUnitOptions.clearScriptErrorMessages(); WebConversation wc = new WebConversation(); + boolean oldDebug= HttpUnitUtils.setEXCEPTION_DEBUG(false); + HttpUnitOptions.setExceptionsThrownOnScriptError( false); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); - boolean oldDebug= HttpUnitUtils.setEXCEPTION_DEBUG(false); try { + HttpUnitOptions.setExceptionsThrownOnScriptError( true); + HttpUnitOptions.clearScriptErrorMessages(); response.getLinkWith( "go" ).click(); fail("there should have been an exception"); - } catch (Throwable th) { + } catch (ScriptException se) { + fail("Runtime exception is appropriate in this test case since we ignored the loading error"); + } catch (RuntimeException rte) { // java.lang.RuntimeException: Error clicking link: com.meterware.httpunit.ScriptException: URL 'javascript:sayCheese()' failed: org.mozilla.javascript.EcmaError: ReferenceError: "sayCheese" is not defined. - assertTrue("is not defined should be found in message",th.getMessage().indexOf("not defined")>0); + assertTrue("is not defined should be found in message",rte.getMessage().indexOf("not defined")>0); } finally { HttpUnitUtils.setEXCEPTION_DEBUG(oldDebug); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-18 11:31:32
|
Revision: 1035 http://httpunit.svn.sourceforge.net/httpunit/?rev=1035&view=rev Author: wolfgang_fahl Date: 2009-08-18 11:31:16 +0000 (Tue, 18 Aug 2009) Log Message: ----------- check behaviour of undefined resources Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-17 13:11:58 UTC (rev 1034) +++ trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-18 11:31:16 UTC (rev 1035) @@ -33,6 +33,8 @@ import java.util.*; import java.util.zip.GZIPOutputStream; +import org.xml.sax.SAXException; + //import HTTPClient.HTTPConnection; //import HTTPClient.HTTPResponse; @@ -766,6 +768,39 @@ } } } + + /** + * check access to undefined resources + */ + public void testUndefinedResource() { + boolean originalState = HttpUnitOptions + .getExceptionsThrownOnErrorStatus(); + for (int i = 0; i < 1; i++) { + boolean throwException = i == 0; + HttpUnitOptions.setExceptionsThrownOnErrorStatus(throwException); + WebResponse response = null; + try { + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest(getHostPath() + + "/undefined"); + response = wc.getResponse(request); + if (throwException) { + fail("there should have been an exception here"); + } + assertTrue(response != null); + assertEquals(HttpURLConnection.HTTP_NOT_FOUND, response + .getResponseCode()); + assertEquals(0, response.getContentLength()); + } catch (Exception e) { + if (throwException) { + assertTrue(e instanceof HttpNotFoundException); + } else { + fail("there should be no exception here"); + } + } + } + HttpUnitOptions.setExceptionsThrownOnErrorStatus(originalState); + } /** * test for bug report [ 1283878 ] FileNotFoundException using Sun JDK 1.5 on empty error pages @@ -782,11 +817,11 @@ defineResource( "emptyError", "", 404); WebRequest request = new GetMethodWebRequest( getHostPath() +"/emptyError" ); WebResponse response = wc.getResponse( request ); - assertEquals( 404, response.getResponseCode() ); + assertEquals( HttpURLConnection.HTTP_NOT_FOUND, response.getResponseCode() ); assertEquals( 0, response.getContentLength() ); } catch (java.io.FileNotFoundException fnfe) { fnfe.printStackTrace(); - assertTrue("There should be not file not found exception '"+fnfe.getMessage()+"'",false); + assertTrue("There should be no file not found exception '"+fnfe.getMessage()+"'",false); } finally { // Restore exceptions state HttpUnitOptions.setExceptionsThrownOnErrorStatus(originalState ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 13:53:25
|
Revision: 1034 http://httpunit.svn.sourceforge.net/httpunit/?rev=1034&view=rev Author: wolfgang_fahl Date: 2009-08-17 13:11:58 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Header added Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2009-08-17 13:11:19 UTC (rev 1033) +++ trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2009-08-17 13:11:58 UTC (rev 1034) @@ -1,6 +1,7 @@ package com.meterware.httpunit.cookies; /******************************************************************************************************************** * $Id$ + * $URL$ * * Copyright (c) 2002-2004,2008 Russell Gold * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 13:11:27
|
Revision: 1033 http://httpunit.svn.sourceforge.net/httpunit/?rev=1033&view=rev Author: wolfgang_fahl Date: 2009-08-17 13:11:19 +0000 (Mon, 17 Aug 2009) Log Message: ----------- fix by James Courtney Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2009-08-17 12:58:51 UTC (rev 1032) +++ trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2009-08-17 13:11:19 UTC (rev 1033) @@ -180,17 +180,18 @@ "expires=Tue, 29-Mar-2005 19:30:42 GMT; Max-Age=2592000", "Max-Age=2592000;expires=Tue, 29-Mar-2005 19:30:42 GMT", "expires=Tue, 29-Mar-2005 19:30:42 GMT", - "Expires=Wednesday, 01-Jan-1970 0:0:00 GMT" + "Expires=Wednesday, 01-Jan-1970 00:00:00 GMT" }; - long expectedMilliSeconds[] = {System.currentTimeMillis() + 5000 * 1000, - System.currentTimeMillis() + 3000 * 1000, + long now=System.currentTimeMillis(); + long expectedMilliSeconds[] = {now + 5000 * 1000, + now + 3000 * 1000, + now + 2592000 * 1000, + now + 2592000 * 1000, 1112124642000l, - 1112124642000l, - 1112124642000l, 0}; for (int i = 0; i < ages.length; i++) { - String cookieName = "cookie" + i; + String cookieName = "cookie" + i ; String header = cookieName + "=cookievalue;" + ages[i]; TestSource source = new TestSource( new URL( "http://www.somedomain.com/somepath/" ), header ); CookieJar jar = new CookieJar( source ); @@ -199,10 +200,10 @@ long expiredTime = cookie.getExpiredTime(); int grace = 3000; - assertTrue( cookieName + " expiration expect on or after" + + assertTrue( cookieName + " '"+ages[i]+"' expiration expect on or after" + expectedMilliSeconds[i] + " but was " + expiredTime, expectedMilliSeconds[i] <= expiredTime ); - assertTrue( cookieName + " expiration expect before " + + assertTrue( cookieName + " '"+ages[i]+"' expiration expect before " + (expectedMilliSeconds[i] + grace) + " but was " + expiredTime, (expectedMilliSeconds[i]) + grace > expiredTime ); // assertEquals( cookieName + " expiration", expiredTime, expectedMilliSeconds[i] ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 12:58:59
|
Revision: 1032 http://httpunit.svn.sourceforge.net/httpunit/?rev=1032&view=rev Author: wolfgang_fahl Date: 2009-08-17 12:58:51 +0000 (Mon, 17 Aug 2009) Log Message: ----------- fix problems in german locale Modified Paths: -------------- trunk/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java Modified: trunk/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java =================================================================== --- trunk/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java 2009-08-17 12:15:24 UTC (rev 1031) +++ trunk/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java 2009-08-17 12:58:51 UTC (rev 1032) @@ -1,6 +1,7 @@ package com.meterware.servletunit; /******************************************************************************************************************** * $Id$ +* $URL$ * * Copyright (c) 2000-2004, Russell Gold * @@ -213,8 +214,9 @@ headerValue = servletResponse.getHeaderField( "three" ); assertEquals( "int header is wrong", "3", headerValue ); - SimpleDateFormat df = new SimpleDateFormat( "MM/dd/yyyy z" ); - Date d = df.parse( "12/9/1969 GMT" ); + // use RFC1123_DATE_SPEC formatter + SimpleDateFormat df = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss z" ); + Date d = df.parse( "12/9/1969 12:00:00 GMT" ); servletResponse.setDateHeader( "date", d.getTime() ); headerValue = servletResponse.getHeaderField( "date" ); assertEquals( "date header is wrong", "Tue, 09 Dec 1969 12:00:00 GMT", headerValue ); @@ -225,8 +227,9 @@ ServletUnitHttpResponse servletResponse = new ServletUnitHttpResponse(); servletResponse.setContentType( "text/html" ); - SimpleDateFormat df = new SimpleDateFormat( "MM/dd/yyyy z" ); - Date date = df.parse( "12/9/1969 GMT" ); + // RFC1123_DATE_SPEC format + SimpleDateFormat df = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss z" ); + Date date = df.parse( "12/9/1969 12:00:00 GMT" ); servletResponse.addHeader( "list", "over-rideme" ); servletResponse.setHeader( "list", "foo" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 12:09:15
|
Revision: 1030 http://httpunit.svn.sourceforge.net/httpunit/?rev=1030&view=rev Author: wolfgang_fahl Date: 2009-08-17 12:09:08 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Header added Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java trunk/httpunit/test/com/meterware/httpunit/javascript/FrameScriptingTest.java trunk/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java trunk/httpunit/test/com/meterware/httpunit/javascript/JavaScriptTestSuite.java trunk/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java 2009-08-17 12:05:41 UTC (rev 1029) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java 2009-08-17 12:09:08 UTC (rev 1030) @@ -1,8 +1,9 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ + * $URL$ * - * Copyright (c) 2002-2008, Russell Gold + * Copyright (c) 2002-2009, 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 Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java 2009-08-17 12:05:41 UTC (rev 1029) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java 2009-08-17 12:09:08 UTC (rev 1030) @@ -1,8 +1,9 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ + * $URL$ * - * Copyright (c) 2002-2008, Russell Gold + * Copyright (c) 2002-2009, 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 Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/FrameScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/FrameScriptingTest.java 2009-08-17 12:05:41 UTC (rev 1029) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/FrameScriptingTest.java 2009-08-17 12:09:08 UTC (rev 1030) @@ -1,9 +1,10 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ +* $URL$ +* +* Copyright (c) 2003-2009, Russell Gold * -* Copyright (c) 2003-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 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java 2009-08-17 12:05:41 UTC (rev 1029) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java 2009-08-17 12:09:08 UTC (rev 1030) @@ -1,9 +1,10 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ + * $URL$ + * + * Copyright (c) 2002-2009, Russell Gold * - * Copyright (c) 2002-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 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/JavaScriptTestSuite.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/JavaScriptTestSuite.java 2009-08-17 12:05:41 UTC (rev 1029) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/JavaScriptTestSuite.java 2009-08-17 12:09:08 UTC (rev 1030) @@ -1,9 +1,9 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ + * $URL$ + * Copyright (c) 2002-2009, Russell Gold * - * Copyright (c) 2002-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 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and @@ -30,11 +30,19 @@ **/ public class JavaScriptTestSuite { + /** + * start the JUnit tests from here + * @param args + */ public static void main( String[] args ) { junit.textui.TestRunner.run( suite() ); } + /** + * collect the test suite for the java script tests + * @return + */ public static Test suite() { TestSuite result = new TestSuite(); result.addTest( ScriptingTest.suite() ); Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java 2009-08-17 12:05:41 UTC (rev 1029) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java 2009-08-17 12:09:08 UTC (rev 1030) @@ -1,9 +1,10 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ + * $URL$ + * + * Copyright (c) 2002-2009, 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 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 12:05:48
|
Revision: 1029 http://httpunit.svn.sourceforge.net/httpunit/?rev=1029&view=rev Author: wolfgang_fahl Date: 2009-08-17 12:05:41 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Header added Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-08-17 11:30:49 UTC (rev 1028) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-08-17 12:05:41 UTC (rev 1029) @@ -1,8 +1,9 @@ package com.meterware.httpunit.javascript; /******************************************************************************************************************** * $Id$ + * $URL$ * - * Copyright (c) 2002-2008, Russell Gold + * Copyright (c) 2002-2009, 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 11:31:01
|
Revision: 1028 http://httpunit.svn.sourceforge.net/httpunit/?rev=1028&view=rev Author: wolfgang_fahl Date: 2009-08-17 11:30:49 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Header added Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-17 11:29:47 UTC (rev 1027) +++ trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-17 11:30:49 UTC (rev 1028) @@ -1,7 +1,7 @@ package com.meterware.httpunit; /******************************************************************************************************************** * $Id$ - * $URL* + * $URL$* * * Copyright (c) 2002-2009, Russell Gold * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 11:29:53
|
Revision: 1027 http://httpunit.svn.sourceforge.net/httpunit/?rev=1027&view=rev Author: wolfgang_fahl Date: 2009-08-17 11:29:47 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Header added Property Changed: ---------------- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java Property changes on: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Id Author HeadURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-08-17 11:22:23
|
Revision: 1026 http://httpunit.svn.sourceforge.net/httpunit/?rev=1026&view=rev Author: wolfgang_fahl Date: 2009-08-17 11:22:14 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Header added Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-11 13:13:44 UTC (rev 1025) +++ trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-08-17 11:22:14 UTC (rev 1026) @@ -1,8 +1,9 @@ package com.meterware.httpunit; /******************************************************************************************************************** * $Id$ + * $URL* * - * Copyright (c) 2002-2008, Russell Gold + * Copyright (c) 2002-2009, 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rus...@us...> - 2009-08-11 13:13:51
|
Revision: 1025 http://httpunit.svn.sourceforge.net/httpunit/?rev=1025&view=rev Author: russgold Date: 2009-08-11 13:13:44 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Bug: Need to use 24-hour format for date headers Modified Paths: -------------- trunk/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java Modified: trunk/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java =================================================================== --- trunk/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java 2009-06-29 15:49:54 UTC (rev 1024) +++ trunk/httpunit/src/com/meterware/servletunit/ServletUnitHttpResponse.java 2009-08-11 13:13:44 UTC (rev 1025) @@ -38,7 +38,7 @@ class ServletUnitHttpResponse implements HttpServletResponse { // rfc1123-date is "Sun, 06 Nov 1994 08:49:37 GMT" - private static final String RFC1123_DATE_SPEC = "EEE, dd MMM yyyy hh:mm:ss z"; + private static final String RFC1123_DATE_SPEC = "EEE, dd MMM yyyy HH:mm:ss z"; private boolean _committed; private Locale _locale = Locale.getDefault(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-06-29 15:49:59
|
Revision: 1024 http://httpunit.svn.sourceforge.net/httpunit/?rev=1024&view=rev Author: wolfgang_fahl Date: 2009-06-29 15:49:54 +0000 (Mon, 29 Jun 2009) Log Message: ----------- more settings changed Modified Paths: -------------- trunk/httpunit/.settings/org.eclipse.jdt.core.prefs Modified: trunk/httpunit/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/httpunit/.settings/org.eclipse.jdt.core.prefs 2009-06-29 15:46:18 UTC (rev 1023) +++ trunk/httpunit/.settings/org.eclipse.jdt.core.prefs 2009-06-29 15:49:54 UTC (rev 1024) @@ -1,4 +1,4 @@ -#Mon Jun 29 17:45:01 CEST 2009 +#Mon Jun 29 17:49:25 CEST 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 @@ -43,7 +43,7 @@ org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-06-29 15:46:22
|
Revision: 1023 http://httpunit.svn.sourceforge.net/httpunit/?rev=1023&view=rev Author: wolfgang_fahl Date: 2009-06-29 15:46:18 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Eclipse setting modified for lesser warnings Modified Paths: -------------- trunk/httpunit/.classpath trunk/httpunit/.settings/org.eclipse.jdt.core.prefs Modified: trunk/httpunit/.classpath =================================================================== --- trunk/httpunit/.classpath 2009-03-29 13:20:36 UTC (rev 1022) +++ trunk/httpunit/.classpath 2009-06-29 15:46:18 UTC (rev 1023) @@ -17,11 +17,6 @@ <classpathentry kind="var" path="MAVEN_REPOSITORY/javax/activation/activation/1.1/activation-1.1.jar"/> <classpathentry kind="var" path="MAVEN_REPOSITORY/javax/mail/mail/1.4/mail-1.4.jar"/> <classpathentry kind="lib" path="jars/maven-ant-tasks-2.0.9.jar"/> - <!-- Libaries needed to test [ 2264431 ] form.submit() sends multiple HTTP POSTS - <classpathentry kind="var" path="MAVEN_REPOSITORY/org/mortbay/jetty/jetty/6.1.4/jetty-6.1.4.jar"/> - <classpathentry kind="var" path="MAVEN_REPOSITORY/org/mortbay/jetty/jetty-naming/6.1.4/jetty-naming-6.1.4.jar"/> - <classpathentry kind="var" path="MAVEN_REPOSITORY/org/mortbay/jetty/jetty-plus/6.1.4/jetty-plus-6.1.4.jar"/> - <classpathentry kind="var" path="MAVEN_REPOSITORY/org/mortbay/jetty/jetty-util/6.1.4/jetty-util-6.1.4.jar"/> + <classpathentry kind="var" path="MAVEN_REPOSITORY"/> <classpathentry kind="output" path="bin"/> - --> </classpath> Modified: trunk/httpunit/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/httpunit/.settings/org.eclipse.jdt.core.prefs 2009-03-29 13:20:36 UTC (rev 1022) +++ trunk/httpunit/.settings/org.eclipse.jdt.core.prefs 2009-06-29 15:46:18 UTC (rev 1023) @@ -1,12 +1,70 @@ -#Thu Jun 05 20:38:34 CEST 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.source=1.3 +#Mon Jun 29 17:45:01 CEST 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=ignore +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=ignore +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.3 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rus...@us...> - 2009-03-29 13:20:48
|
Revision: 1022 http://httpunit.svn.sourceforge.net/httpunit/?rev=1022&view=rev Author: russgold Date: 2009-03-29 13:20:36 +0000 (Sun, 29 Mar 2009) Log Message: ----------- patch 1152036: don't request javascript when not enabled Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java trunk/httpunit/src/com/meterware/httpunit/WebConversation.java trunk/httpunit/src/com/meterware/httpunit/parsing/ScriptFilter.java Modified: trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java 2009-03-16 15:31:41 UTC (rev 1021) +++ trunk/httpunit/src/com/meterware/httpunit/ParsedHTML.java 2009-03-29 13:20:36 UTC (rev 1022) @@ -348,12 +348,11 @@ * @param element */ void interpretScriptElement( Element element ) { - // proposed patch 1152036 - // not enabled by wf...@bi... since it would brake - // com.meterware.httpunit.javascript.NekoEnhancedScriptingTest - testNoScriptSections - //if (!HttpUnitOptions.isScriptingEnabled()) { - // return; - //} + if (!HttpUnitOptions.isScriptingEnabled()) { + _enableNoScriptNodes = true; + return; + } + String script = getScript( element ); if (script != null) { try { Modified: trunk/httpunit/src/com/meterware/httpunit/WebConversation.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/WebConversation.java 2009-03-16 15:31:41 UTC (rev 1021) +++ trunk/httpunit/src/com/meterware/httpunit/WebConversation.java 2009-03-29 13:20:36 UTC (rev 1022) @@ -175,7 +175,7 @@ * @param headers */ private void sendHeaders( URLConnection connection, Dictionary headers ) { - boolean sendReferer = getClientProperties().isSendReferer(); + boolean sendReferer = getClientProperties().isSendReferer(); for (Enumeration e = headers.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); if ( sendReferer || !"referer".equalsIgnoreCase( key ) ) { Modified: trunk/httpunit/src/com/meterware/httpunit/parsing/ScriptFilter.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/parsing/ScriptFilter.java 2009-03-16 15:31:41 UTC (rev 1021) +++ trunk/httpunit/src/com/meterware/httpunit/parsing/ScriptFilter.java 2009-03-29 13:20:36 UTC (rev 1022) @@ -19,20 +19,16 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ -import java.io.IOException; -import java.io.StringReader; -import org.apache.xerces.xni.Augmentations; -import org.apache.xerces.xni.QName; -import org.apache.xerces.xni.XMLAttributes; -import org.apache.xerces.xni.XMLLocator; -import org.apache.xerces.xni.XMLString; -import org.apache.xerces.xni.XNIException; +import com.meterware.httpunit.HttpUnitOptions; +import org.apache.xerces.xni.*; import org.apache.xerces.xni.parser.XMLInputSource; - import org.cyberneko.html.HTMLConfiguration; import org.cyberneko.html.filters.DefaultFilter; +import java.io.IOException; +import java.io.StringReader; + /** * A filter to interpret JavaScript script blocks, based on the sample Scripts program provided by NekoHTML. * @@ -97,7 +93,7 @@ private boolean isSupportedScript( QName element, XMLAttributes attrs ) { if (!element.rawname.equalsIgnoreCase( "script" ) || attrs == null) return false; String value = getScriptLanguage( attrs ); - return _scriptHandler.supportsScriptLanguage( value ); + return HttpUnitOptions.isScriptingEnabled() && _scriptHandler.supportsScriptLanguage( value ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-03-16 15:31:59
|
Revision: 1021 http://httpunit.svn.sourceforge.net/httpunit/?rev=1021&view=rev Author: wolfgang_fahl Date: 2009-03-16 15:31:41 +0000 (Mon, 16 Mar 2009) Log Message: ----------- toLowerCase built in function added Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java Modified: trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java 2009-03-13 14:28:46 UTC (rev 1020) +++ trunk/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java 2009-03-16 15:31:41 UTC (rev 1021) @@ -375,6 +375,14 @@ public void jsFunction_alert( String message ) { getDelegate().alertUser( message ); } + + /** + * javascript built in function "toLowerCase" + * @param s + */ + public String jsFunction_toLowerCase(String s) { + return s.toLowerCase(); + } public boolean jsFunction_confirm( String message ) { Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-03-13 14:28:46 UTC (rev 1020) +++ trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2009-03-16 15:31:41 UTC (rev 1021) @@ -159,6 +159,21 @@ response.getLinkWith( "go" ).click(); assertEquals( "Alert message", "Cheese!", wc.popNextAlert() ); } + + /** + * test javascript call to built-in functions + * e.g. toLowerCase + */ + public void testJavaScriptWitBuiltInFunctions() throws Exception { + defineResource( "OnCommand.html", "<html>" + + "<body>" + + "<a href=\"javascript:alert(toLowerCase('Cheese!'))\">go</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + response.getLinkWith( "go" ).click(); + assertEquals( "Alert message", "cheese!", wc.popNextAlert() ); + } /** * test javascript call to an included function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-03-13 14:28:59
|
Revision: 1020 http://httpunit.svn.sourceforge.net/httpunit/?rev=1020&view=rev Author: wolfgang_fahl Date: 2009-03-13 14:28:46 +0000 (Fri, 13 Mar 2009) Log Message: ----------- patch by Serge Maslyukov to solve issue with drupal's cookie Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java Modified: trunk/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java 2009-02-26 19:26:36 UTC (rev 1019) +++ trunk/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java 2009-03-13 14:28:46 UTC (rev 1020) @@ -251,15 +251,43 @@ * Add the cookie to this jar, replacing any previous matching cookie. */ void addUniqueCookie( Cookie cookie ) { - _cookies.remove( cookie ); + _cookies.remove( cookie ); + for (Iterator i = _cookies.iterator(); i.hasNext();) { + Cookie c = (Cookie) i.next(); + if (c.getName().equals(cookie.getName())) { + if (compareDomain(c.getDomain(), cookie.getDomain())) { + if (c.getPath() != null && cookie.getPath() != null + && c.getPath().equals(cookie.getPath())) { + i.remove(); + } + } + } + } _cookies.add( cookie ); } + /** + * compare the two domains given for "cookie-equality" + * + * @param domain + * @param newDomain + * @return + */ + private boolean compareDomain(String domain, String newDomain) { + if (domain.charAt(0) == '.' && newDomain.endsWith(domain)) { + return true; + } + if (newDomain.charAt(0) == '.' && domain.endsWith(newDomain)) { + return true; + } + + return domain.equals(newDomain); + } /** - * base class for the cookie recipies - there are two different implementations - * of this - */ + * base class for the cookie recipies - there are two different + * implementations of this + */ abstract class CookieRecipe { /** Modified: trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2009-02-26 19:26:36 UTC (rev 1019) +++ trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2009-03-13 14:28:46 UTC (rev 1020) @@ -190,8 +190,7 @@ 0}; for (int i = 0; i < ages.length; i++) { - String index = "" + i; - String cookieName = "cookie" + index.trim(); + String cookieName = "cookie" + i; String header = cookieName + "=cookievalue;" + ages[i]; TestSource source = new TestSource( new URL( "http://www.somedomain.com/somepath/" ), header ); CookieJar jar = new CookieJar( source ); @@ -229,6 +228,44 @@ } /** + * + * @throws Exception + */ + public void testDrupalCookieInteraction() throws Exception { + CookieJar jar = new CookieJar(); + jar.putSingleUseCookie("SESS1234","1234",".drupalsite.org","/"); + Cookie cookie=jar.getCookie("SESS1234"); + assertTrue(cookie!=null); + assertEquals(cookie.getDomain(),".drupalsite.org"); + assertEquals(cookie.getValue(),"1234"); + assertEquals(cookie.getPath(),"/"); + assertEquals(1, jar.getCookies().size()); + + CookieJar jar1 = new CookieJar(); + jar1.putSingleUseCookie("SESS1234", "deleted", "www.drupalsite.org","/"); + jar.updateCookies( jar1 ); + + cookie=jar.getCookie("SESS1234"); + assertTrue(cookie!=null); + assertEquals(cookie.getDomain(),"www.drupalsite.org"); + assertEquals(cookie.getValue(),"deleted"); + assertEquals(cookie.getPath(),"/"); + assertEquals(1, jar.getCookies().size()); + + CookieJar jar2 = new CookieJar(); + jar2.putSingleUseCookie("SESS1234", "4321", ".drupalsite.org","/"); + jar.updateCookies( jar2 ); + + cookie=jar.getCookie("SESS1234"); + assertTrue(cookie!=null); + assertEquals(cookie.getDomain(),".drupalsite.org"); + assertEquals(cookie.getValue(),"4321"); + assertEquals(cookie.getPath(),"/"); + assertEquals(1, jar.getCookies().size()); + + } + + /** * test for [ 1488617 ] alternate patch for cookie bug #1371204 * @throws Exception */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-02-26 19:26:41
|
Revision: 1019 http://httpunit.svn.sourceforge.net/httpunit/?rev=1019&view=rev Author: wolfgang_fahl Date: 2009-02-26 19:26:36 +0000 (Thu, 26 Feb 2009) Log Message: ----------- Negotiate Header should not spoil Authentication -- null pointer problem removed Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/AuthenticationChallenge.java trunk/httpunit/src/com/meterware/httpunit/HttpHeader.java trunk/httpunit/src/com/meterware/httpunit/WebClient.java trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java Modified: trunk/httpunit/src/com/meterware/httpunit/AuthenticationChallenge.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/AuthenticationChallenge.java 2009-02-26 16:45:33 UTC (rev 1018) +++ trunk/httpunit/src/com/meterware/httpunit/AuthenticationChallenge.java 2009-02-26 19:26:36 UTC (rev 1019) @@ -23,6 +23,8 @@ import java.net.MalformedURLException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Dictionary; +import java.util.Enumeration; import java.io.UnsupportedEncodingException; @@ -49,18 +51,24 @@ _request = request; } - + /** + * check whether authentication is needed + * @return + */ boolean needToAuthenticate() { if (getAuthenticationType() == null) return false; if (getCredentialsForRealm() != null) return true; - if (!_client.getExceptionsThrownOnErrorStatus()) return false; - + if (!_client.getExceptionsThrownOnErrorStatus()) return false;; + throw createAuthorizationRequiredException(); } private String getAuthenticationType() { - return getLabel(); + String result=getLabel(); + if (_headerString!=null && _headerString.equals("Negotiate")) + result=null; + return result; } @@ -82,8 +90,16 @@ } + /** + * get the credentials for the realm property + * @return + */ private PasswordAuthentication getCredentialsForRealm() { - return _client.getCredentialsForRealm( getProperty( "realm" ) ); + String realm=getProperty( "realm" ); + PasswordAuthentication result=null; + if (realm!=null) + result=_client.getCredentialsForRealm( realm ); + return result; } private String getMethod() { Modified: trunk/httpunit/src/com/meterware/httpunit/HttpHeader.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/HttpHeader.java 2009-02-26 16:45:33 UTC (rev 1018) +++ trunk/httpunit/src/com/meterware/httpunit/HttpHeader.java 2009-02-26 19:26:36 UTC (rev 1019) @@ -28,15 +28,26 @@ private String _label; private Map _properties; + protected String _headerString; + /** + * construct a HttpHeader from the given headerString + * @param headerString + */ public HttpHeader( String headerString ) { this( headerString, null ); } + /** + * construct a HttpHeader from the given headerString and label + * @param headerString + * @param defaultLabel + */ public HttpHeader( String headerString, String defaultLabel ) { if (headerString != null) { + _headerString=headerString; final int index = headerString.indexOf( ' ' ); if (index < 0) { // non-conforming header _label = defaultLabel; Modified: trunk/httpunit/src/com/meterware/httpunit/WebClient.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/WebClient.java 2009-02-26 16:45:33 UTC (rev 1018) +++ trunk/httpunit/src/com/meterware/httpunit/WebClient.java 2009-02-26 19:26:36 UTC (rev 1019) @@ -261,8 +261,20 @@ } + /** + * get the credentials for the given realm + * @param realm + * @return + */ PasswordAuthentication getCredentialsForRealm( String realm ) { - return ((PasswordAuthentication) _credentials.get( realm )); + if (_credentials==null) { + throw new Error("null _credentials while calling getCredentialsForRealm"); + } + if (realm==null) { + throw new Error("null realm while calling getCredentialsForRealm"); + } + PasswordAuthentication result=((PasswordAuthentication) _credentials.get( realm )); + return result; } /** Modified: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-02-26 16:45:33 UTC (rev 1018) +++ trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-02-26 19:26:36 UTC (rev 1019) @@ -384,8 +384,32 @@ assertEquals( "bogusrealm", e.getAuthenticationParameter( "realm" ) ); } } + + /** + * test the Negotiate Header does not spoil authentication + * @throws Exception + */ + public void testAuthenticationNegotiateRequest() throws Exception { + defineResource( "getAuthorization", new PseudoServlet() { + public WebResource getGetResponse() { + String header = getHeader( "Authorization" ); + if (header == null) { + WebResource webResource = new WebResource( "unauthorized" ); + webResource.addHeader( "WWW-Authenticate: Negotiate"); + return webResource; + } else { + return new WebResource( header, "text/plain" ); + } + } + } ); + WebConversation wc = new WebConversation(); + wc.setAuthentication( "testrealm", "user", "password" ); + WebResponse wr = wc.getResponse( getHostPath() + "/getAuthorization" ); + assertEquals( "authorization", "unauthorized", wr.getText() ); + } + public void suspendtestProxyServerAccessWithAuthentication() throws Exception { defineResource( "http://someserver.com/sample", new PseudoServlet() { public WebResource getGetResponse() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2009-02-26 16:45:45
|
Revision: 1018 http://httpunit.svn.sourceforge.net/httpunit/?rev=1018&view=rev Author: wolfgang_fahl Date: 2009-02-26 16:45:33 +0000 (Thu, 26 Feb 2009) Log Message: ----------- comment added Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2008-12-18 20:33:16 UTC (rev 1017) +++ trunk/httpunit/test/com/meterware/httpunit/WebClientTest.java 2009-02-26 16:45:33 UTC (rev 1018) @@ -330,6 +330,10 @@ } + /** + * test on demand Basic Authentication + * @throws Exception + */ public void testOnDemandBasicAuthentication() throws Exception { defineResource( "getAuthorization", new PseudoServlet() { public WebResource getGetResponse() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2008-12-18 20:33:24
|
Revision: 1017 http://httpunit.svn.sourceforge.net/httpunit/?rev=1017&view=rev Author: wolfgang_fahl Date: 2008-12-18 20:33:16 +0000 (Thu, 18 Dec 2008) Log Message: ----------- new testcase according to discussion with James Courtney Modified Paths: -------------- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java Modified: trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java =================================================================== --- trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2008-12-14 22:20:00 UTC (rev 1016) +++ trunk/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java 2008-12-18 20:33:16 UTC (rev 1017) @@ -303,6 +303,8 @@ checkAcceptance( 1, true, "www.some.meterware.com/servlets/special", ".meterware.com", null ); checkAcceptance( 2, false, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); checkAcceptance( 3, true, "www.meterware.com/servlets/special", "www.meterware.com", null ); + // missing leading dot case (yahoo cookies seem to behave like this - seems to be non RFC 2109 compliant ...) + checkAcceptance( 4, true, "www.meterware.com/servlets/special", "meterware.com", null ); CookieProperties.setPathMatchingStrict( false ); checkAcceptance( 11, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wol...@us...> - 2008-12-14 22:20:08
|
Revision: 1016 http://httpunit.svn.sourceforge.net/httpunit/?rev=1016&view=rev Author: wolfgang_fahl Date: 2008-12-14 22:20:00 +0000 (Sun, 14 Dec 2008) Log Message: ----------- comment added Modified Paths: -------------- trunk/httpunit/src/com/meterware/httpunit/cookies/Cookie.java Modified: trunk/httpunit/src/com/meterware/httpunit/cookies/Cookie.java =================================================================== --- trunk/httpunit/src/com/meterware/httpunit/cookies/Cookie.java 2008-12-02 22:14:56 UTC (rev 1015) +++ trunk/httpunit/src/com/meterware/httpunit/cookies/Cookie.java 2008-12-14 22:20:00 UTC (rev 1016) @@ -236,6 +236,12 @@ } + /** + * accept path for the given hostpath + * @param pathPattern + * @param hostPath + * @return true - either if PathMatching is not strict or the hostpath starts with the given path pattern + */ private boolean acceptPath( String pathPattern, String hostPath ) { return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |