httpunit-commit Mailing List for httpunit (Page 78)
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...> - 2000-11-21 20:45:01
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv6274/doc Modified Files: release_notes.txt Log Message: Initial servletunit release Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- release_notes.txt 2000/11/16 21:42:18 1.10 +++ release_notes.txt 2000/11/21 20:44:57 1.11 @@ -8,11 +8,18 @@ Revision History: +21-Nov-00 +Additions: + 1. Introductory ServletUnit functionality (parameters and sessions, but no JSP, no redirect, no forwarding) + 2. WebConversation now has a new public base class: WebClient + 3. Any message header may now be defined, using: WebClient.setHeaderField and will be sent on all subsequent requests + 4. Forms may now be retrieved by their name attributes, using WebResponse.getFormWithName() + +16-Nov-00 1.2 Acknowledgements: Thanks to Robert Krueger for providing an interface to the xerces parser for XML web responses. Thanks to Marco Tamanti and Gabriele Antonelli for suggesting ways to support file URLs -16-Nov-00 1.2 Problems corrected: 1. Unnamed parameters are no longer submitted as part of a form request 2. Searching for tables beginning with a string no longer aborts with NullPointerException if the table is missing cells |
From: Russell G. <rus...@us...> - 2000-11-21 20:40:06
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv5258/servletunit Log Message: Directory /cvsroot/httpunit/httpunit/src/com/meterware/servletunit added to the repository |
From: Russell G. <rus...@us...> - 2000-11-21 20:38:06
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv4954/servletunit Log Message: Directory /cvsroot/httpunit/httpunit/test/com/meterware/servletunit added to the repository |
From: Russell G. <rus...@us...> - 2000-11-16 21:42:28
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv21159/doc Modified Files: release_notes.txt Log Message: Prepare for 1.2 release Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- release_notes.txt 2000/11/10 18:48:37 1.9 +++ release_notes.txt 2000/11/16 21:42:18 1.10 @@ -12,22 +12,19 @@ Thanks to Robert Krueger for providing an interface to the xerces parser for XML web responses. Thanks to Marco Tamanti and Gabriele Antonelli for suggesting ways to support file URLs -10-Nov-00 -Additions: - 1. XML parsing is now supported. If WebResponse.getDOM is called for a non-HTML response, the xerces parser - will be invoked to treat the response as XML. - 2. File URLs (file:xxx) are now supported - -02-Nov-00 -Additions: - 1. Forms with multiple buttons are now supported, using the SubmitButton class. - 2. WebResponse now supports finding a table via its summary text, using getTableWithSummary(). - +16-Nov-00 1.2 Problems corrected: 1. Unnamed parameters are no longer submitted as part of a form request 2. Searching for tables beginning with a string no longer aborts with NullPointerException if the table is missing cells 3. A problem which caused WebResponse.java to fail compilation under JDK 1.1 has been corrected +Additions: + 1. Forms with multiple buttons are now supported, using the SubmitButton class. + 2. WebResponse now supports finding a table via its summary text, using getTableWithSummary(). + 3. XML parsing is now supported. If WebResponse.getDOM is called for a non-HTML response (content type is not "text/html"), + the xerces parser will be invoked to treat the response as XML. + 4. File URLs (file:xxx) are now supported + 17-Oct-00 1.1 Acknowledgements: Thanks to Seth Ladd for specific exceptions from WebConversation.getResponse |
From: Russell G. <rus...@us...> - 2000-11-16 21:42:28
|
Update of /cvsroot/httpunit/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv21159 Modified Files: build.xml Log Message: Prepare for 1.2 release Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- build.xml 2000/11/10 18:48:36 1.14 +++ build.xml 2000/11/16 21:42:17 1.15 @@ -5,8 +5,8 @@ <project name="httpunit" default="jar" basedir="."> <property name="name" value="httpunit" /> <property name="Name" value="HttpUnit" /> - <property name="version" value="1.1" /> - <property name="zip_version" value="1_1" /> + <property name="version" value="1.2" /> + <property name="zip_version" value="1_2" /> <property name="src.dir" value="src" /> <property name="tstsrc.dir" value="test" /> <property name="examples.dir" value="examples" /> |
From: Russell G. <rus...@us...> - 2000-11-10 18:48:40
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv20483/test/com/meterware/httpunit Modified Files: FormSubmitTest.java HttpUnitTest.java PseudoServer.java PseudoServerTest.java WebPageTest.java Log Message: Added support for XML and local files Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FormSubmitTest.java 2000/11/02 18:37:37 1.3 +++ FormSubmitTest.java 2000/11/10 18:48:37 1.4 @@ -116,6 +116,18 @@ } + public void testUnnamedImageButtonDefaultSubmit() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=image value=name src=\"\">" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + WebRequest request = form.getRequest(); + assertEquals( getHostPath() + "/ask?age=12", request.getURL().toExternalForm() ); + } + + public void testImageButtonPositionalSubmit() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + @@ -188,6 +200,12 @@ WebForm form = page.getForms()[0]; WebRequest request = form.getRequest( form.getSubmitButton( "update", "name" ) ); assertEquals( getHostPath() + "/ask?update=name&age=12", request.getURL().toExternalForm() ); + + request = form.getRequest( "update", "name" ); + assertEquals( getHostPath() + "/ask?update=name&age=12", request.getURL().toExternalForm() ); + + request = form.getRequest( "update" ); + assertEquals( getHostPath() + "/ask?update=age&age=12", request.getURL().toExternalForm() ); } Index: HttpUnitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- HttpUnitTest.java 2000/09/27 18:04:04 1.6 +++ HttpUnitTest.java 2000/11/10 18:48:37 1.7 @@ -39,6 +39,11 @@ } + protected void defineResource( String resourceName, String value, String contentType ) { + _server.setResource( resourceName, value, contentType ); + } + + protected void defineWebPage( String pageName, String body ) { defineResource( pageName + ".html", "<html><head><title>" + pageName + "</title></head>\n" + "<body>" + body + "</body></html>" ); Index: PseudoServer.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PseudoServer.java 2000/09/27 18:04:04 1.1 +++ PseudoServer.java 2000/11/10 18:48:37 1.2 @@ -68,10 +68,31 @@ * Defines the contents of an expected resource. **/ public void setResource( String name, String value ) { - _resources.put( asResourceName( name ), value ); + setResource( name, value, "text/html" ); } + /** + * Defines the contents of an expected resource. + **/ + public void setResource( String name, String value, String contentType ) { + _resources.put( asResourceName( name ), new WebResource( value, contentType ) ); + } + + + /** + * Adds a header to a defined resource. + **/ + public void addResourceHeader( String name, String header ) { + WebResource resource = (WebResource) _resources.get( asResourceName( name ) ); + if (resource == null) { + resource = new WebResource( "" ); + _resources.put( asResourceName( name ), resource ); + } + resource.addHeader( header ); + } + + //------------------------------------- private members --------------------------------------- @@ -109,14 +130,18 @@ if (!command.equals( "GET" )) { sendResponse( ps, HttpURLConnection.HTTP_BAD_METHOD, "unsupported method: " + command ); } else { - String resource = (String) _resources.get( uri ); + WebResource resource = (WebResource) _resources.get( uri ); if (resource == null) { sendResponse( ps, HttpURLConnection.HTTP_NOT_FOUND, "unable to find " + uri ); } else { sendResponse( ps, HttpURLConnection.HTTP_OK, "OK" ); - sendLine( ps, "Content-type: text/html" ); + sendLine( ps, "Content-type: " + resource.getContentType() ); + String[] headers = resource.getHeaders(); + for (int i = 0; i < headers.length; i++) { + sendLine( ps, headers[i] ); + } sendLine( ps, "" ); - sendText( ps, resource ); + sendText( ps, resource.getContents() ); ps.close(); } } @@ -152,6 +177,49 @@ private ServerSocket _serverSocket; +} + + +class WebResource { + + + final static String DEFAULT_CONTENT_TYPE = "text/html"; + + WebResource( String contents ) { + this( contents, DEFAULT_CONTENT_TYPE ); + } + + + WebResource( String contents, String contentType ) { + _contents = contents; + _contentType = contentType; + } + + + void addHeader( String header ) { + _headers.addElement( header ); + } + + + String[] getHeaders() { + String[] headers = new String[ _headers.size() ]; + _headers.copyInto( headers ); + return headers; + } + + + String getContents() { + return _contents; + } + + + String getContentType() { + return _contentType; + } + + private String _contents; + private String _contentType; + private Vector _headers = new Vector(); } Index: PseudoServerTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PseudoServerTest.java 2000/10/12 16:16:36 1.2 +++ PseudoServerTest.java 2000/11/10 18:48:37 1.3 @@ -76,5 +76,25 @@ assertEquals( "content type", "text/html", response.getContentType() ); } + + + public void testRedirect() throws Exception { + String resourceName = "something/interesting"; + String resourceValue = "the desired content\r\n"; + + String redirectName = "anOldOne"; + + PseudoServer ps = new PseudoServer(); + int port = ps.getConnectedPort(); + ps.setResource( resourceName, resourceValue ); + ps.setResource( redirectName, "" ); + ps.addResourceHeader( redirectName, "Location: http://localhost:" + port + '/' + resourceName ); + + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + '/' + redirectName ); + WebResponse response = wc.getResponse( request ); + assertEquals( "requested resource", resourceValue, response.toString() ); + assertEquals( "content type", "text/html", response.getContentType() ); + } } Index: WebPageTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebPageTest.java 2000/09/27 18:04:04 1.2 +++ WebPageTest.java 2000/11/10 18:48:37 1.3 @@ -28,7 +28,11 @@ import java.util.Vector; +import java.io.*; +import org.w3c.dom.Document; + + /** * A unit test of the httpunit parsing classes. **/ @@ -51,6 +55,21 @@ public void setUp() throws Exception { super.setUp(); + } + + + public void testNoResponse() throws Exception { + WebConversation wc = new WebConversation(); + try { + WebRequest request = new GetMethodWebRequest( getHostPath() + "/SimplePage.html" ); + WebResponse simplePage = wc.getResponse( request ); + fail( "Did not complain about missing page" ); + } catch (HttpNotFoundException e) { + } + } + + + public void testTitle() throws Exception { defineResource( "SimplePage.html", "<html><head><title>A Sample Page</title></head>\n" + "<body>This has no forms but it does\n" + @@ -61,17 +80,39 @@ WebConversation wc = new WebConversation(); WebRequest request = new GetMethodWebRequest( getHostPath() + "/SimplePage.html" ); - _simplePage = wc.getResponse( request ); + WebResponse simplePage = wc.getResponse( request ); + assertEquals( "Title", "A Sample Page", simplePage.getTitle() ); } - - - public void testTitle() throws Exception { - assertEquals( "Title", "A Sample Page", _simplePage.getTitle() ); + + + public void testXML() throws Exception { + defineResource( "SimplePage.xml", + "<?xml version=\"1.0\" ?><main><title>See me now</title></main>", + "text/xml" ); + + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( getHostPath() + "/SimplePage.xml" ); + WebResponse simplePage = wc.getResponse( request ); + Document doc = simplePage.getDOM(); } - - private WebResponse _simplePage; + public void testLocalFile() throws Exception { + File file = new File( "temp.html" ); + FileWriter fw = new FileWriter( file ); + PrintWriter pw = new PrintWriter( fw ); + pw.println( "<html><head><title>A Sample Page</title></head>" ); + pw.println( "<body>This is a very simple page<p>With not much text</body></html>" ); + pw.close(); + WebConversation wc = new WebConversation(); + WebRequest request = new GetMethodWebRequest( "file:" + file.getAbsolutePath() ); + WebResponse simplePage = wc.getResponse( request ); + assertEquals( "Title", "A Sample Page", simplePage.getTitle() ); + + file.delete(); + } + + } |
From: Russell G. <rus...@us...> - 2000-11-10 18:48:40
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv20483/src/com/meterware/httpunit Modified Files: WebConversation.java WebForm.java WebResponse.java Log Message: Added support for XML and local files Index: WebConversation.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- WebConversation.java 2000/10/12 16:16:35 1.16 +++ WebConversation.java 2000/11/10 18:48:37 1.17 @@ -82,22 +82,15 @@ * cookies as requested by the server. **/ public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException { - HttpURLConnection connection = (HttpURLConnection) openConnection( request.getURL() ); + URLConnection connection = openConnection( request.getURL() ); request.completeRequest( connection ); updateCookies( connection ); if (connection.getHeaderField( "Location" ) != null) { delay( HttpUnitOptions.getRedirectDelay() ); return getResponse( new RedirectWebRequest( request, connection.getHeaderField( "Location" ) ) ); - } else if (connection.getHeaderField( "WWW-Authenticate" ) != null) { - throw new AuthorizationRequiredException( connection.getHeaderField( "WWW-Authenticate" ) ); - } else if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { - throw new HttpInternalErrorException( request.getURLString() ); - } else if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { - throw new HttpNotFoundException( request.getURLString() ); - } else if (connection.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { - throw new HttpException( connection.getResponseCode(), request.getURLString() ); } else { + if (connection instanceof HttpURLConnection) validateHeaders( request, (HttpURLConnection) connection ); WebResponse result = new WebResponse( this, request.getTarget(), request.getURL(), connection ); if (result.isHTML()) { removeSubFrames( request.getTarget() ); @@ -111,6 +104,19 @@ } + private void validateHeaders( WebRequest request, HttpURLConnection connection ) throws HttpException, IOException { + if (connection.getHeaderField( "WWW-Authenticate" ) != null) { + throw new AuthorizationRequiredException( connection.getHeaderField( "WWW-Authenticate" ) ); + } else if (connection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { + throw new HttpInternalErrorException( request.getURLString() ); + } else if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { + throw new HttpNotFoundException( request.getURLString() ); + } else if (connection.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { + throw new HttpException( connection.getResponseCode(), request.getURLString() ); + } + } + + private void delay( int numMilliseconds ) { if (numMilliseconds == 0) return; try { @@ -219,8 +225,8 @@ HttpURLConnection.setFollowRedirects( false ); } - private HttpURLConnection openConnection( URL url ) throws MalformedURLException, IOException { - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + private URLConnection openConnection( URL url ) throws MalformedURLException, IOException { + URLConnection connection = url.openConnection(); connection.setUseCaches( false ); sendAuthorization( connection ); sendUserAgent( connection ); Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- WebForm.java 2000/11/02 18:37:37 1.14 +++ WebForm.java 2000/11/10 18:48:37 1.15 @@ -141,10 +141,30 @@ * Creates and returns a web request which will simulate the submission of this form with an unnamed submit button. **/ public WebRequest getRequest() { - return getRequest( null ); + return getRequest( (SubmitButton) null ); } + /** + * Creates and returns a web request which will simulate the submission of this form with a button with the specified name and value. + **/ + public WebRequest getRequest( String submitButtonName, String submitButtonValue ) { + SubmitButton sb = getSubmitButton( submitButtonName, submitButtonValue ); + if (sb == null) throw new IllegalSubmitButtonException( submitButtonName, submitButtonValue ); + return getRequest( sb ); + } + + + /** + * Creates and returns a web request which will simulate the submission of this form with a button with the specified name. + **/ + public WebRequest getRequest( String submitButtonName ) { + SubmitButton sb = getSubmitButton( submitButtonName ); + if (sb == null) throw new IllegalSubmitButtonException( submitButtonName, "" ); + return getRequest( sb ); + } + + private SubmitButton getDefaultButton() { if (getSubmitButtons().length == 1) { return getSubmitButtons()[0]; @@ -677,16 +697,24 @@ IllegalSubmitButtonException( SubmitButton button ) { - _button = button; + _name = button.getName(); + _value = button.getValue(); + } + + + IllegalSubmitButtonException( String name, String value ) { + _name = name; + _value = value; } public String getMessage() { - return "Specified submit button (name=\"" + _button.getName() + "\" value=\"" + _button.getValue() + "\") not part of this form."; + return "Specified submit button (name=\"" + _name + "\" value=\"" + _value + "\") not part of this form."; } - private SubmitButton _button; + private String _name; + private String _value; } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- WebResponse.java 2000/10/31 19:54:15 1.21 +++ WebResponse.java 2000/11/10 18:48:37 1.22 @@ -26,6 +26,8 @@ import org.xml.sax.*; import org.w3c.dom.*; +import java.lang.reflect.*; + /** * A response from a web server to an Http request. **/ @@ -148,10 +150,15 @@ /** * Returns a copy of the domain object model tree associated with this response. + * If the response is HTML, it will use a special parser which can transform HTML into an XML DOM. * @exception SAXException thrown if there is an error parsing the response. **/ public Document getDOM() throws SAXException { - return (Document) getReceivedPage().getDOM(); + if (isHTML()) { + return (Document) getReceivedPage().getDOM(); + } else { + return getXMLDOM(); + } } @@ -347,10 +354,52 @@ } + private Document getXMLDOM() throws SAXException { + Document doc = null; + + try { + Class parserClass = Class.forName("org.apache.xerces.parsers.DOMParser"); + Constructor constructor = parserClass.getConstructor( null ); + Object parser = constructor.newInstance( null ); + + Class[] parseMethodArgTypes = { InputSource.class }; + Object[] parseMethodArgs = { new InputSource( new StringReader( _responseText ) ) }; + Method parseMethod = parserClass.getMethod( "parse", parseMethodArgTypes ); + parseMethod.invoke( parser, parseMethodArgs ); + + Method getDocumentMethod = parserClass.getMethod( "getDocument", null ); + doc = (Document)getDocumentMethod.invoke( parser, null ); + } catch (InvocationTargetException ex) { + Throwable tex = ex.getTargetException(); + if (tex instanceof SAXException) { + throw (SAXException)tex; + } else if (tex instanceof IOException) { + throw new RuntimeException( tex.toString() ); + } else { + throw new IllegalStateException( "unexpected exception" ); + } + } catch (NoSuchMethodException ex) { + throw new IllegalStateException( "parse method not found" ); + } catch (IllegalAccessException ex) { + throw new IllegalStateException( "parse method not public" ); + } catch (InstantiationException ex) { + throw new IllegalStateException( "error instantiating parser" ); + } catch (ClassNotFoundException ex) { + throw new IllegalStateException( "parser class not found" ); + } + + return doc; + } + + private void readHeaders( URLConnection connection ) { readContentTypeHeader( connection ); try { - _responseCode = ((HttpURLConnection) connection).getResponseCode(); + if (connection instanceof HttpURLConnection) { + _responseCode = ((HttpURLConnection) connection).getResponseCode(); + } else { + _responseCode = HttpURLConnection.HTTP_OK; + } } catch (IOException e) { } } |
From: Russell G. <rus...@us...> - 2000-11-10 18:48:40
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv20483/doc Modified Files: release_notes.txt Log Message: Added support for XML and local files Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- release_notes.txt 2000/11/02 18:37:24 1.8 +++ release_notes.txt 2000/11/10 18:48:37 1.9 @@ -8,10 +8,20 @@ Revision History: -25-Oct-00 +Acknowledgements: + Thanks to Robert Krueger for providing an interface to the xerces parser for XML web responses. + Thanks to Marco Tamanti and Gabriele Antonelli for suggesting ways to support file URLs + +10-Nov-00 Additions: + 1. XML parsing is now supported. If WebResponse.getDOM is called for a non-HTML response, the xerces parser + will be invoked to treat the response as XML. + 2. File URLs (file:xxx) are now supported + +02-Nov-00 +Additions: 1. Forms with multiple buttons are now supported, using the SubmitButton class. - 2. WebResponse now supports finding a table via its summary text, using getTableWithSummary() + 2. WebResponse now supports finding a table via its summary text, using getTableWithSummary(). Problems corrected: 1. Unnamed parameters are no longer submitted as part of a form request |
From: Russell G. <rus...@us...> - 2000-11-10 18:48:40
|
Update of /cvsroot/httpunit/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv20483 Modified Files: build.xml Log Message: Added support for XML and local files Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- build.xml 2000/10/17 14:15:30 1.13 +++ build.xml 2000/11/10 18:48:36 1.14 @@ -38,7 +38,7 @@ <target name="compile" depends="prepare"> <mkdir dir="${build.classes}" /> <javac srcdir="${src.dir}" destdir="${build.classes}" classpath="${classpath}" - debug="on" deprecation="off" optimize="off"> + debug="on" deprecation="on" optimize="off"> </javac> </target> @@ -48,7 +48,7 @@ <!-- =================================================================== --> <target name="testcompile" depends="compile"> <javac srcdir="${tstsrc.dir}" destdir="${build.classes}" classpath="${classpath}" - debug="on" deprecation="off" optimize="off"> + debug="on" deprecation="on" optimize="off"> </javac> </target> |
From: Russell G. <rus...@us...> - 2000-11-02 18:37:40
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv27738/test/com/meterware/httpunit Modified Files: FormSubmitTest.java Log Message: Completed initial submit button support Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FormSubmitTest.java 2000/10/31 19:54:15 1.2 +++ FormSubmitTest.java 2000/11/02 18:37:37 1.3 @@ -104,6 +104,30 @@ } + public void testImageButtonDefaultSubmit() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=image name=update value=name src=\"\">" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + WebRequest request = form.getRequest(); + assertEquals( getHostPath() + "/ask?update=name&update.x=0&update.y=0&age=12", request.getURL().toExternalForm() ); + } + + + public void testImageButtonPositionalSubmit() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=image name=update value=name src=\"\">" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + WebRequest request = form.getRequest( form.getSubmitButton( "update" ), 10, 15 ); + assertEquals( getHostPath() + "/ask?update=name&update.x=10&update.y=15&age=12", request.getURL().toExternalForm() ); + } + + public void testSubmitButtonAttributes() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + |
From: Russell G. <rus...@us...> - 2000-11-02 18:37:40
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv27738/src/com/meterware/httpunit Modified Files: SubmitButton.java WebForm.java WebRequest.java Log Message: Completed initial submit button support Index: SubmitButton.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SubmitButton.java 2000/10/31 19:54:15 1.1 +++ SubmitButton.java 2000/11/02 18:37:37 1.2 @@ -49,6 +49,17 @@ } + /** + * Returns true if this submit button is an image map. + **/ + public boolean isImageButton() { + return _isImageButton; + } + + +//------------------------------------ Object methods ---------------------------------------- + + public String toString() { return "Submit with " + getName() + "=" + getValue(); } @@ -71,6 +82,7 @@ _node = node; _name = NodeUtils.getNodeAttribute( node, "name" ); _value = NodeUtils.getNodeAttribute( _node, "value" ); + _isImageButton = NodeUtils.getNodeAttribute( _node, "type" ).equalsIgnoreCase( "image" ); } @@ -79,6 +91,7 @@ Node _node; String _name; String _value; + boolean _isImageButton; private SubmitButton() { Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- WebForm.java 2000/10/31 19:54:15 1.13 +++ WebForm.java 2000/11/02 18:37:37 1.14 @@ -145,18 +145,34 @@ } + private SubmitButton getDefaultButton() { + if (getSubmitButtons().length == 1) { + return getSubmitButtons()[0]; + } else if (getSubmitButtonVector().contains( SubmitButton.UNNAMED_BUTTON )) { + return getSubmitButton( "" ); + } else { + return null; + } + } + + /** * Creates and returns a web request which will simulate the submission of this form by pressing the specified button. - * If the button is null, simulates the pressing of an unnamed button. + * If the button is null, simulates the pressing of the default button. **/ + public WebRequest getRequest( SubmitButton button, int x, int y ) { + WebRequest request = getRequest( button ); + request.setSubmitPosition( x, y ); + return request; + } + + + /** + * Creates and returns a web request which will simulate the submission of this form by pressing the specified button. + * If the button is null, simulates the pressing of the default button. + **/ public WebRequest getRequest( SubmitButton button ) { - if (button == null) { - if (getSubmitButtons().length == 1) { - button = getSubmitButtons()[0]; - } else if (getSubmitButtonVector().contains( SubmitButton.UNNAMED_BUTTON )) { - button = getSubmitButton( "" ); - } - } + if (button == null) button = getDefaultButton(); if (HttpUnitOptions.getParameterValuesValidated()) { if (button == null) { Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WebRequest.java 2000/10/31 19:54:15 1.9 +++ WebRequest.java 2000/11/02 18:37:37 1.10 @@ -161,7 +161,11 @@ Enumeration e = _parameters.keys(); if (_submitButton != null && _submitButton.getName().length() > 0) { - appendParameter( sb, _submitButton.getName(), _submitButton.getValue(), e.hasMoreElements() ); + appendParameter( sb, _submitButton.getName(), _submitButton.getValue(), e.hasMoreElements() || _submitButton.isImageButton() ); + if (_submitButton.isImageButton()) { + appendParameter( sb, _submitButton.getName() + ".x", Integer.toString( _submitX ), true ); + appendParameter( sb, _submitButton.getName() + ".y", Integer.toString( _submitY ), e.hasMoreElements() ); + } } while (e.hasMoreElements()) { @@ -183,6 +187,12 @@ final static String TOP_FRAME = "_top"; + void setSubmitPosition( int x, int y ) { + _submitX = x; + _submitY = y; + } + + //--------------------------------------- private members ------------------------------------ /** The name of the system parameter used by java.net to locate protocol handlers. **/ @@ -201,6 +211,8 @@ private WebForm _sourceForm; private SubmitButton _submitButton; private String _target = TOP_FRAME; + private int _submitX; + private int _submitY; private boolean _httpsProtocolSupportEnabled; |
From: Russell G. <rus...@us...> - 2000-11-02 18:37:39
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv27738/doc Modified Files: release_notes.txt Log Message: Completed initial submit button support Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- release_notes.txt 2000/10/31 19:54:14 1.7 +++ release_notes.txt 2000/11/02 18:37:24 1.8 @@ -6,18 +6,12 @@ Limitations: HttpUnit does not support JavaScript -Acknowledgements: -Thanks to Seth Ladd for specific exceptions from WebConversation.getResponse -Thanks to Dave Glowacki for suggestions on convenience methods in WebResponse and WebLink, - and for correcting the set up of the https protocol handling. -Thanks to Perry Doell for the methods to examine cookies on WebConversation -Thanks to Ken Hygh for the proper handling of parameters with no specified type -Thanks to Gabriel Hauser for finding a bug in the handling of parameter defaults Revision History: 25-Oct-00 Additions: 1. Forms with multiple buttons are now supported, using the SubmitButton class. + 2. WebResponse now supports finding a table via its summary text, using getTableWithSummary() Problems corrected: 1. Unnamed parameters are no longer submitted as part of a form request @@ -25,68 +19,41 @@ 3. A problem which caused WebResponse.java to fail compilation under JDK 1.1 has been corrected 17-Oct-00 1.1 -Additions: - 1. It is now possible to set a delay in the handling of redirect requests, if necessary - 2. The WebResponse now can return the response code associated with it (2xx) - 3. An exception (HttpException or a subclass) is now thrown on all client and server errors (4xx or 5xx) +Acknowledgements: + Thanks to Seth Ladd for specific exceptions from WebConversation.getResponse + Thanks to Dave Glowacki for suggestions on convenience methods in WebResponse and WebLink, + and for correcting the set up of the https protocol handling. + Thanks to Perry Doell for the methods to examine cookies on WebConversation + Thanks to Ken Hygh for the proper handling of parameters with no specified type + Thanks to Gabriel Hauser for finding a bug in the handling of parameter defaults -Problems corrected: - 1. Unnamed frames are now handled - 2. Empty parameter values are now handled - - 6-Oct-00 -Problems corrected: - 1. Base tag is now handled to override defaults for page URL and target - - 5-Oct-00 -Problems corrected: - 1. Blank "src" attributes in FRAME nodes now correctly result in a blank page - 2. The "_self" target is now handled as the default target - - 4-Oct-00 -Additions: - 1. Frames are now supported. The WebConversation method has two methods: getFrameNames and getFrameContents which - allow manipulation of frames. - 2. Calling HttpUnitOptions.setImagesTreatedAsAltText( true ) will cause the ALT text in images to be treated as ordinary - text - Problems corrected: - 1. It is no longer necessary to edit the java.security file to enable HTTPS support. Just install the JSSE jars - in your classpath. - 2. Parameters with no type specified are now properly handled as text - + 1. The value parameter for checkboxes is no longer ignored + 2. Previously, getTableStartingWith[Prefix] only checked the nested tables in cell (0,0) of each outer table + 3. Parameters with no type specified are now properly handled as text + 4. Base tag is now handled to override defaults for page URL and target + 5. Empty parameter values are now handled -28-Sep-00 Additions: - 1. PseudoServer class is now used by unit tests to handle requests. This will enable development of frames capability + 1. The license agreement is now available from the home page and javadoc 2. Https support is now built in; however, it depends on the JSSE extension (not included). - See http://java.sun.com/products/jsse and be careful to follow the installation instructions - -25-Sep-00 -Problems corrected: - 1. In the 15-Sep build, the value parameter for checkboxes was ignored in computing defaults and validating - parameter values - all checkboxes were assumed to have the value 'on' only - 2. getTableStartingWith[Prefix] only checked the nested tables in cell (0,0) of each outer table - -Additions: - 3. WebConversation now supports getCookieNames and getCookieValue to return the current cookies - -15-Sep-00 - -General: - 1. Non-breaking spaces are converted to spaces on any conversion to text - 2. WebConversation.getResponse() can now throw HttpInternalErrorException and HttpNotFoundException - in response to 501 and 404 codes, respectively - 3. By default, parser warnings are no longer displayed. They may be enabled by a call to - HttpUnitOptions.setParserWarningsEnabled( true ) + See http://java.sun.com/products/jsse. + 3. Frames are now supported. The WebConversation method has two methods: getFrameNames and getFrameContents which + allow manipulation of frames. 4. By default, WebRequest.setParameter will now throw IllegalRequestParameterException on any attempt - to set a form parameter to a value not normally available from the browser. This checking can be - disabled via a call to HttpUnitOptions.setParameterValuesValidated( false ) -Additions: - 1. WebResponse.getTitle() returns the HTML title of the page - 2. WebLink.getURLString() returns the URL string specified by the link in its href attribute - 3. The license agreement is now available from the home page and javadoc - 4. WebResponse.getURL() return the URL used to retrieve the page + to set a form parameter to a value not normally available from the browser. + 5. It is possible to modify the behavior of HttpUnit via static methods on HttpUnitOptions. This includes: + o enabling parser warnings (disabled by default) + o disabling parameter validation (enabled by default) + 6. WebConversation.getResponse now throws HttpException if any 4xx or 5xx code is returned. The exact code is + available from the exception + 7. WebResponse.getTitle() returns the HTML title of the page + 8. WebLink.getURLString() returns the URL string specified by the link in its href attribute + 9. WebResponse.getURL() return the URL used to retrieve the page + 10. WebConversation now supports getCookieNames and getCookieValue to return the current cookies + 11. The WebResponse now can return the response code associated with it (2xx) + 12. Non-breaking spaces are converted to spaces on any conversion to text + 1-Sep-00 1.0 |
From: Russell G. <rus...@us...> - 2000-10-31 19:54:17
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv1904/doc Modified Files: release_notes.txt Log Message: Initial submit button support Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- release_notes.txt 2000/10/26 14:16:49 1.6 +++ release_notes.txt 2000/10/31 19:54:14 1.7 @@ -2,7 +2,7 @@ Known problems: 1. The "_parent" and "_empty" frame targets are not handled correctly - 2. The "_self" target only works for links + 2. The "_self" target only works for links, not forms Limitations: HttpUnit does not support JavaScript @@ -16,9 +16,13 @@ Revision History: 25-Oct-00 +Additions: + 1. Forms with multiple buttons are now supported, using the SubmitButton class. + Problems corrected: 1. Unnamed parameters are no longer submitted as part of a form request 2. Searching for tables beginning with a string no longer aborts with NullPointerException if the table is missing cells + 3. A problem which caused WebResponse.java to fail compilation under JDK 1.1 has been corrected 17-Oct-00 1.1 Additions: |
From: Russell G. <rus...@us...> - 2000-10-31 19:54:17
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv1904/src/com/meterware/httpunit Modified Files: GetMethodWebRequest.java ParsedHTML.java PostMethodWebRequest.java WebForm.java WebRequest.java WebResponse.java WebTable.java Added Files: SubmitButton.java Log Message: Initial submit button support ***** Error reading new file(2, 'No such file or directory') Index: GetMethodWebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- GetMethodWebRequest.java 2000/10/02 16:32:10 1.5 +++ GetMethodWebRequest.java 2000/10/31 19:54:15 1.6 @@ -58,8 +58,8 @@ /** * Constructs a web request for a form. **/ - GetMethodWebRequest( URL urlBase, String urlString, String target, WebForm sourceForm ) { - super( urlBase, urlString, target, sourceForm ); + GetMethodWebRequest( URL urlBase, String urlString, String target, WebForm sourceForm, SubmitButton button ) { + super( urlBase, urlString, target, sourceForm, button ); } Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ParsedHTML.java 2000/10/26 14:16:49 1.9 +++ ParsedHTML.java 2000/10/31 19:54:15 1.10 @@ -135,6 +135,16 @@ /** + * Returns the first table in the response which has the specified text as its summary attribute. + * Will recurse into any nested tables, as needed. + * @return the selected table, or null if none is found + **/ + public WebTable getTableWithSummary( String summary ) { + return getTableWithSummary( summary, getTables() ); + } + + + /** * Returns a copy of the domain object model associated with this page. **/ public Node getDOM() { @@ -258,6 +268,33 @@ WebTable[] innerTables = cell.getTables(); if (innerTables.length != 0) { WebTable result = getTableStartingWithPrefix( text, innerTables ); + if (result != null) return result; + } + } + } + } + } + } + return null; + } + + + + /** + * Returns the table with the specified text in its summary attribute. + **/ + private WebTable getTableWithSummary( String summary, WebTable[] tables ) { + for (int i = 0; i < tables.length; i++) { + if (tables[i].getSummary().equalsIgnoreCase( summary )) { + return tables[i]; + } else { + for (int j = 0; j < tables[i].getRowCount(); j++) { + for (int k = 0; k < tables[i].getColumnCount(); k++) { + TableCell cell = tables[i].getTableCell(j,k); + if (cell != null) { + WebTable[] innerTables = cell.getTables(); + if (innerTables.length != 0) { + WebTable result = getTableWithSummary( summary, innerTables ); if (result != null) return result; } } Index: PostMethodWebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- PostMethodWebRequest.java 2000/10/02 16:32:10 1.6 +++ PostMethodWebRequest.java 2000/10/31 19:54:15 1.7 @@ -58,8 +58,8 @@ /** * Constructs a web request for a form. **/ - PostMethodWebRequest( URL urlBase, String urlString, String target, WebForm sourceForm ) { - super( urlBase, urlString, target, sourceForm ); + PostMethodWebRequest( URL urlBase, String urlString, String target, WebForm sourceForm, SubmitButton button ) { + super( urlBase, urlString, target, sourceForm, button ); } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- WebForm.java 2000/10/26 14:16:49 1.12 +++ WebForm.java 2000/10/31 19:54:15 1.13 @@ -75,17 +75,105 @@ /** - * Creates and returns a web request which will simulate the submission of this form. + * Returns an array containing the submit buttons defined for this form. **/ + public SubmitButton[] getSubmitButtons() { + if (_submitButtons == null) { + Vector buttons = getSubmitButtonVector(); + _submitButtons = new SubmitButton[ buttons.size() ]; + buttons.copyInto( _submitButtons ); + } + return _submitButtons; + } + + + + private Vector _buttonVector; + + private Vector getSubmitButtonVector() { + if (_buttonVector == null) { + _buttonVector = new Vector(); + NodeList nl = ((Element) _node).getElementsByTagName( "input" ); + for (int i = 0; i < nl.getLength(); i++) { + if (NodeUtils.getNodeAttribute( nl.item(i), "type" ).equalsIgnoreCase( "submit" ) + || NodeUtils.getNodeAttribute( nl.item(i), "type" ).equalsIgnoreCase( "image" )) { + _buttonVector.addElement( new SubmitButton( nl.item(i) ) ); + } + } + } + return _buttonVector; + } + + + /** + * Returns the submit button defined in this form with the specified name. + * If more than one such button exists, will return the first found. + * If no such button is found, will return null. + **/ + public SubmitButton getSubmitButton( String name ) { + SubmitButton[] buttons = getSubmitButtons(); + for (int i = 0; i < buttons.length; i++) { + if (buttons[i].getName().equals( name )) { + return buttons[i]; + } + } + return null; + } + + + /** + * Returns the submit button defined in this form with the specified name and value. + * If more than one such button exists, will return the first found. + * If no such button is found, will return null. + **/ + public SubmitButton getSubmitButton( String name, String value ) { + SubmitButton[] buttons = getSubmitButtons(); + for (int i = 0; i < buttons.length; i++) { + if (buttons[i].getName().equals( name ) && buttons[i].getValue().equals( value )) { + return buttons[i]; + } + } + return null; + } + + + /** + * Creates and returns a web request which will simulate the submission of this form with an unnamed submit button. + **/ public WebRequest getRequest() { + return getRequest( null ); + } + + + /** + * Creates and returns a web request which will simulate the submission of this form by pressing the specified button. + * If the button is null, simulates the pressing of an unnamed button. + **/ + public WebRequest getRequest( SubmitButton button ) { + if (button == null) { + if (getSubmitButtons().length == 1) { + button = getSubmitButtons()[0]; + } else if (getSubmitButtonVector().contains( SubmitButton.UNNAMED_BUTTON )) { + button = getSubmitButton( "" ); + } + } + + if (HttpUnitOptions.getParameterValuesValidated()) { + if (button == null) { + throw new IllegalUnnamedSubmitButtonException(); + } else if (!getSubmitButtonVector().contains( button )) { + throw new IllegalSubmitButtonException( button ); + } + } + NamedNodeMap nnm = _node.getAttributes(); String action = getValue( nnm.getNamedItem( "action" ) ); WebRequest result; if (getValue( nnm.getNamedItem( "method" ) ).equalsIgnoreCase( "post" )) { - result = new PostMethodWebRequest( _baseURL, action, getTarget(), this ); + result = new PostMethodWebRequest( _baseURL, action, getTarget(), this, button ); } else { - result = new GetMethodWebRequest( _baseURL, action, getTarget(), this ); + result = new GetMethodWebRequest( _baseURL, action, getTarget(), this, button ); } String[] parameterNames = getParameterNames(); @@ -100,7 +188,6 @@ } } return result; - } @@ -219,10 +306,12 @@ /** The target in which the parent response is to be rendered. **/ private String _parentTarget; + /** The submit buttons in this form. **/ + private SubmitButton[] _submitButtons; + /** The selections in this form. **/ private HTMLSelectElement[] _selections; - /** The text areas in this form. **/ private HTMLTextAreaElement[] _textAreas; @@ -539,7 +628,50 @@ } } +} + + +//============================= exception class IllegalUnnamedSubmitButtonException ====================================== + + +/** + * This exception is thrown on an attempt to define a form request with a button not defined on that form. + **/ +class IllegalUnnamedSubmitButtonException extends IllegalRequestParameterException { + + + IllegalUnnamedSubmitButtonException() { + } + + public String getMessage() { + return "This form has no unnamed buttons"; + } } + + +//============================= exception class IllegalSubmitButtonException ====================================== + + +/** + * This exception is thrown on an attempt to define a form request with a button not defined on that form. + **/ +class IllegalSubmitButtonException extends IllegalRequestParameterException { + + + IllegalSubmitButtonException( SubmitButton button ) { + _button = button; + } + + + public String getMessage() { + return "Specified submit button (name=\"" + _button.getName() + "\" value=\"" + _button.getValue() + "\") not part of this form."; + } + + + private SubmitButton _button; + +} + Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- WebRequest.java 2000/10/11 19:15:11 1.8 +++ WebRequest.java 2000/10/31 19:54:15 1.9 @@ -99,7 +99,7 @@ * Constructs a web request using a base URL and a relative URL string. **/ protected WebRequest( URL urlBase, String urlString ) { - this( urlBase, urlString, (WebForm) null ); + this( urlBase, urlString, TOP_FRAME ); } @@ -107,26 +107,19 @@ * Constructs a web request using a base URL, a relative URL string, and a target. **/ protected WebRequest( URL urlBase, String urlString, String target ) { - this( urlBase, urlString, target, null ); + _urlBase = urlBase; + _urlString = urlString; + _target = target; } - /** - * Constructs a web request using a base URL and a relative URL string. - **/ - protected WebRequest( URL urlBase, String urlString, WebForm sourceForm ) { - this( urlBase, urlString, TOP_FRAME, sourceForm ); - } - - /** - * Constructs a web request using a base URL and a relative URL string. + * Constructs a web request from a form. **/ - protected WebRequest( URL urlBase, String urlString, String target, WebForm sourceForm ) { - _urlBase = urlBase; - _urlString = urlString; - _sourceForm = sourceForm; - _target = target; + protected WebRequest( URL urlBase, String urlString, String target, WebForm sourceForm, SubmitButton button ) { + this( urlBase, urlString, target ); + _sourceForm = sourceForm; + _submitButton = button; } @@ -134,7 +127,7 @@ * Constructs a web request using a base request and a relative URL string. **/ protected WebRequest( WebRequest baseRequest, String urlString ) throws MalformedURLException { - this( baseRequest.getURL(), urlString, (WebForm) null ); + this( baseRequest.getURL(), urlString ); } @@ -165,7 +158,13 @@ final protected String getParameterString() { StringBuffer sb = new StringBuffer(); - for (Enumeration e = _parameters.keys(); e.hasMoreElements();) { + Enumeration e = _parameters.keys(); + + if (_submitButton != null && _submitButton.getName().length() > 0) { + appendParameter( sb, _submitButton.getName(), _submitButton.getValue(), e.hasMoreElements() ); + } + + while (e.hasMoreElements()) { String name = (String) e.nextElement(); Object value = _parameters.get( name ); if (value instanceof String) { @@ -196,13 +195,14 @@ private final static String SSL_PROTOCOL_HANDLER = "com.sun.net.ssl.internal.www.protocol"; - private URL _urlBase; - private String _urlString; - private Hashtable _parameters = new Hashtable(); - private WebForm _sourceForm; - private String _target = TOP_FRAME; + private URL _urlBase; + private String _urlString; + private Hashtable _parameters = new Hashtable(); + private WebForm _sourceForm; + private SubmitButton _submitButton; + private String _target = TOP_FRAME; - private boolean _httpsProtocolSupportEnabled; + private boolean _httpsProtocolSupportEnabled; private void appendParameters( StringBuffer sb, String name, String[] values, boolean moreToCome ) { Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- WebResponse.java 2000/10/12 16:16:35 1.20 +++ WebResponse.java 2000/10/31 19:54:15 1.21 @@ -180,6 +180,18 @@ /** + * Returns the first table in the response which has the specified text as its summary attribute. + * Will recurse into any nested tables, as needed. + * Case is ignored. + * @exception SAXException thrown if there is an error parsing the response. + * @return the selected table, or null if none is found + **/ + public WebTable getTableWithSummary( String text ) throws SAXException { + return getReceivedPage().getTableWithSummary( text ); + } + + + /** * Returns the text of the response (excluding headers) as a string. Use this method in preference to 'toString' * which may be used to represent internal state of this object. **/ @@ -258,12 +270,16 @@ private String _characterSet = "us-ascii"; private int _responseCode; + + + // the following variables are essentially final; however, the JDK 1.1 compiler does not handle final variables properly with + // multiple constructors that call each other, so the final qualifiers have been removed. - final private URL _url; + private URL _url; - final private WebConversation _conversation; + private WebConversation _conversation; - final private String _target; + private String _target; /** Index: WebTable.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WebTable.java 2000/10/02 16:32:10 1.10 +++ WebTable.java 2000/10/31 19:54:15 1.11 @@ -150,7 +150,7 @@ /** - * Returns a rendering of the table with all cells converted to text. + * Returns a rendering of this table with all cells converted to text. **/ public String[][] asText() { String[][] result = new String[ getRowCount() ][ getColumnCount() ]; @@ -161,6 +161,14 @@ } } return result; + } + + + /** + * Returns the summary attribute associated with this table. + **/ + public String getSummary() { + return NodeUtils.getNodeAttribute( _dom, "summary" ); } |
From: Russell G. <rus...@us...> - 2000-10-31 19:54:17
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv1904/test/com/meterware/httpunit Modified Files: FormParametersTest.java FormSubmitTest.java HtmlTablesTest.java WebFormTest.java Log Message: Initial submit button support Index: FormParametersTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FormParametersTest.java 2000/09/27 18:04:04 1.3 +++ FormParametersTest.java 2000/10/31 19:54:15 1.4 @@ -59,7 +59,7 @@ "<Select name=colors><Option>blue<Option>red</Select>" + "<Select name=fish><Option value=red>snapper<Option value=pink>salmon</select>" + "<Select name=media multiple size=2><Option>TV<Option>Radio</select>" + - "</form>" ); + "<Input type=submit name=submit value=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( false ); @@ -77,7 +77,7 @@ "<Select name=colors><Option>blue<Option>red</Select>" + "<Select name=fish><Option value=red>snapper<Option value=pink>salmon</select>" + "<Select name=media multiple size=2><Option>TV<Option>Radio</select>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( true ); @@ -102,7 +102,7 @@ "<Input type=text name=color>" + "<Input type=password name=password>" + "<Input type=hidden name=secret>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( false ); @@ -120,7 +120,7 @@ "<Input type=text name=color>" + "<Input type=password name=password>" + "<Input type=hidden name=secret>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( true ); @@ -138,7 +138,7 @@ "<Input type=radio name=color value=red>" + "<Input type=radio name=color value=blue>" + "<Input type=radio name=color value=green>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( false ); @@ -152,7 +152,7 @@ "<Input type=radio name=color value=red>" + "<Input type=radio name=color value=blue>" + "<Input type=radio name=color value=green>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( true ); @@ -168,7 +168,7 @@ "<Input type=checkbox name=use_color>" + "<Input type=checkbox name=color value=red>" + "<Input type=checkbox name=color value=blue>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); HttpUnitOptions.setParameterValuesValidated( false ); Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FormSubmitTest.java 2000/10/26 14:16:49 1.1 +++ FormSubmitTest.java 2000/10/31 19:54:15 1.2 @@ -57,6 +57,7 @@ public void testSubmitString() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age>" + + "<Input type=submit value=Go>" + "</form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); @@ -69,11 +70,154 @@ defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text value=dontSend>" + "<Input type=text name=age>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebRequest request = page.getForms()[0].getRequest(); request.setParameter( "age", "23" ); assertEquals( getHostPath() + "/ask?age=23", request.getURL().toExternalForm() ); + } + + + public void testSubmitButtonDetection() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update>" + + "<Input type=submit name=recalculate>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + SubmitButton[] buttons = form.getSubmitButtons(); + assertEquals( "num detected submit buttons", 2, buttons.length ); + } + + + public void testImageButtonDetection() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=image name=update src=\"\">" + + "<Input type=image name=recalculate src=\"\">" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + SubmitButton[] buttons = form.getSubmitButtons(); + assertEquals( "num detected submit buttons", 2, buttons.length ); + } + + + public void testSubmitButtonAttributes() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + SubmitButton[] buttons = form.getSubmitButtons(); + assertEquals( "num detected submit buttons", 1, buttons.length ); + assertEquals( "submit button name", "update", buttons[0].getName() ); + assertEquals( "submit button value", "age", buttons[0].getValue() ); + } + + + public void testSubmitButtonSelectionByName() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "<Input type=submit name=recompute value=age>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + SubmitButton button = form.getSubmitButton( "zork" ); + assertNull( "Found a non-existent button", button ); + button = form.getSubmitButton( "update" ); + assertNotNull( "Didn't find the desired button", button ); + assertEquals( "submit button name", "update", button.getName() ); + assertEquals( "submit button value", "age", button.getValue() ); + } + + + public void testSubmitButtonSelectionByNameAndValue() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "<Input type=submit name=update value=name>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + SubmitButton button = form.getSubmitButton( "update" ); + assertNotNull( "Didn't find the desired button", button ); + assertEquals( "submit button name", "update", button.getName() ); + assertEquals( "submit button value", "age", button.getValue() ); + button = form.getSubmitButton( "update", "name" ); + assertNotNull( "Didn't find the desired button", button ); + assertEquals( "submit button name", "update", button.getName() ); + assertEquals( "submit button value", "name", button.getValue() ); + } + + + public void testNamedButtonSubmitString() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "<Input type=submit name=update value=name>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + WebRequest request = form.getRequest( form.getSubmitButton( "update", "name" ) ); + assertEquals( getHostPath() + "/ask?update=name&age=12", request.getURL().toExternalForm() ); + } + + + public void testUnnamedButtonSubmit() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "<Input type=submit name=update value=name>" + + "</form>" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + try { + WebRequest request = form.getRequest(); + fail( "Should not allow submit with unnamed button" ); + } catch (IllegalRequestParameterException e) { + } + } + + + public void testForeignSubmitButtonDetection() throws Exception { + defineWebPage( "Default", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "<Input type=submit name=update value=name>" + + "</form>" ); + defineWebPage( "Dupl", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=update value=age>" + + "<Input type=submit name=update value=name>" + + "</form>" ); + defineWebPage( "Wrong", "<form method=GET action = \"/ask\">" + + "<Input type=text name=age value=12>" + + "<Input type=submit name=save value=age>" + + "</form>" ); + WebResponse other = _wc.getResponse( getHostPath() + "/Dupl.html" ); + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebResponse wrong = _wc.getResponse( getHostPath() + "/Wrong.html" ); + + WebForm form = page.getForms()[0]; + WebForm otherForm = other.getForms()[0]; + WebForm wrongForm = wrong.getForms()[0]; + + HttpUnitOptions.setParameterValuesValidated( true ); + WebRequest request = form.getRequest( otherForm.getSubmitButtons()[0] ); + + HttpUnitOptions.setParameterValuesValidated( false ); + request = form.getRequest( wrongForm.getSubmitButtons()[0] ); + + HttpUnitOptions.setParameterValuesValidated( true ); + try { + request = form.getRequest( wrongForm.getSubmitButtons()[0] ); + fail( "Failed to reject illegal button" ); + } catch (IllegalRequestParameterException e) { + } } Index: HtmlTablesTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- HtmlTablesTest.java 2000/09/27 18:04:04 1.9 +++ HtmlTablesTest.java 2000/10/31 19:54:15 1.10 @@ -210,6 +210,13 @@ assertEquals( "Non-blank rows", 2, cells.length ); assertEquals( "Non-blank columns", 2, cells[0].length ); assertEquals( "cell at 1,0", "Blue", cells[1][0] ); + + wt = page.getTableWithSummary( "Inner One" ); + assertNotNull( "Did not find table starting with summary 'Inner One'", wt ); + cells = wt.asText(); + assertEquals( "Total rows", 3, cells.length ); + assertEquals( "Total columns", 2, cells[0].length ); + assertEquals( "cell at 2,0", "Blue", cells[2][0] ); } Index: WebFormTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFormTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebFormTest.java 2000/10/17 14:14:35 1.7 +++ WebFormTest.java 2000/10/31 19:54:15 1.8 @@ -145,7 +145,7 @@ "<Select name=color><Option>blue<Option selected>red \n" + "<Option>green</select>" + "<TextArea name=\"text\">Sample text</TextArea>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); @@ -165,7 +165,7 @@ "<Select multiple size=4 name=colors>" + "<Option>blue<Option selected>red \n" + "<Option>green<Option value=\"pink\" selected>salmon</select>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebForm form = page.getForms()[0]; @@ -186,7 +186,7 @@ "<Select name=colors><Option>blue<Option>red</Select>" + "<Select name=fish><Option value=red>snapper<Option value=pink>salmon</select>" + "<Select name=media multiple size=2><Option>TV<Option>Radio</select>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); @@ -210,7 +210,7 @@ "<Input type=checkbox name=color value=blue checked>" + "<Input type=checkbox name=gender value=male checked>" + "<Input type=checkbox name=gender value=female>" + - "</form>" ); + "<Input type=submit></form>" ); WebResponse response = _wc.getResponse( getHostPath() + "/Default.html" ); assertNotNull( response.getForms() ); |
From: Russell G. <rus...@us...> - 2000-10-26 14:21:32
|
Update of /cvsroot/httpunit/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv25714 Modified Files: index.html Log Message: Correct spacing Index: index.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/index.html,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- index.html 2000/10/26 14:20:08 1.10 +++ index.html 2000/10/26 14:21:29 1.11 @@ -33,7 +33,7 @@ <blockquote>The latest release of HttpUnit is available <var:dist from the <a href="http://httpunit.sourceforge.net"><var:dist HttpUnit home page</A> <var:publish>as a <a href="http://httpunit.sourceforge.net/httpunit_<version>.zip"><var:publish>zip file</A> -.<var:publish><br><var:publish> Other builds are available by <a href="ftp://httpunit.sourceforge.net/pub/httpunit"> +.<var:publish><br><var:publish>Other builds are available by <a href="ftp://httpunit.sourceforge.net/pub/httpunit"> <var:publish>anonymous ftp</a>. <b><var:publish>Note: JTidy is now being hosted on SourceForge. You may download it from <a href="http://sourceforge.net/project/showfiles.php?group_id=13153"><var:publish>the project download area</a></b>. @@ -48,7 +48,7 @@ a cvs client, accessing the repository at <code>:pserver:ano...@cv...:/cvsroot/httpunit</code>. </ul> -<hr><P><font size=-2><var:publish> Hosted by +<hr><P><font size=-2><var:publish>Hosted by <IMG SRC="http://sourceforge.net/sflogo.php?group_id=6550&type=1" WIDTH="88" HEIGHT="31" BORDER="0" ALT="SourceForge Logo" NATURALSIZEFLAG="0" ALIGN="TOP"></font></p> |
From: Russell G. <rus...@us...> - 2000-10-26 14:20:11
|
Update of /cvsroot/httpunit/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv25564 Modified Files: index.html Log Message: Correct spacing Index: index.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/index.html,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- index.html 2000/10/26 14:16:49 1.9 +++ index.html 2000/10/26 14:20:08 1.10 @@ -31,12 +31,12 @@ <h2>Where do I get releases?</h2> <blockquote>The latest release of HttpUnit is available -<var:dist from the <a href="http://httpunit.sourceforge.net"><var:dist HttpUnit home page</A> -<var:publish> as a <a href="http://httpunit.sourceforge.net/httpunit_<version>.zip"><var:publish> zip file</A> -.<var:publish> <br><var:publish> Other builds are available by <a href="ftp://httpunit.sourceforge.net/pub/httpunit"> -<var:publish> anonymous ftp</a>. -<b><var:publish> Note: JTidy is now being hosted on SourceForge. -You may download it from <a href="http://sourceforge.net/project/showfiles.php?group_id=13153"><var:publish> the project download area</a></b>. +<var:dist from the <a href="http://httpunit.sourceforge.net"><var:dist HttpUnit home page</A> +<var:publish>as a <a href="http://httpunit.sourceforge.net/httpunit_<version>.zip"><var:publish>zip file</A> +.<var:publish><br><var:publish> Other builds are available by <a href="ftp://httpunit.sourceforge.net/pub/httpunit"> +<var:publish>anonymous ftp</a>. +<b><var:publish>Note: JTidy is now being hosted on SourceForge. +You may download it from <a href="http://sourceforge.net/project/showfiles.php?group_id=13153"><var:publish>the project download area</a></b>. </blockquote> <h2>How do I contribute, give feedback, fix bugs and so on?</h2> |
From: Russell G. <rus...@us...> - 2000-10-26 14:16:52
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv25355/src/com/meterware/httpunit Modified Files: ParsedHTML.java WebForm.java package.html Log Message: Minor bug fixes; begin multiple button support Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ParsedHTML.java 2000/10/06 18:38:54 1.8 +++ ParsedHTML.java 2000/10/26 14:16:49 1.9 @@ -224,10 +224,13 @@ } else { for (int j = 0; j < tables[i].getRowCount(); j++) { for (int k = 0; k < tables[i].getColumnCount(); k++) { - WebTable[] innerTables = tables[i].getTableCell(j,k).getTables(); - if (innerTables.length != 0) { - WebTable result = getTableStartingWith( text, innerTables ); - if (result != null) return result; + TableCell cell = tables[i].getTableCell(j,k); + if (cell != null) { + WebTable[] innerTables = cell.getTables(); + if (innerTables.length != 0) { + WebTable result = getTableStartingWith( text, innerTables ); + if (result != null) return result; + } } } } @@ -250,10 +253,13 @@ } else { for (int j = 0; j < tables[i].getRowCount(); j++) { for (int k = 0; k < tables[i].getColumnCount(); k++) { - WebTable[] innerTables = tables[i].getTableCell(j,k).getTables(); - if (innerTables.length != 0) { - WebTable result = getTableStartingWithPrefix( text, innerTables ); - if (result != null) return result; + TableCell cell = tables[i].getTableCell(j,k); + if (cell != null) { + WebTable[] innerTables = cell.getTables(); + if (innerTables.length != 0) { + WebTable result = getTableStartingWithPrefix( text, innerTables ); + if (result != null) return result; + } } } } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- WebForm.java 2000/10/17 14:14:35 1.11 +++ WebForm.java 2000/10/26 14:16:49 1.12 @@ -90,7 +90,7 @@ String[] parameterNames = getParameterNames(); for (int i = 0; i < parameterNames.length; i++) { - if (getParameterDefaults().get( parameterNames[i] ) != null) { + if (parameterNames[i].length() > 0 && getParameterDefaults().get( parameterNames[i] ) != null) { Object value = getParameterDefaults().get( parameterNames[i] ); if (value instanceof String) { result.setParameter( parameterNames[i], (String) value); Index: package.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/package.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- package.html 2000/10/12 16:16:35 1.3 +++ package.html 2000/10/26 14:16:49 1.4 @@ -8,10 +8,9 @@ requests based on either submitting a form or clicking on a link. <H2>Installation</H2> -The package depends on <A HREF="http://httpunit.sourceforge.net/Tidy.jar.zip">JTidy</A>, created by Andy Quick. +The package depends on <A HREF="http://lempinen.net/sami/jtidy">JTidy</A>, an HTML parser/validator. The jtidy.jar must be in the class path ahead of any other implementation of the DOM classes. In addition, -unit tests will require <A HREF=http://www.xprogramming.com/ftp/TestingFramework/JUnit/junit32.zip>JUnit</A> -as well. +unit tests will require <A HREF="http://junit.org/">JUnit</A> as well. <H2>Example</H2> |
From: Russell G. <rus...@us...> - 2000-10-26 14:16:52
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv25355/test/com/meterware/httpunit Modified Files: HttpUnitSuite.java Added Files: FormSubmitTest.java Log Message: Minor bug fixes; begin multiple button support ***** Error reading new file(2, 'No such file or directory') Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- HttpUnitSuite.java 2000/10/12 16:16:36 1.8 +++ HttpUnitSuite.java 2000/10/26 14:16:49 1.9 @@ -43,6 +43,7 @@ suite.addTest( WebFrameTest.suite() ); suite.addTest( RequestTargetTest.suite() ); suite.addTest( FormParametersTest.suite() ); + suite.addTest( FormSubmitTest.suite() ); suite.addTest( Base64Test.suite() ); suite.addTest( PseudoServerTest.suite() ); return suite; |
From: Russell G. <rus...@us...> - 2000-10-26 14:16:52
|
Update of /cvsroot/httpunit/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv25355 Modified Files: index.html Log Message: Minor bug fixes; begin multiple button support Index: index.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/index.html,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- index.html 2000/10/12 16:16:35 1.8 +++ index.html 2000/10/26 14:16:49 1.9 @@ -31,12 +31,12 @@ <h2>Where do I get releases?</h2> <blockquote>The latest release of HttpUnit is available -<var:dist> from the <a href="http://httpunit.sourceforge.net"><var:dist> HttpUnit home page</A> -<var:publish as a <a href="http://httpunit.sourceforge.net/httpunit_<version>.zip"><var:publish zip file</A> -.<var:publish <br><var:publish Other builds are available by <a href="ftp://httpunit.sourceforge.net/pub/httpunit"> -<var:publish anonymous ftp</a>. -<b><var:publish Note: Andy Quick has dropped support for JTidy, a library on which HttpUnit depends. I am investigating the situation. -For now, you may download it from <a href="Tidy.jar.zip"><var:publish this site</a></b>. +<var:dist from the <a href="http://httpunit.sourceforge.net"><var:dist HttpUnit home page</A> +<var:publish> as a <a href="http://httpunit.sourceforge.net/httpunit_<version>.zip"><var:publish> zip file</A> +.<var:publish> <br><var:publish> Other builds are available by <a href="ftp://httpunit.sourceforge.net/pub/httpunit"> +<var:publish> anonymous ftp</a>. +<b><var:publish> Note: JTidy is now being hosted on SourceForge. +You may download it from <a href="http://sourceforge.net/project/showfiles.php?group_id=13153"><var:publish> the project download area</a></b>. </blockquote> <h2>How do I contribute, give feedback, fix bugs and so on?</h2> @@ -48,7 +48,7 @@ a cvs client, accessing the repository at <code>:pserver:ano...@cv...:/cvsroot/httpunit</code>. </ul> -<hr><P><font size=-2><var:publish Hosted by +<hr><P><font size=-2><var:publish> Hosted by <IMG SRC="http://sourceforge.net/sflogo.php?group_id=6550&type=1" WIDTH="88" HEIGHT="31" BORDER="0" ALT="SourceForge Logo" NATURALSIZEFLAG="0" ALIGN="TOP"></font></p> |
From: Russell G. <rus...@us...> - 2000-10-26 14:16:52
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv25355/doc Modified Files: release_notes.txt Log Message: Minor bug fixes; begin multiple button support Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- release_notes.txt 2000/10/17 14:14:35 1.5 +++ release_notes.txt 2000/10/26 14:16:49 1.6 @@ -15,6 +15,11 @@ Thanks to Gabriel Hauser for finding a bug in the handling of parameter defaults Revision History: +25-Oct-00 +Problems corrected: + 1. Unnamed parameters are no longer submitted as part of a form request + 2. Searching for tables beginning with a string no longer aborts with NullPointerException if the table is missing cells + 17-Oct-00 1.1 Additions: 1. It is now possible to set a delay in the handling of redirect requests, if necessary |
From: Russell G. <rus...@us...> - 2000-10-17 14:15:32
|
Update of /cvsroot/httpunit/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv4936 Modified Files: build.xml Log Message: Prepare for 1.1 release Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- build.xml 2000/09/28 18:27:39 1.12 +++ build.xml 2000/10/17 14:15:30 1.13 @@ -5,8 +5,8 @@ <project name="httpunit" default="jar" basedir="."> <property name="name" value="httpunit" /> <property name="Name" value="HttpUnit" /> - <property name="version" value="1.0" /> - <property name="zip_version" value="1_0" /> + <property name="version" value="1.1" /> + <property name="zip_version" value="1_1" /> <property name="src.dir" value="src" /> <property name="tstsrc.dir" value="test" /> <property name="examples.dir" value="examples" /> |
From: Russell G. <rus...@us...> - 2000-10-17 14:14:38
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv4824/test/com/meterware/httpunit Modified Files: WebFormTest.java Log Message: Handle empty default values Index: WebFormTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFormTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WebFormTest.java 2000/10/03 13:41:04 1.6 +++ WebFormTest.java 2000/10/17 14:14:35 1.7 @@ -100,6 +100,24 @@ } + public void testNullTextValues() throws Exception { + defineWebPage( "Default", "<form method=POST action = \"/servlet/Login\">" + + "<Input name=\"secret\" type=\"hidden\" value=>" + + "<br><Input name=typeless value=>" + + "<B>Enter the name 'master': <Input type=TEXT Name=name></B>" + + "<br><Input type=submit value = \"Log in\">" + + "</form>" ); + + WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); + WebForm form = page.getForms()[0]; + assertEquals( 3, form.getParameterNames().length ); + + WebRequest request = form.getRequest(); + assertEquals( "", request.getParameter( "secret" ) ); + assertEquals( "", request.getParameter( "typeless" ) ); + } + + public void testTableForm() throws Exception { defineWebPage( "Default", "<form method=POST action = \"/servlet/Login\">" + "<table summary=\"\"><tr><td>" + |
From: Russell G. <rus...@us...> - 2000-10-17 14:14:38
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory slayer.i.sourceforge.net:/tmp/cvs-serv4824/src/com/meterware/httpunit Modified Files: WebForm.java Log Message: Handle empty default values Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WebForm.java 2000/10/03 13:41:05 1.10 +++ WebForm.java 2000/10/17 14:14:35 1.11 @@ -228,7 +228,12 @@ private String getValue( Node node ) { - return (node == null) ? "" : node.getNodeValue(); + return (node == null) ? "" : emptyIfNull( node.getNodeValue() ); + } + + + private String emptyIfNull( String value ) { + return (value == null) ? "" : value; } |
From: Russell G. <rus...@us...> - 2000-10-17 14:14:38
|
Update of /cvsroot/httpunit/httpunit/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv4824/doc Modified Files: release_notes.txt Log Message: Handle empty default values Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- release_notes.txt 2000/10/12 16:16:35 1.4 +++ release_notes.txt 2000/10/17 14:14:35 1.5 @@ -11,9 +11,11 @@ Thanks to Dave Glowacki for suggestions on convenience methods in WebResponse and WebLink, and for correcting the set up of the https protocol handling. Thanks to Perry Doell for the methods to examine cookies on WebConversation -Thanks to Ken Hygh for the proper handling of parameters with no specified type +Thanks to Ken Hygh for the proper handling of parameters with no specified type +Thanks to Gabriel Hauser for finding a bug in the handling of parameter defaults Revision History: +17-Oct-00 1.1 Additions: 1. It is now possible to set a delay in the handling of redirect requests, if necessary 2. The WebResponse now can return the response code associated with it (2xx) @@ -21,6 +23,7 @@ Problems corrected: 1. Unnamed frames are now handled + 2. Empty parameter values are now handled 6-Oct-00 Problems corrected: |