httpunit-commit Mailing List for httpunit (Page 64)
Brought to you by:
russgold
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
From: Russell G. <rus...@us...> - 2002-03-03 23:00:03
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv18648/doc Modified Files: release_notes.txt Log Message: from Donald Ball: ServletUnit enhancements Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.93 retrieving revision 1.94 diff -u -r1.93 -r1.94 --- release_notes.txt 1 Mar 2002 18:09:04 -0000 1.93 +++ release_notes.txt 3 Mar 2002 22:59:59 -0000 1.94 @@ -19,7 +19,10 @@ Thanks to Alex Chaffee for implementing context parameters for web.xml in ServletUnit Thanks to Jochen Hiller for supplying code to use jaxp to select a parser rather than being hardcoded to xerces Thanks to Oliver Imbusch for adding the WebClientListener behavior + Thanks to Donald Ball for numerous additions to ServletUnit, including support for context paths, retrieval of + the requestURI for a servlet request, and wild-card mapping of servlets. Thanks to Peter Royal for correcting handling of long line numbers in JTidyWriter, based on locale + Thanks to Peter Rossbach for some documentation and build fixes Problems fixed: 1. hasParameterNamed and hasParameterStartingWithPrefix now check all types of parameters, not just <INPUT> fields @@ -32,6 +35,7 @@ 8. Parameter validation is now done for requests built from links 9. Control characters and spaces created by breaking HTML in the middle are now trimmed from link parameters. 10. Forms with query strings included in the action attribute now are submitted with that string intact. + 11. (bug #490821) Javadoc generation no longer gives errors Additions: Content and parsing enhancements: @@ -44,23 +48,26 @@ 4. ServletUnit now supports creating a RequestDispatcher from ServletContext to forward to other servlets. Support for this is rudimentary at present: query parameters on the request dispatcher create are ignored. 5. ServletUnit now supports the web.xml <context-param> tag. + 6. ServletUnit now supports the HttpServletRequest.getRequestURI method + 7. ServletUnit now supports defining (and retrieving) a non-empty context path for a web application + 8. ServletUnit now supports wild-cards in web.xml servlet mapping Form manipulation enhancements: - 6. It is now possible to set values for a form directly into the WebForm object. All such changes will be validated. + 9. It is now possible to set values for a form directly into the WebForm object. All such changes will be validated. These will be used by any requests derived from the form. - 7. Parameters defined in form query strings are now included in the known parameters of a form and requests + 10. Parameters defined in form query strings are now included in the known parameters of a form and requests built from it. - 8. Form parameters can be reset to their initial values using WebForm.reset(). + 11. Form parameters can be reset to their initial values using WebForm.reset(). Test properties enhancements: - 9. You can now call HttpUnitOptions.setAutoRedirect( false ) to enable explicit testing of redirect requests. - 10. WebClient now has an exceptionsThrownOnErrorStatus property to control this behavior per client. + 12. You can now call HttpUnitOptions.setAutoRedirect( false ) to enable explicit testing of redirect requests. + 13. WebClient now has an exceptionsThrownOnErrorStatus property to control this behavior per client. Extensibility enhancements: - 11. HttpUnit can now use any jaxp-compliant parser, rather than just xerces. - 12. MessageBodyWebRequest's constructors and inner class are now public, allowing outside code to create new request classes. - 13. WebClient now exposes the protected method writeMessageBody to ease implementation of new subclasses - 14. WebClient can now accept a listener of type WebClientListener to report on each request sent and response received. + 14. HttpUnit can now use any jaxp-compliant parser, rather than just xerces. + 15. MessageBodyWebRequest's constructors and inner class are now public, allowing outside code to create new request classes. + 16. WebClient now exposes the protected method writeMessageBody to ease implementation of new subclasses + 17. WebClient can now accept a listener of type WebClientListener to report on each request sent and response received. Notes: 1. Parameter validation is now handled by the form. Requests created from the form while parameter validation is |
From: Russell G. <rus...@us...> - 2002-03-03 22:59:32
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv18502/jars Modified Files: jars.txt Log Message: from Pete Rossbach: documentation and build updates Index: jars.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/jars.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- jars.txt 3 Dec 2001 20:00:16 -0000 1.1 +++ jars.txt 3 Mar 2002 22:59:29 -0000 1.2 @@ -1,6 +1,11 @@ Jars used: +(runtime) junit 3.7 servlet 2.3 xerces 1.2.3 -jtidy 04aug2000r5 \ No newline at end of file +jtidy 04aug2000r5 + +(for testing HttpUnit only) +mail (javamail 1.2) +activation (jaf 1.0.1) |
From: Russell G. <rus...@us...> - 2002-03-03 22:59:32
|
Update of /cvsroot/httpunit/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv18502 Modified Files: build.xml Log Message: from Pete Rossbach: documentation and build updates Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- build.xml 22 Feb 2002 15:49:04 -0000 1.40 +++ build.xml 3 Mar 2002 22:59:28 -0000 1.41 @@ -144,7 +144,9 @@ <javadoc packagenames="${packages}" sourcepath="${basedir}/${src.dir}" destdir="${javadoc.dir}" author="true" version="true" windowtitle="${Name} ${version} API" doctitle="${Name}" - footer="Copyright &copy; 2000-2001 Russell Gold. See <a href="http://httpunit.sourceforge.net/doc/license.html">license agreement</A> for rights granted." /> + footer="Copyright &copy; 2000-2002 Russell Gold. See <a href="http://httpunit.sourceforge.net/doc/license.html">license agreement</A> for rights granted." > + <classpath refid="base.classpath"/> + </javadoc> </target> |
From: Russell G. <rus...@us...> - 2002-03-01 18:09:09
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv19499/test/com/meterware/httpunit Modified Files: FormSubmitTest.java JTidyPrintWriterTest.java Log Message: from Peter Royal: fixed JTidyWriter column parsing Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- FormSubmitTest.java 14 Jan 2002 18:13:45 -0000 1.13 +++ FormSubmitTest.java 1 Mar 2002 18:09:04 -0000 1.14 @@ -229,7 +229,7 @@ assertEquals( getHostPath() + "/ask?age=12&update=name&update.x=10&update.y=15", request.getURL().toExternalForm() ); } - + public void testSubmitButtonAttributes() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + Index: JTidyPrintWriterTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/JTidyPrintWriterTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JTidyPrintWriterTest.java 12 Dec 2001 17:27:22 -0000 1.2 +++ JTidyPrintWriterTest.java 1 Mar 2002 18:09:05 -0000 1.3 @@ -68,10 +68,10 @@ URL url = new URL("http://localhost/blank.html"); PrintWriter p = new JTidyPrintWriter(url); p.print("line 1234 column 1234"); - p.print("line 1.234 column 1.234"); - p.print("line 1.234.567 column 1.234.567"); - p.print("line 1.2.34 column 12.34"); - p.print("line 123..4 column 12..34"); + p.print("line 1,234 column 1,234"); + p.print("line 1,234,567 column 1,234,567"); + p.print("line 1,2,34 column 12,34"); + p.print("line 123,,4 column 12,,34"); } public void testWrongXHTMLPage() throws Exception { |
From: Russell G. <rus...@us...> - 2002-03-01 18:09:09
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv19499/src/com/meterware/httpunit Modified Files: JTidyPrintWriter.java Log Message: from Peter Royal: fixed JTidyWriter column parsing Index: JTidyPrintWriter.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/JTidyPrintWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JTidyPrintWriter.java 12 Dec 2001 17:27:22 -0000 1.2 +++ JTidyPrintWriter.java 1 Mar 2002 18:09:04 -0000 1.3 @@ -23,6 +23,9 @@ import java.util.Enumeration; import java.io.PrintWriter; import java.net.URL; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.ParseException; /** * Basic "parser" for the JTidy error output. Will get the line and column number as well @@ -30,8 +33,16 @@ * called or if a string starts with "line" * * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a> + * @author <a href="mailto:pr...@ma...">Peter Royal</a> **/ class JTidyPrintWriter extends PrintWriter { + /** + * DecimalFormat.getNumberInstance() should provide us with a proper formatter for the default locale. The + * integers returned from JTidy contain the appropriate decimal separator for the current locale. + */ + private static final NumberFormat INTEGER_FORMAT = DecimalFormat.getNumberInstance(); + + JTidyPrintWriter( URL pageURL ) { super(System.out); _url = pageURL; @@ -70,21 +81,6 @@ } /** - * Tidy is apparently returning line number in a format x.xxx remove the dots - **/ - private String removeDots(String string) - { - StringTokenizer tok = new StringTokenizer(string,"."); - StringBuffer buf = new StringBuffer(); - String elem; - while(tok.hasMoreElements()) { - elem = tok.nextToken(); - buf.append(elem); - } - return buf.toString(); - } - - /** * Detects a new log if starting with "line", a warning if message starts with "Warning" * and an error if it starts with "Error" **/ @@ -98,11 +94,11 @@ // skip first "line" tok.nextToken(); // get line - _line = Integer.parseInt(removeDots(tok.nextToken())); + _line = parseInteger(tok.nextToken()); // skip second "column" tok.nextToken(); // get column - _column = Integer.parseInt(removeDots(tok.nextToken())); + _column = parseInteger(tok.nextToken()); } else if (s.startsWith("Warning")) { _error = false; _msg = s; @@ -114,6 +110,16 @@ _msg += s; } } + + + private int parseInteger( String integer ) { + try { + return INTEGER_FORMAT.parse( integer ).intValue(); + } catch (ParseException e) { + throw new NumberFormatException( "Unable to parse integer [int: " + integer + ", error: " + e.getMessage() ); + } + } + public void println() { if (!_logged) { |
From: Russell G. <rus...@us...> - 2002-03-01 18:09:09
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv19499/doc Modified Files: release_notes.txt Log Message: from Peter Royal: fixed JTidyWriter column parsing Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.92 retrieving revision 1.93 diff -u -r1.92 -r1.93 --- release_notes.txt 28 Feb 2002 14:30:33 -0000 1.92 +++ release_notes.txt 1 Mar 2002 18:09:04 -0000 1.93 @@ -12,13 +12,14 @@ Revision History: -28-Feb-2000 + 1-Mar-2002 Acknowledgements: Thanks to Didier Besset for correcting the WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix Thanks to Stefan G. Renz for identifying the infinite loop bug in frame handling Thanks to Alex Chaffee for implementing context parameters for web.xml in ServletUnit Thanks to Jochen Hiller for supplying code to use jaxp to select a parser rather than being hardcoded to xerces Thanks to Oliver Imbusch for adding the WebClientListener behavior + Thanks to Peter Royal for correcting handling of long line numbers in JTidyWriter, based on locale Problems fixed: 1. hasParameterNamed and hasParameterStartingWithPrefix now check all types of parameters, not just <INPUT> fields |
From: Russell G. <rus...@us...> - 2002-03-01 06:08:27
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv1888/com/meterware/servletunit Modified Files: ServletRunner.java ServletUnitContext.java ServletUnitHttpRequest.java ServletUnitServletConfig.java ServletUnitServletContext.java WebApplication.java Log Message: from Donald Ball: ServletUnit enhancements Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ServletRunner.java 4 Feb 2002 22:33:55 -0000 1.12 +++ ServletRunner.java 1 Mar 2002 06:08:24 -0000 1.13 @@ -25,6 +25,7 @@ import com.meterware.httpunit.HttpInternalErrorException; import com.meterware.httpunit.HttpUnitUtils; +import java.io.File; import java.io.InputStream; import java.io.IOException; import java.net.MalformedURLException; @@ -49,25 +50,47 @@ * Default constructor, which defines no servlets. */ public ServletRunner() { + _context = new ServletUnitContext(); _application = new WebApplication(); } - /** - * Constructor which expects the full path to the web.xml for the application. - **/ - public ServletRunner( String webXMLFileSpec ) throws IOException, SAXException { - _application = new WebApplication( HttpUnitUtils.newParser().parse( webXMLFileSpec ) ); + * Constructor which expects the full path to the web.xml for the + * application. + * + * @param webXMLFileSpec the full path to the web.xml file + */ + public ServletRunner( String webXMLFileSpec) throws IOException, SAXException { + this(webXMLFileSpec, null); } + /** + * Constructor which expects the full path to the web.xml for the + * application and a context path under which to mount it. + * + * @param webXMLFileSpec the full path to the web.xml file + * @param contextPath the context path + */ + public ServletRunner( String webXMLFileSpec, String contextPath ) throws IOException, SAXException { + _context = new ServletUnitContext(contextPath); + File webXMLFile = new File(webXMLFileSpec); + _application = new WebApplication(HttpUnitUtils.newParser().parse( webXMLFileSpec ), webXMLFile.getParentFile().getParentFile(), _context.getContextPath()); + } /** * Constructor which expects an input stream containing the web.xml for the application. **/ public ServletRunner( InputStream webXML ) throws IOException, SAXException { - _application = new WebApplication( HttpUnitUtils.newParser().parse( new InputSource( webXML ) ) ); + this(webXML, null); } + /** + * Constructor which expects an input stream containing the web.xml for the application. + **/ + public ServletRunner( InputStream webXML, String contextPath ) throws IOException, SAXException { + _context = new ServletUnitContext(contextPath); + _application = new WebApplication( HttpUnitUtils.newParser().parse( new InputSource( webXML ) ), _context.getContextPath()); + } /** * Registers a servlet class to be run. @@ -122,7 +145,7 @@ private ServletUnitClient _client; - private ServletUnitContext _context = new ServletUnitContext(); + private ServletUnitContext _context; private InvocationContextFactory _factory = new InvocationContextFactory() { public InvocationContext newInvocation( WebRequest request, Cookie[] clientCookies, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { Index: ServletUnitContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ServletUnitContext.java 21 Nov 2000 20:44:59 -0000 1.1 +++ ServletUnitContext.java 1 Mar 2002 06:08:24 -0000 1.2 @@ -25,6 +25,13 @@ class ServletUnitContext { + ServletUnitContext() { + _contextPath = ""; + } + + ServletUnitContext(String contextPath) { + _contextPath = (contextPath != null ? contextPath : ""); + } /** * Returns the session with the specified ID, if any. @@ -43,11 +50,20 @@ return result; } + /** + * Returns the contextPath + */ + String getContextPath() { + return _contextPath; + } + //------------------------------- private members --------------------------- private Hashtable _sessions = new Hashtable(); + + private String _contextPath = null; } Index: ServletUnitHttpRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ServletUnitHttpRequest.java 6 Feb 2002 18:38:13 -0000 1.9 +++ ServletUnitHttpRequest.java 1 Mar 2002 06:08:24 -0000 1.10 @@ -226,11 +226,13 @@ * Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. **/ public String getRequestURI() { - throwNotImplementedYet(); - return ""; + try { + return _request.getURL().getPath(); + } catch (MalformedURLException e) { + return null; + } } - /** * Returns the current HttpSession associated with this request or, if there is no current session * and create is true, returns a new session. @@ -586,7 +588,7 @@ * this method returns "". **/ public java.lang.String getContextPath() { - throw new RuntimeException( "getContextPath not implemented" ); + return _context.getContextPath(); } Index: ServletUnitServletConfig.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ServletUnitServletConfig.java 30 Jan 2002 21:21:11 -0000 1.4 +++ ServletUnitServletConfig.java 1 Mar 2002 06:08:24 -0000 1.5 @@ -19,6 +19,7 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import java.io.File; import java.util.Enumeration; import java.util.Hashtable; @@ -33,10 +34,10 @@ class ServletUnitServletConfig implements ServletConfig { - ServletUnitServletConfig( Servlet servlet, WebApplication application, Hashtable initParams, Hashtable contextParams ) { + ServletUnitServletConfig( Servlet servlet, WebApplication application, Hashtable initParams, Hashtable contextParams, File contextDir ) { _name = servlet.getClass().getName(); _initParameters = initParams; - _context = new ServletUnitServletContext( application, contextParams ); + _context = new ServletUnitServletContext( application, contextParams, contextDir ); } @@ -83,4 +84,5 @@ private final Hashtable _initParameters; private final ServletContext _context; + } Index: ServletUnitServletContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitServletContext.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ServletUnitServletContext.java 30 Jan 2002 21:21:11 -0000 1.7 +++ ServletUnitServletContext.java 1 Mar 2002 06:08:24 -0000 1.8 @@ -20,6 +20,8 @@ * *******************************************************************************************************************/ +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.net.URL; @@ -39,9 +41,10 @@ **/ class ServletUnitServletContext implements ServletContext { - ServletUnitServletContext( WebApplication application, Hashtable contextParams ) { + ServletUnitServletContext( WebApplication application, Hashtable contextParams, File contextDir ) { _application = application; _contextParams = contextParams; + _contextDir = contextDir; } @@ -108,7 +111,16 @@ * method does not use class loaders. **/ public java.net.URL getResource( String path ) { - return null; // XXX not implemented + if (_contextDir == null) { + return null; // no context, but maybe try against working dir? + } else { + try { + File resourceFile = new File(_contextDir, path.substring(1)); + return resourceFile.toURL(); + } catch (IOException e) { + return null; + } + } } @@ -126,7 +138,16 @@ * containers to make a resource available to a servlet from any location, without using a class loader. **/ public java.io.InputStream getResourceAsStream( String path ) { - return null; // XXX not implemented + if (_contextDir == null) { + return null; // no context, but maybe try against working dir? + } else { + try { + File resourceFile = new File(_contextDir, path.substring(1)); + return new FileInputStream(resourceFile); + } catch (IOException e) { + return null; + } + } } @@ -346,4 +367,5 @@ private Hashtable _attributes = new Hashtable(); private WebApplication _application; private Hashtable _contextParams = new Hashtable(); + private File _contextDir; } Index: WebApplication.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WebApplication.java 30 Jan 2002 21:21:11 -0000 1.4 +++ WebApplication.java 1 Mar 2002 06:08:24 -0000 1.5 @@ -22,6 +22,7 @@ import com.meterware.httpunit.HttpInternalErrorException; import com.meterware.httpunit.HttpNotFoundException; +import java.io.File; import java.io.IOException; import java.io.PrintWriter; @@ -30,8 +31,10 @@ import java.util.ArrayList; import java.util.Dictionary; +import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; +import java.util.Map; import javax.servlet.Servlet; import javax.servlet.ServletException; @@ -47,7 +50,8 @@ /** - * This class represents the information recorded about a single web application. It is usually extracted from web.xml. + * This class represents the information recorded about a single web + * application. It is usually extracted from web.xml. * * @author <a href="mailto:rus...@ac...">Russell Gold</a> **/ @@ -57,19 +61,42 @@ /** * Constructs a default application spec with no information. */ - WebApplication() {} + WebApplication() { + _contextPath = ""; + } + /** + * Constructs an application spec from an XML document. + */ + WebApplication(Document document) throws MalformedURLException,SAXException { + this(document, null, ""); + } + + /** + * Constructs an application spec from an XML document. + */ + WebApplication(Document document, String contextPath) throws MalformedURLException,SAXException { + this(document, null, contextPath); + } /** * Constructs an application spec from an XML document. */ - WebApplication( Document document ) throws MalformedURLException,SAXException { + WebApplication(Document document, File file) throws MalformedURLException,SAXException { + this(document, null, ""); + } + + /** + * Constructs an application spec from an XML document. + */ + WebApplication(Document document, File file, String contextPath) throws MalformedURLException,SAXException { + _contextDir = file; + _contextPath = contextPath; registerServlets( document ); NodeList nl = document.getElementsByTagName( "security-constraint" ); for (int i = 0; i < nl.getLength(); i++) { _securityConstraints.add( new SecurityConstraintImpl( (Element) nl.item(i) ) ); } - extractContextParameters( document ); extractLoginConfiguration( document ); } @@ -86,7 +113,11 @@ * Registers a servlet to be run. **/ void registerServlet( String resourceName, ServletConfiguration servletConfiguration ) { - _servlets.put( asResourceName( resourceName ), servletConfiguration ); + // FIXME - shouldn't everything start with one or the other? + if (!resourceName.startsWith("/") && !resourceName.startsWith("*")) { + resourceName = "/"+resourceName; + } + _servletMapping.put( resourceName, servletConfiguration); } @@ -99,7 +130,7 @@ if (!Servlet.class.isAssignableFrom( servletClass )) throw new HttpInternalErrorException( url ); Servlet servlet = (Servlet) servletClass.newInstance(); // XXX cache instances - by class? - servlet.init( new ServletUnitServletConfig( servlet, this, configuration.getInitParams(), _contextParameters ) ); + servlet.init( new ServletUnitServletConfig( servlet, this, configuration.getInitParams(), _contextParameters, _contextDir ) ); return servlet; } catch (ClassNotFoundException e) { throw new HttpNotFoundException( url, e ); @@ -112,17 +143,27 @@ private ServletConfiguration getServletConfiguration(URL url) { + if (!url.getFile().startsWith(_contextPath)) { + return null; + } String servletName = getServletName( getURLPath( url ) ); if (servletName.endsWith( "j_security_check" )) { return SECURITY_CHECK_CONFIGURATION; } else { - return (ServletConfiguration) _servlets.get( servletName ); + return _servletMapping.get( servletName ); } } private String getURLPath( URL url ) { - return url.getFile(); + String file = url.getFile(); + if (_contextPath.equals("")) { + return file; + } else if (file.startsWith(_contextPath)) { + return file.substring(_contextPath.length()); + } else { + return null; + } } @@ -188,7 +229,7 @@ private final static ServletConfiguration SECURITY_CHECK_CONFIGURATION = new ServletConfiguration( SecurityCheckServlet.class.getName() ); /** A mapping of resource names to servlet class names. **/ - private Hashtable _servlets = new Hashtable(); + private ServletMapping _servletMapping = new ServletMapping(); private ArrayList _securityConstraints = new ArrayList(); @@ -204,6 +245,10 @@ private Hashtable _contextParameters = new Hashtable(); + private File _contextDir = null; + + private String _contextPath = null; + final static private SecurityConstraint NULL_SECURITY_CONSTRAINT = new NullSecurityConstraint(); @@ -422,6 +467,117 @@ private ArrayList _urlPatterns = new ArrayList(); } + } + + /** + * A utility class for mapping servlets to url patterns. This implements the + * matching algorithm documented in section 10 of the JSDK-2.2 reference. + * + * @author <a href="ba...@we...">Donald Ball</a> + * @version $Revision$ + */ + class ServletMapping { + + private final Map exactMatches = new HashMap(); + private final Map extensions = new HashMap(); + private final Map urlTree = new HashMap(); + + void put(String mapping, ServletConfiguration servletConfiguration) { + if (mapping.indexOf('*') == -1) { + exactMatches.put(mapping, servletConfiguration); + } else if (mapping.startsWith("*.")) { + extensions.put(mapping.substring(2), servletConfiguration); + } else { + ParsedPath path = new ParsedPath(mapping); + Map context = urlTree; + while (path.hasNext()) { + String part = path.next(); + if (part.equals("*")) { + context.put("*", servletConfiguration); + return; + } + if (!context.containsKey(part)) { + context.put(part, new HashMap()); + } + context = (Map)context.get(part); + } + context.put("/", servletConfiguration); + } + } + + ServletConfiguration get(String url) { + if (exactMatches.containsKey(url)) { + return (ServletConfiguration)exactMatches.get(url); + } + ParsedPath path = new ParsedPath(url); + Map context = urlTree; + while (path.hasNext()) { + String part = path.next(); + if (!context.containsKey(part)) { + if (context.containsKey("*")) { + return (ServletConfiguration)context.get("*"); + } else { + int index = url.lastIndexOf('.'); + if (index == -1 || index == url.length()-1) { + return null; + } else { + return (ServletConfiguration)extensions.get(url.substring(index+1)); + } + } + } + context = (Map)context.get(part); + } + if (context.containsKey("*")) { + return (ServletConfiguration)context.get("*"); + } + return (ServletConfiguration)context.get("/"); + } + + } + +} + +/** + * A utility class for parsing URLs into paths + * + * @author <a href="ba...@we...">Donald Ball</a> + */ +class ParsedPath { + + private final String path; + private int position = 0; + static final char seperator_char = '/'; + + /** + * Creates a new parsed path for the given path value + * + * @param path the path + */ + ParsedPath(String path) { + if (path.charAt(0) != seperator_char) { + throw new IllegalArgumentException("Illegal path '"+path+"', does not begin with "+seperator_char); + } + this.path = path; + } + + /** + * Returns true if there are more parts left, otherwise false + */ + public final boolean hasNext() { + return (position < path.length()); + } + + /** + * Returns the next part in the path + */ + public final String next() { + int offset = position+1; + while (offset < path.length() && path.charAt(offset) != seperator_char) { + offset++; + } + String result = path.substring(position+1, offset); + position = offset; + return result; } } |
From: Russell G. <rus...@us...> - 2002-02-28 14:30:40
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv16505/test/com/meterware/httpunit Modified Files: HttpUnitSuite.java PseudoServerTest.java Added Files: WebClientTest.java Log Message: from Oliver Imbusch: added WebClientListener capability ***** Error reading new file[Errno 2] No such file or directory: 'WebClientTest.java' Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- HttpUnitSuite.java 14 Nov 2001 17:11:29 -0000 1.16 +++ HttpUnitSuite.java 28 Feb 2002 14:30:33 -0000 1.17 @@ -46,6 +46,7 @@ result.addTest( FormSubmitTest.suite() ); result.addTest( Base64Test.suite() ); result.addTest( PseudoServerTest.suite() ); + result.addTest( WebClientTest.suite() ); result.addTest( MessageBodyRequestTest.suite() ); result.addTest( JTidyPrintWriterTest.suite() ); addOptionalTestCase( result, "com.meterware.httpunit.XMLPageTest" ); Index: PseudoServerTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- PseudoServerTest.java 11 Feb 2002 14:33:53 -0000 1.21 +++ PseudoServerTest.java 28 Feb 2002 14:30:34 -0000 1.22 @@ -29,9 +29,6 @@ import com.meterware.httpunit.*; -/** - * Tests the basic authentication. - **/ public class PseudoServerTest extends HttpUnitTest { public static void main(String args[]) { @@ -344,5 +341,6 @@ ps.shutDown(); } } + } |
From: Russell G. <rus...@us...> - 2002-02-28 14:30:38
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory usw-pr-cvs1:/tmp/cvs-serv16505/doc/tutorial Added Files: .cvsignore Log Message: from Oliver Imbusch: added WebClientListener capability --- NEW FILE --- classes jars task1.zip |
From: Russell G. <rus...@us...> - 2002-02-28 14:30:38
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv16505/src/com/meterware/httpunit Modified Files: WebClient.java Added Files: WebClientListener.java Log Message: from Oliver Imbusch: added WebClientListener capability ***** Error reading new file[Errno 2] No such file or directory: 'WebClientListener.java' Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- WebClient.java 14 Feb 2002 14:33:49 -0000 1.20 +++ WebClient.java 28 Feb 2002 14:30:33 -0000 1.21 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2001, Russell Gold +* Copyright (c) 2000-2002, 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 @@ -29,6 +29,9 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; +import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; import org.xml.sax.SAXException; @@ -41,6 +44,7 @@ * @author Russell Gold * @author Jan Ohrstrom * @author Seth Ladd + * @author Oliver Imbusch **/ abstract public class WebClient implements FrameHolder { @@ -62,12 +66,51 @@ public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException { if (request.getURLString().startsWith( "about:" )) return WebResponse.BLANK_RESPONSE; + tellListeners( request ); WebResponse response = newResponse( request ); + tellListeners( response ); updateClient( response ); return getFrameContents( request.getTarget() ); } + private void tellListeners( WebRequest request ) { + List listeners; + + synchronized (_clientListeners) { + listeners = new ArrayList( _clientListeners ); + } + + for (Iterator i = listeners.iterator(); i.hasNext();) { + ((WebClientListener) i.next()).requestSent( this, request ); + } + } + + + private void tellListeners( WebResponse response ) { + List listeners; + + synchronized (_clientListeners) { + listeners = new ArrayList( _clientListeners ); + } + + for (Iterator i = listeners.iterator(); i.hasNext();) { + ((WebClientListener) i.next()).responseReceived( this, response ); + } + } + + + /** + * Resets the state of this client, removing all cookies, frames, and per-client headers. This does not affect + * any listeners or preferences which may have been set. + **/ + public void clearContents() { + _frameContents = new Hashtable(); + _cookies = new Hashtable(); + _headers = new HeaderDictionary(); + } + + /** * Returns the name of the currently active frames. **/ @@ -181,6 +224,26 @@ } + /** + * Adds a listener to watch for requests and responses. + */ + public void addClientListener( WebClientListener listener ) { + synchronized (_clientListeners) { + if (listener != null && !_clientListeners.contains( listener )) _clientListeners.add( listener ); + } + } + + + /** + * Removes a listener to watch for requests and responses. + */ + public void removeClientListener( WebClientListener listener ) { + synchronized (_clientListeners) { + _clientListeners.remove( listener ); + } + } + + //------------------------------------------ protected members ----------------------------------- @@ -272,6 +335,8 @@ private HeaderDictionary _headers = new HeaderDictionary(); private boolean _exceptionsThrownOnErrorStatus = HttpUnitOptions.getExceptionsThrownOnErrorStatus(); + + private List _clientListeners = new ArrayList(); /** |
From: Russell G. <rus...@us...> - 2002-02-28 14:30:38
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv16505/doc Modified Files: release_notes.txt Log Message: from Oliver Imbusch: added WebClientListener capability Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.91 retrieving revision 1.92 diff -u -r1.91 -r1.92 --- release_notes.txt 22 Feb 2002 15:49:04 -0000 1.91 +++ release_notes.txt 28 Feb 2002 14:30:33 -0000 1.92 @@ -12,12 +12,13 @@ Revision History: -22-Feb-2000 1.3.5 +28-Feb-2000 Acknowledgements: Thanks to Didier Besset for correcting the WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix Thanks to Stefan G. Renz for identifying the infinite loop bug in frame handling Thanks to Alex Chaffee for implementing context parameters for web.xml in ServletUnit Thanks to Jochen Hiller for supplying code to use jaxp to select a parser rather than being hardcoded to xerces + Thanks to Oliver Imbusch for adding the WebClientListener behavior Problems fixed: 1. hasParameterNamed and hasParameterStartingWithPrefix now check all types of parameters, not just <INPUT> fields @@ -58,6 +59,7 @@ 11. HttpUnit can now use any jaxp-compliant parser, rather than just xerces. 12. MessageBodyWebRequest's constructors and inner class are now public, allowing outside code to create new request classes. 13. WebClient now exposes the protected method writeMessageBody to ease implementation of new subclasses + 14. WebClient can now accept a listener of type WebClientListener to report on each request sent and response received. Notes: 1. Parameter validation is now handled by the form. Requests created from the form while parameter validation is |
From: Russell G. <rus...@us...> - 2002-02-28 14:30:37
|
Update of /cvsroot/httpunit/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv16505 Modified Files: .cvsignore Log Message: from Oliver Imbusch: added WebClientListener capability Index: .cvsignore =================================================================== RCS file: /cvsroot/httpunit/httpunit/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- .cvsignore 14 Jan 2002 18:13:45 -0000 1.2 +++ .cvsignore 28 Feb 2002 14:30:32 -0000 1.3 @@ -1,3 +1,5 @@ build *.ipr -savejars \ No newline at end of file +savejars +dist +lib \ No newline at end of file |
From: Russell G. <rus...@us...> - 2002-02-22 15:49:08
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory usw-pr-cvs1:/tmp/cvs-serv32197/doc/tutorial Modified Files: task1editor-validation.html Log Message: Clean up for 1.3.5 release Index: task1editor-validation.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/tutorial/task1editor-validation.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- task1editor-validation.html 27 Nov 2001 20:14:20 -0000 1.4 +++ task1editor-validation.html 22 Feb 2002 15:49:04 -0000 1.5 @@ -58,7 +58,15 @@ <li>We can now call a new method in the servlet which will return an array of error messages, which we can compare against our expected values for them.</li></ol></p> -<p>To make this test pass, we just have to create a single new method in the servlet:</p> +<p>This test won't even compile yet, so before proceeding, we should create the new method in the servlet without +any logic: +<pre class="servlet-code"> +String[] getValidationErrors() { + <b>return</b> new String[0]; +} +</pre> + +<p>Now it compiles and fails, as expected. To make this test pass, we need to implement the new method in the servlet:</p> <pre class="servlet-code"> String[] getValidationErrors() { ArrayList errorList = <b>new</b> ArrayList(); |
From: Russell G. <rus...@us...> - 2002-02-22 15:49:07
|
Update of /cvsroot/httpunit/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv32197 Modified Files: build.xml Log Message: Clean up for 1.3.5 release Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- build.xml 28 Jan 2002 21:10:57 -0000 1.39 +++ build.xml 22 Feb 2002 15:49:04 -0000 1.40 @@ -5,7 +5,7 @@ <project name="httpunit" default="jar" basedir="."> <property name="name" value="httpunit" /> <property name="Name" value="HttpUnit" /> - <property name="version" value="1.3" /> + <property name="version" value="1.3.5" /> <property name="debug" value="on" /> <property name="deprecation" value="off" /> |
From: Russell G. <rus...@us...> - 2002-02-22 15:49:07
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv32197/doc Modified Files: release_notes.txt Log Message: Clean up for 1.3.5 release Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.90 retrieving revision 1.91 diff -u -r1.90 -r1.91 --- release_notes.txt 14 Feb 2002 14:33:48 -0000 1.90 +++ release_notes.txt 22 Feb 2002 15:49:04 -0000 1.91 @@ -11,112 +11,63 @@ Revision History: -13-Feb-2002 -Additions: - 1. WebResponse now has a getSubframeContents method which returns the contents of a subframe of the frame represented - by the response. - -11-Feb-2002 -Problems corrected: - 1. Subframes with the same names as others in the same tree no longer cause an infinite loop / stack overflow -Additions: - 1. WebClient now has an exceptionsThrownOnErrorStatus property to control this behavior per client. -Notes: - 1. The decision as to whether a response will throw an exception if its status is 4xx or 5xx is now controlled by - the exceptionsThrownOnErrorStatus property of WebClient and its subclasses (WebConversation, ServletUnitClient). - This property is initialized from the HttpUnitOptions property of the same name when the WebClient object is - created. This allows finer control over this behavior. Tests which depend on this setting should no longer - interfere with one another. - - 5-Feb-2002 -Additions: - 1. Form parameters can be reset to their initial values using WebForm.reset(). - - 4-Feb-2002 -Problems corrected: - 1. Forms with query strings included in the action attribute now are submitted with that string intact. -Additions: - 1. Parameters defined in form query strings are now included in the known parameters of a form and requests - built from it. - - 1-Feb-2002 -Acknowledgements: - Thanks to Jochen Hiller for supplying code to use jaxp to select a parser rather than being hardcoded to xerces - -Additions: - 1. HttpUnit can now use any jaxp-compliant parser, rather than just xerces. - -30-Jan-2002 -Acknkowledgements: - Thanks to Alex Chaffee for implementing context parameters for web.xml in ServletUnit - -Additions: - 1. ServletUnit now supports the <context-param> tag. - -24-Jan-2002 -Additions: - 1. You can now call HttpUnitOptions.setAutoRedirect( false ) to enable explicit testing of redirect requests. - 2. WebClient now exposes the protected method writeMessageBody to ease implementation of new subclasses - -23-Jan-2002 -Problems fixed: - 1. Control characters and spaces created by breaking HTML in the middle are now trimmed from link parameters. - -21-Jan-2002 -Additions: - 1. MessageBodyWebRequest's constructors and inner class are now public, allowing outside code to create new request classes. - 2. ServletUnit now supports creating a RequestDispatcher from ServletContext to forward to other servlets. - Support for this is rudimentary at present: query parameters on the request dispatcher create are ignored. - -17-Jan-2002 -Problems fixed: - 1. Link parameters are now sent in the proper order, as long as parameter validation is not turned off. - 2. Parameter validation is now done for requests built from links -15-Jan-2002 +22-Feb-2000 1.3.5 Acknowledgements: + Thanks to Didier Besset for correcting the WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix Thanks to Stefan G. Renz for identifying the infinite loop bug in frame handling + Thanks to Alex Chaffee for implementing context parameters for web.xml in ServletUnit + Thanks to Jochen Hiller for supplying code to use jaxp to select a parser rather than being hardcoded to xerces Problems fixed: - 1. An infinite loop would result if a frame had the same name as one of its sub-frames - -14-Jan-2002 - -Problems fixed: - 1. Parameters are now submitted in the order specified in the form, as long as parameter validation is not turned off. - 2. It is no longer permitted to change hidden parameters with parameter validation enabled. - 3. An infinite loop would result if a frame had the same name as one of its sub-frames - -Additions: - 1. HttpUnit now handles multiple file form controls with the same name. - 2. It is now possible to set values for a form directly into the form. All such changes will be validated. - These will be used by any requests derived from the form. + 1. hasParameterNamed and hasParameterStartingWithPrefix now check all types of parameters, not just <INPUT> fields + 2. (bug #492003) JTidyPrintWriter fails to parse columns + 3. Empty cookies were not being recognized. + 4. Parameters are now submitted in the order specified in the form, as long as parameter validation is not turned off. + 5. It is no longer permitted to change hidden parameters with parameter validation enabled. + 6. Subframes with the same names as others in the same tree no longer cause an infinite loop / stack overflow + 7. Link parameters are now sent in the proper order, as long as parameter validation is not turned off. + 8. Parameter validation is now done for requests built from links + 9. Control characters and spaces created by breaking HTML in the middle are now trimmed from link parameters. + 10. Forms with query strings included in the action attribute now are submitted with that string intact. + +Additions: + Content and parsing enhancements: + 1. Disabled submit buttons are now detected, but requests cannot be made from them unless parameter validation is off. + 2. HttpUnit now handles multiple file form controls with the same name. + 3. WebResponse now has a getSubframeContents method which returns the contents of a subframe of the frame represented + by the response. + + ServletUnit enhancements + 4. ServletUnit now supports creating a RequestDispatcher from ServletContext to forward to other servlets. + Support for this is rudimentary at present: query parameters on the request dispatcher create are ignored. + 5. ServletUnit now supports the web.xml <context-param> tag. + + Form manipulation enhancements: + 6. It is now possible to set values for a form directly into the WebForm object. All such changes will be validated. + These will be used by any requests derived from the form. + 7. Parameters defined in form query strings are now included in the known parameters of a form and requests + built from it. + 8. Form parameters can be reset to their initial values using WebForm.reset(). + + Test properties enhancements: + 9. You can now call HttpUnitOptions.setAutoRedirect( false ) to enable explicit testing of redirect requests. + 10. WebClient now has an exceptionsThrownOnErrorStatus property to control this behavior per client. + + Extensibility enhancements: + 11. HttpUnit can now use any jaxp-compliant parser, rather than just xerces. + 12. MessageBodyWebRequest's constructors and inner class are now public, allowing outside code to create new request classes. + 13. WebClient now exposes the protected method writeMessageBody to ease implementation of new subclasses Notes: 1. Parameter validation is now handled by the form. Requests created from the form while parameter validation is enabled will share the variable space of the form and therefore be validated. Requests created while validation is disabled will have their own variable space, which is initialized to that of the form. - -10-Jan-2002 - -Problems fixed: - 1. Empty cookies were not being recognized. - -12-Dec-2001 - -Problems fixed: - 1. (bug #492003) JTidyPrintWriter fails to parse columns - - 3-Dec-2001 - -Acknowledgements: - Thanks to Didier Besset for correcting the WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix - -Problems fixed: - 1. hasParameterNamed and hasParameterStartingWithPrefix now check all types of parameters, not just <INPUT> fields - -Additions: - 1. Disabled submit buttons are now detected, but requests cannot be made from them unless parameter validation is off. + 2. The decision as to whether a response will throw an exception if its status is 4xx or 5xx is now controlled by + the exceptionsThrownOnErrorStatus property of WebClient and its subclasses (WebConversation, ServletUnitClient). + This property is initialized from the HttpUnitOptions property of the same name when the WebClient object is + created. This allows finer control over this behavior. Tests which depend on this setting should no longer + interfere with one another. 28-Nov-2001 1.3.0 |
From: Russell G. <rus...@us...> - 2002-02-21 21:13:35
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv26365a/src/com/meterware/httpunit Modified Files: WebForm.java Log Message: Correct accessibility of recordParameters method Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- WebForm.java 11 Feb 2002 13:54:28 -0000 1.46 +++ WebForm.java 21 Feb 2002 21:13:32 -0000 1.47 @@ -347,7 +347,7 @@ /** * Iterates through the parameters in this holder, recording them in the supplied parameter processor. **/ - public void recordParameters( ParameterProcessor processor ) throws IOException { + void recordParameters( ParameterProcessor processor ) throws IOException { FormControl[] controls = getFormControls(); for (int i = 0; i < controls.length; i++) { controls[i].addValues( processor, getCharacterSet() ); |
From: Russell G. <rus...@us...> - 2002-02-14 14:33:55
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv31413/test/com/meterware/httpunit Modified Files: WebFrameTest.java Log Message: Correct nested frame link bug, added getSubframeContent Index: WebFrameTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- WebFrameTest.java 11 Feb 2002 13:54:28 -0000 1.11 +++ WebFrameTest.java 14 Feb 2002 14:33:49 -0000 1.12 @@ -224,6 +224,25 @@ } + public void testGetSubframes() throws Exception { + WebResponse response = _wc.getResponse( getHostPath() + "/Frames.html" ); + assertEquals( "red subframe", _wc.getFrameContents( "red" ), response.getSubframeContents( "red" ) ); + } + + + public void testNestedSubFrames() throws Exception { + defineResource( "SuperFrames.html", + "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + + "<FRAMESET cols=\"50%,50%\">" + + " <FRAME src=\"Frames.html\" name=\"red\">" + + " <FRAME src=\"Frames.html\" name=\"blue\">" + + "</FRAMESET></HTML>" ); + WebResponse response = _wc.getResponse( getHostPath() + "/SuperFrames.html" ); + assertEquals( "red:red subframe", _wc.getFrameContents( "red:red" ), + response.getSubframeContents( "red" ).getSubframeContents( "red" ) ); + } + + public void testNestedCrossFrameLinks() throws Exception { defineResource( "SuperFrames.html", "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + @@ -240,6 +259,26 @@ WebResponse frameContent = _wc.getResponse( _wc.getFrameContents( frameNames[1] ).getLinks()[0].getRequest() ); assertTrue( "Second response not the same as source frame contents", frameContent == _wc.getFrameContents( frameNames[0] ) ); assertEquals( "URL for second request", getHostPath() + "/Linker.html", frameContent.getURL().toExternalForm() ); + } + + + public void testCrossLevelLinks() throws Exception { + defineResource( "SuperFrames.html", + "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + + "<FRAMESET cols=\"50%,50%\">" + + " <FRAME src=\"Frames.html\" name=\"red\">" + + " <FRAME src=\"Frames.html\" name=\"blue\">" + + "</FRAMESET></HTML>" ); + WebResponse response = _wc.getResponse( getHostPath() + "/SuperFrames.html" ); + String topFrameNames[] = response.getFrameNames(); + WebResponse topRedFrame = _wc.getFrameContents( topFrameNames[0] ); + String frameNames[] = topRedFrame.getFrameNames(); + + _wc.getResponse( _wc.getFrameContents( frameNames[0] ).getLinks()[0].getRequest() ); + WebResponse frameContent = _wc.getResponse( _wc.getFrameContents( frameNames[0] ).getLinks()[0].getRequest() ); + assertTrue( "Second response not the same as source frame contents", frameContent == _wc.getFrameContents( "_top" ) ); + assertEquals( "URL for second request", getHostPath() + "/Form.html", frameContent.getURL().toExternalForm() ); + assertEquals( "Number of active frames", 1, _wc.getFrameNames().length ); } |
From: Russell G. <rus...@us...> - 2002-02-14 14:33:54
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv31413/src/com/meterware/httpunit Modified Files: HttpWebResponse.java WebClient.java WebFrame.java WebRequestSource.java WebResponse.java Added Files: FrameHolder.java NoSuchFrameException.java Log Message: Correct nested frame link bug, added getSubframeContent ***** Error reading new file[Errno 2] No such file or directory: 'FrameHolder.java' ***** Error reading new file[Errno 2] No such file or directory: 'NoSuchFrameException.java' Index: HttpWebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- HttpWebResponse.java 11 Feb 2002 14:33:53 -0000 1.18 +++ HttpWebResponse.java 14 Feb 2002 14:33:49 -0000 1.19 @@ -95,7 +95,7 @@ public String toString() { - return "[headers=" + _headers + "]"; + return "HttpWebResponse [url=" + getURL() + "; headers=" + _headers + "]"; } Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- WebClient.java 11 Feb 2002 14:33:53 -0000 1.19 +++ WebClient.java 14 Feb 2002 14:33:49 -0000 1.20 @@ -43,7 +43,7 @@ * @author Seth Ladd **/ abstract -public class WebClient { +public class WebClient implements FrameHolder { /** * Submits a GET method request and returns a response. @@ -85,6 +85,7 @@ /** * Returns the response associated with the specified frame name. + * Throws a runtime exception if no matching frame is defined. **/ public WebResponse getFrameContents( String frameName ) { WebResponse response = (WebResponse) _frameContents.get( frameName ); @@ -316,6 +317,7 @@ private void updateFrames( WebResponse response ) throws MalformedURLException, IOException, SAXException { removeSubFrames( response.getTarget() ); + response.setFrameHolder( this ); _frameContents.put( response.getTarget(), response ); if (response.isHTML()) { @@ -411,21 +413,3 @@ } - -//================================================================================================== - - -class NoSuchFrameException extends RuntimeException { - - NoSuchFrameException( String frameName ) { - _frameName = frameName; - } - - - public String getMessage() { - return "No frame named " + _frameName + " is currently active"; - } - - - private String _frameName; -} Index: WebFrame.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- WebFrame.java 11 Feb 2002 13:54:28 -0000 1.5 +++ WebFrame.java 14 Feb 2002 14:33:49 -0000 1.6 @@ -51,7 +51,7 @@ } - private static String getNestedFrameName( String parentFrameName, final String relativeName ) { + static String getNestedFrameName( String parentFrameName, final String relativeName ) { if (parentFrameName.equalsIgnoreCase( WebRequest.TOP_FRAME )) return relativeName; return parentFrameName + ':' + relativeName; } Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebRequestSource.java 11 Feb 2002 13:54:28 -0000 1.7 +++ WebRequestSource.java 14 Feb 2002 14:33:49 -0000 1.8 @@ -53,6 +53,8 @@ return _pageFrame; } else if (getSpecifiedTarget().equalsIgnoreCase( "_self" )) { return _pageFrame; + } else if (getSpecifiedTarget().equalsIgnoreCase( "_top" )) { + return "_top"; } else { return WebFrame.getTargetFrameName( _pageFrame, getSpecifiedTarget() ); } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- WebResponse.java 11 Feb 2002 14:33:53 -0000 1.61 +++ WebResponse.java 14 Feb 2002 14:33:49 -0000 1.62 @@ -262,6 +262,17 @@ } + /** + * Returns the contents of the specified subframe of this frameset response. + * + * @param subFrameName the name of the desired frame as defined in the frameset. + **/ + public WebResponse getSubframeContents( String subFrameName ) { + if (_frameHolder == null) throw new NoSuchFrameException( subFrameName ); + return _frameHolder.getFrameContents( WebFrame.getNestedFrameName( _frameName, subFrameName ) ); + } + + //---------------------- HTMLSegment methods ----------------------------- /** @@ -497,6 +508,14 @@ } + /** + * Provides a FrameHolder to help with computation of subframes. + **/ + void setFrameHolder( FrameHolder holder ) { + _frameHolder = holder; + } + + //--------------------------------- private members -------------------------------------- @@ -536,6 +555,8 @@ private WebRequest _refreshRequest; + private FrameHolder _frameHolder; + private int _refreshDelay; private String _responseText; @@ -1012,3 +1033,4 @@ private String _contentType; } + |
From: Russell G. <rus...@us...> - 2002-02-14 14:33:53
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv31413/doc Modified Files: release_notes.txt Log Message: Correct nested frame link bug, added getSubframeContent Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- release_notes.txt 11 Feb 2002 14:33:52 -0000 1.89 +++ release_notes.txt 14 Feb 2002 14:33:48 -0000 1.90 @@ -11,6 +11,11 @@ Revision History: +13-Feb-2002 +Additions: + 1. WebResponse now has a getSubframeContents method which returns the contents of a subframe of the frame represented + by the response. + 11-Feb-2002 Problems corrected: 1. Subframes with the same names as others in the same tree no longer cause an infinite loop / stack overflow |
From: Russell G. <rus...@us...> - 2002-02-11 14:33:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv330/src/com/meterware/httpunit Modified Files: HttpWebResponse.java WebClient.java WebConversation.java WebResponse.java Log Message: Moved control of exceptionsThrownOnErrorStatus into WebClient Index: HttpWebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpWebResponse.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- HttpWebResponse.java 28 Jan 2002 18:43:25 -0000 1.17 +++ HttpWebResponse.java 11 Feb 2002 14:33:53 -0000 1.18 @@ -47,12 +47,12 @@ * @param url the url from which the response was received * @param connection the URL connection from which the response can be read **/ - HttpWebResponse( String target, URL url, URLConnection connection ) throws IOException { + HttpWebResponse( String target, URL url, URLConnection connection, boolean throwExceptionOnError ) throws IOException { super( target, url ); readHeaders( connection ); /** make sure that any IO exception for HTML received page happens here, not later. **/ - if (_responseCode < HttpURLConnection.HTTP_BAD_REQUEST || !HttpUnitOptions.getExceptionsThrownOnErrorStatus()) { + if (_responseCode < HttpURLConnection.HTTP_BAD_REQUEST || !throwExceptionOnError) { defineRawInputStream( new BufferedInputStream( connection.getInputStream() ) ); if (getContentType().startsWith( "text" )) loadResponseText(); } Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- WebClient.java 11 Feb 2002 13:54:28 -0000 1.18 +++ WebClient.java 11 Feb 2002 14:33:53 -0000 1.19 @@ -45,7 +45,6 @@ abstract public class WebClient { - /** * Submits a GET method request and returns a response. * @exception SAXException thrown if there is an error parsing the retrieved page @@ -164,6 +163,23 @@ } + /** + * Specifies whether an exception will be thrown when an error status (4xx or 5xx) is detected on a response. + * Defaults to the value returned by HttpUnitOptions.getExceptionsThrownOnErrorStatus. + **/ + public void setExceptionsThrownOnErrorStatus( boolean throwExceptions ) { + _exceptionsThrownOnErrorStatus = throwExceptions; + } + + + /** + * Returns true if an exception will be thrown when an error status (4xx or 5xx) is detected on a response. + **/ + public boolean getExceptionsThrownOnErrorStatus() { + return _exceptionsThrownOnErrorStatus; + } + + //------------------------------------------ protected members ----------------------------------- @@ -254,6 +270,8 @@ /** A map of header names to values. **/ private HeaderDictionary _headers = new HeaderDictionary(); + private boolean _exceptionsThrownOnErrorStatus = HttpUnitOptions.getExceptionsThrownOnErrorStatus(); + /** * Examines the headers in the response and throws an exception if appropriate. @@ -261,7 +279,7 @@ private void validateHeaders( WebResponse response ) throws HttpException, IOException { if (response.getHeaderField( "WWW-Authenticate" ) != null) { throw new AuthorizationRequiredException( response.getHeaderField( "WWW-Authenticate" ) ); - } else if (HttpUnitOptions.getExceptionsThrownOnErrorStatus()) { + } else if (getExceptionsThrownOnErrorStatus()) { if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { throw new HttpInternalErrorException( response.getURL() ); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { Index: WebConversation.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- WebConversation.java 26 Nov 2001 14:20:12 -0000 1.23 +++ WebConversation.java 11 Feb 2002 14:33:53 -0000 1.24 @@ -63,7 +63,7 @@ } } request.completeRequest( connection ); - return new HttpWebResponse( request.getTarget(), request.getURL(), connection ); + return new HttpWebResponse( request.getTarget(), request.getURL(), connection, getExceptionsThrownOnErrorStatus() ); } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- WebResponse.java 11 Feb 2002 13:54:28 -0000 1.60 +++ WebResponse.java 11 Feb 2002 14:33:53 -0000 1.61 @@ -64,7 +64,7 @@ * access to WebResponse parsing without using a WebClient. **/ public static WebResponse newResponse( URLConnection connection ) throws IOException { - return new HttpWebResponse( "_top", connection.getURL(), connection ); + return new HttpWebResponse( "_top", connection.getURL(), connection, HttpUnitOptions.getExceptionsThrownOnErrorStatus() ); } |
From: Russell G. <rus...@us...> - 2002-02-11 14:33:57
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv330/test/com/meterware/httpunit Modified Files: PseudoServerTest.java Log Message: Moved control of exceptionsThrownOnErrorStatus into WebClient Index: PseudoServerTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- PseudoServerTest.java 28 Jan 2002 18:43:25 -0000 1.20 +++ PseudoServerTest.java 11 Feb 2002 14:33:53 -0000 1.21 @@ -117,12 +117,16 @@ ps.setErrorResource( "error.htm", 501, "Internal error" ); int port = ps.getConnectedPort(); - HttpUnitOptions.setExceptionsThrownOnErrorStatus( false ); - WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + "/error.htm" ); - WebResponse response = wc.getResponse( request ); - assertEquals( "Response code", 501, response.getResponseCode() ); - assertEquals( "Message contents", "Internal error", response.getText().trim() ); + try { + WebConversation wc = new WebConversation(); + wc.setExceptionsThrownOnErrorStatus( false ); + WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + "/error.htm" ); + WebResponse response = wc.getResponse( request ); + assertEquals( "Response code", 501, response.getResponseCode() ); + assertEquals( "Message contents", "Internal error", response.getText().trim() ); + } finally { + ps.shutDown(); + } } |
From: Russell G. <rus...@us...> - 2002-02-11 14:33:56
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv330/doc Modified Files: release_notes.txt Log Message: Moved control of exceptionsThrownOnErrorStatus into WebClient Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- release_notes.txt 11 Feb 2002 13:54:28 -0000 1.88 +++ release_notes.txt 11 Feb 2002 14:33:52 -0000 1.89 @@ -14,6 +14,14 @@ 11-Feb-2002 Problems corrected: 1. Subframes with the same names as others in the same tree no longer cause an infinite loop / stack overflow +Additions: + 1. WebClient now has an exceptionsThrownOnErrorStatus property to control this behavior per client. +Notes: + 1. The decision as to whether a response will throw an exception if its status is 4xx or 5xx is now controlled by + the exceptionsThrownOnErrorStatus property of WebClient and its subclasses (WebConversation, ServletUnitClient). + This property is initialized from the HttpUnitOptions property of the same name when the WebClient object is + created. This allows finer control over this behavior. Tests which depend on this setting should no longer + interfere with one another. 5-Feb-2002 Additions: |
From: Russell G. <rus...@us...> - 2002-02-11 13:54:31
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17962/test/com/meterware/httpunit Modified Files: WebFrameTest.java Log Message: Use separate namespace for each frame set Index: WebFrameTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WebFrameTest.java 28 Jan 2002 18:43:25 -0000 1.10 +++ WebFrameTest.java 11 Feb 2002 13:54:28 -0000 1.11 @@ -55,7 +55,7 @@ defineWebPage( "Linker", "This is a trivial page with <a href=Target.html>one link</a>" ); defineWebPage( "Target", "This is another page with <a href=Form.html target=\"_top\">one link</a>" ); - defineWebPage( "Form", "This is a page with a simple form: " + + defineWebPage( "Form", "This is a page with a simple form: " + "<form action=submit><input name=name><input type=submit></form>" + "<a href=Linker.html target=red>a link</a>"); defineResource( "Frames.html", @@ -221,6 +221,25 @@ assertTrue( "Second response not the same as source frame contents", response == _wc.getFrameContents( "red" ) ); assertMatchingSet( "Frames defined for the conversation", new String[] { "_top", "red", "blue" }, _wc.getFrameNames() ); assertEquals( "URL for second request", getHostPath() + "/Linker.html", response.getURL().toExternalForm() ); + } + + + public void testNestedCrossFrameLinks() throws Exception { + defineResource( "SuperFrames.html", + "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" + + "<FRAMESET cols=\"50%,50%\">" + + " <FRAME src=\"Frames.html\" name=\"red\">" + + " <FRAME src=\"Frames.html\" name=\"blue\">" + + "</FRAMESET></HTML>" ); + WebResponse response = _wc.getResponse( getHostPath() + "/SuperFrames.html" ); + String topFrameNames[] = response.getFrameNames(); + WebResponse topRedFrame = _wc.getFrameContents( topFrameNames[0] ); + String frameNames[] = topRedFrame.getFrameNames(); + + _wc.getResponse( _wc.getFrameContents( frameNames[0] ).getLinks()[0].getRequest() ); + WebResponse frameContent = _wc.getResponse( _wc.getFrameContents( frameNames[1] ).getLinks()[0].getRequest() ); + assertTrue( "Second response not the same as source frame contents", frameContent == _wc.getFrameContents( frameNames[0] ) ); + assertEquals( "URL for second request", getHostPath() + "/Linker.html", frameContent.getURL().toExternalForm() ); } |
From: Russell G. <rus...@us...> - 2002-02-11 13:54:31
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17962/src/com/meterware/httpunit Modified Files: WebClient.java WebForm.java WebFrame.java WebRequestSource.java WebResponse.java Log Message: Use separate namespace for each frame set Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- WebClient.java 28 Jan 2002 18:43:25 -0000 1.17 +++ WebClient.java 11 Feb 2002 13:54:28 -0000 1.18 @@ -320,7 +320,7 @@ String[] names = (String[]) _subFrames.get( targetName ); if (names == null) return; for (int i = 0; i < names.length; i++) { - if (!targetName.equals( names[i] )) removeSubFrames( names[i] ); + removeSubFrames( names[i] ); _frameContents.remove( names[i] ); _subFrames.remove( names[i] ); } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- WebForm.java 6 Feb 2002 18:38:13 -0000 1.45 +++ WebForm.java 11 Feb 2002 13:54:28 -0000 1.46 @@ -394,8 +394,8 @@ * Contructs a web form given the URL of its source page and the DOM extracted * from that page. **/ - WebForm( URL baseURL, String parentTarget, Node node, String characterSet ) { - super( node, baseURL, NodeUtils.getNodeAttribute( node, "action" ), parentTarget ); + WebForm( URL baseURL, String frameName, Node node, String characterSet ) { + super( node, baseURL, NodeUtils.getNodeAttribute( node, "action" ), frameName ); _characterSet = characterSet; } Index: WebFrame.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WebFrame.java 9 Nov 2001 18:35:14 -0000 1.4 +++ WebFrame.java 11 Feb 2002 13:54:28 -0000 1.5 @@ -32,18 +32,34 @@ //---------------------------------------- package methods ----------------------------------------- - WebFrame( URL baseURL, Node frameNode ) { + WebFrame( URL baseURL, Node frameNode, String parentFrameName ) { _element = frameNode; _baseURL = baseURL; + _name = getFrameName( parentFrameName ); } String getName() { - if (_name == null) { - _name = NodeUtils.getNodeAttribute( _element, "name" ); - if (_name.length() == 0) _name = toString(); - } return _name; + } + + + private String getFrameName( String parentFrameName ) { + final String relativeName = NodeUtils.getNodeAttribute( _element, "name" ); + if (relativeName.length() == 0) return toString(); + else return getNestedFrameName( parentFrameName, relativeName ); + } + + + private static String getNestedFrameName( String parentFrameName, final String relativeName ) { + if (parentFrameName.equalsIgnoreCase( WebRequest.TOP_FRAME )) return relativeName; + return parentFrameName + ':' + relativeName; + } + + + static String getTargetFrameName( String sourceFrameName, final String relativeName ) { + if (sourceFrameName.indexOf( ':' ) < 0) return relativeName; + return sourceFrameName.substring( 0, sourceFrameName.lastIndexOf( ':' ) ) + ':' + relativeName; } Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WebRequestSource.java 4 Feb 2002 22:33:55 -0000 1.6 +++ WebRequestSource.java 11 Feb 2002 13:54:28 -0000 1.7 @@ -50,11 +50,11 @@ **/ public String getTarget() { if (getSpecifiedTarget().length() == 0) { - return _parentTarget; + return _pageFrame; } else if (getSpecifiedTarget().equalsIgnoreCase( "_self" )) { - return _parentTarget; + return _pageFrame; } else { - return getSpecifiedTarget(); + return WebFrame.getTargetFrameName( _pageFrame, getSpecifiedTarget() ); } } @@ -123,12 +123,12 @@ * Contructs a web form given the URL of its source page and the DOM extracted * from that page. **/ - WebRequestSource( Node node, URL baseURL, String destination, String parentTarget ) { + WebRequestSource( Node node, URL baseURL, String destination, String pageFrame ) { if (node == null) throw new IllegalArgumentException( "node must not be null" ); _node = node; _baseURL = baseURL; _destination = destination; - _parentTarget = parentTarget; + _pageFrame = pageFrame; } @@ -174,8 +174,8 @@ private static final String PARAM_DELIM = "&"; - /** The target in which the parent response is to be rendered. **/ - private String _parentTarget; + /** The name of the frame in which the response containing this request source is rendered. **/ + private String _pageFrame; /** The URL of the page containing this entity. **/ private URL _baseURL; Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- WebResponse.java 1 Feb 2002 14:31:43 -0000 1.59 +++ WebResponse.java 11 Feb 2002 13:54:28 -0000 1.60 @@ -128,7 +128,7 @@ * Returns the target of the page. **/ public String getTarget() { - return _target; + return _frameName; } @@ -423,12 +423,12 @@ /** * Constructs a response object. - * @param target the name of the frame to hold the response + * @param frameName the name of the frame to hold the response * @param url the url from which the response was received **/ - protected WebResponse( String target, URL url ) { + protected WebResponse( String frameName, URL url ) { _url = url; - _target = target; + _frameName = frameName; } @@ -447,7 +447,7 @@ if (splitIndex < 0) splitIndex = 0; try { _refreshDelay = Integer.parseInt( contentTypeHeader.substring( 0, splitIndex ) ); - _refreshRequest = new GetMethodWebRequest( _url, getRefreshURL( contentTypeHeader.substring( splitIndex+1 ) ), _target ); + _refreshRequest = new GetMethodWebRequest( _url, getRefreshURL( contentTypeHeader.substring( splitIndex+1 ) ), _frameName ); } catch (NumberFormatException e) { System.out.println( "Unable to interpret refresh tag: \"" + contentTypeHeader + '"' ); } @@ -548,7 +548,7 @@ private URL _url; - private String _target; + private String _frameName; protected void loadResponseText() throws IOException { @@ -784,7 +784,7 @@ NodeList nl = NodeUtils.getElementsByTagName( getReceivedPage().getOriginalDOM(), frameTagName ); for (int i = 0; i < nl.getLength(); i++) { Node child = nl.item(i); - list.addElement( new WebFrame( getReceivedPage().getBaseURL(), child ) ); + list.addElement( new WebFrame( getReceivedPage().getBaseURL(), child, _frameName ) ); } } @@ -793,7 +793,7 @@ if (_page == null) { try { if (!isHTML()) throw new NotHTMLException( getContentType() ); - _page = new ReceivedPage( _url, _target, getText(), getCharacterSet() ); + _page = new ReceivedPage( _url, _frameName, getText(), getCharacterSet() ); } catch (IOException e) { throw new SAXException( e ); } |
From: Russell G. <rus...@us...> - 2002-02-11 13:54:31
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv17962/doc Modified Files: release_notes.txt Log Message: Use separate namespace for each frame set Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- release_notes.txt 6 Feb 2002 18:38:13 -0000 1.87 +++ release_notes.txt 11 Feb 2002 13:54:28 -0000 1.88 @@ -11,6 +11,10 @@ Revision History: +11-Feb-2002 +Problems corrected: + 1. Subframes with the same names as others in the same tree no longer cause an infinite loop / stack overflow + 5-Feb-2002 Additions: 1. Form parameters can be reset to their initial values using WebForm.reset(). |