httpunit-commit Mailing List for httpunit (Page 68)
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...> - 2001-12-03 20:32:31
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv4232/jars Added Files: Tidy.jar Log Message: Added Tidy r5 |
From: Russell G. <rus...@us...> - 2001-12-03 20:24:30
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv2090/jars Added Files: junit.jar servlet.jar xerces.jar Log Message: Added jars to cvs |
From: Russell G. <rus...@us...> - 2001-12-03 20:12:38
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv30612 Removed Files: Tidy.jar junit.jar servlet.jar xerces.jar Log Message: clean up misadded jars |
From: Russell G. <rus...@us...> - 2001-12-03 20:00:19
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv26278/jars Added Files: jars.txt junit.jar servlet.jar xerces.jar Log Message: Added dependancy jars and version text --- NEW FILE --- Jars used: junit 3.7 servlet 2.3 xerces 1.2.3 jtidy 04aug2000r5 --- NEW FILE --- PK --- NEW FILE --- PK --- NEW FILE --- PK Created-By: 1.3.0 (Sun Microsystems Inc.) PK PK SourceFile ç *· getCharset setCharset SourceFile |
From: Russell G. <rus...@us...> - 2001-12-03 19:39:08
|
Update of /cvsroot/httpunit/httpunit/jars In directory usw-pr-cvs1:/tmp/cvs-serv19374/jars Log Message: Directory /cvsroot/httpunit/httpunit/jars added to the repository |
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv12381/test/com/meterware/servletunit Modified Files: ServletUnitSuite.java Added Files: ErrorTests.java FailingTests.java JUnitServletTest.java PassingTests.java ServletAccessTest.java Log Message: Added JUnitServlet and associated classes ***** Error reading new file[Errno 2] No such file or directory: 'ErrorTests.java' ***** Error reading new file[Errno 2] No such file or directory: 'FailingTests.java' ***** Error reading new file[Errno 2] No such file or directory: 'JUnitServletTest.java' ***** Error reading new file[Errno 2] No such file or directory: 'PassingTests.java' ***** Error reading new file[Errno 2] No such file or directory: 'ServletAccessTest.java' Index: ServletUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/ServletUnitSuite.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ServletUnitSuite.java 2001/11/08 22:07:53 1.3 +++ ServletUnitSuite.java 2001/12/03 19:14:59 1.4 @@ -44,6 +44,7 @@ suite.addTest( NavigationTest.suite() ); suite.addTest( ConfigTest.suite() ); suite.addTest( WebXMLTest.suite() ); + suite.addTest( JUnitServletTest.suite() ); return suite; } |
From: Russell G. <rus...@us...> - 2001-12-03 19:15:02
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv12381/src/com/meterware/servletunit Added Files: JUnitServlet.java ServletTestCase.java Log Message: Added JUnitServlet and associated classes ***** Error reading new file[Errno 2] No such file or directory: 'JUnitServlet.java' ***** Error reading new file[Errno 2] No such file or directory: 'ServletTestCase.java' |
From: Russell G. <rus...@us...> - 2001-12-03 15:42:42
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv10171/src/com/meterware/servletunit Added Files: package.html Log Message: Extract WebXMLString for use in other tests --- NEW FILE --- <HTML><BODY> Classes for unit testing servlets, providing internal access to running servlets using a simulated servlet container. Each test session should begin by creating a {@link com.meterware.servletunit.ServletRunner ServletRunner} which will act as a servlet application context. The definition of application context may be supplied in one of two ways. The {@link com.meterware.servletunit.ServletRunner#registerServlet(String,String) registerServlet} method allows the association of a servlet with a url path. Alternately, an entire servlet application may be defined by passing the name of the desired web.xml file. The {@link com.meterware.servletunit.ServletRunner#newClient newClient} method will return a {@link com.meterware.servletunit.ServletUnitClient ServletUnitClient} object which can be used to invoke the defined servlets, just as any subclass of {@link com.meterware.httpunit.WebClient WebClient}. In addition, this client object defines methods which allow access to the fully initializated servlet itself, as well as the request, response, and servlet session. A <a href="../../../../tutorial/index.html" target="_top">tutorial</a> is available. Please direct any questions to <A HREF="mailto:rus...@ac...">Russell Gold</A>. </BODY></HTML> |
From: Russell G. <rus...@us...> - 2001-12-03 15:42:42
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv10171/test/com/meterware/servletunit Modified Files: WebXMLTest.java Added Files: WebXMLString.java Log Message: Extract WebXMLString for use in other tests ***** Error reading new file[Errno 2] No such file or directory: 'WebXMLString.java' Index: WebXMLTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebXMLTest.java 2001/11/26 14:20:13 1.2 +++ WebXMLTest.java 2001/12/03 15:42:39 1.3 @@ -25,13 +25,8 @@ import java.io.PrintWriter; import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; -import java.util.Hashtable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Enumeration; -import java.util.Properties; -import java.util.Map; import java.net.URL; +import java.util.Properties; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -214,138 +209,6 @@ //=============================================================================================================== - - static class WebXMLString { - - String asText() { - StringBuffer result = new StringBuffer( "<?xml version='1.0' encoding='UTF-8'?>\n<web-app>\n" ); - for (int i = _servlets.size()-1; i >=0; i--) { - result.append( " <servlet>\n <servlet-name>servlet_" ).append( i ).append( "</servlet-name>\n" ); - result.append( " <servlet-class>" ).append( ((Class) _servlets.get(i)).getName() ).append( "</servlet-class>\n" ); - appendParams( result, "init-param", (Hashtable) _initParams.get( new Integer( i ) ) ); - result.append( " </servlet>\n" ); - } - for (int i = _mappings.size()-1; i >=0; i--) { - result.append( " <servlet-mapping>\n <servlet-name>servlet_" ).append( i ).append( "</servlet-name>\n" ); - result.append( " <url-pattern>" ).append( _mappings.get(i) ).append( "</url-pattern>\n </servlet-mapping>\n" ); - } - for (Enumeration e = _resources.elements(); e.hasMoreElements();) { - result.append( ((WebResourceSpec) e.nextElement()).asText() ); - } - result.append( _loginConfig ); - result.append( "</web-app>" ); - return result.toString(); - } - - - private void appendParams( StringBuffer result, String tagName, Hashtable params ) { - if (params == null) return; - for (Iterator it = params.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Map.Entry) it.next(); - result.append( " <" ).append( tagName ).append( ">\n <param-name>" ).append( entry.getKey() ); - result.append( "</param-name>\n <param-value>" ).append( entry.getValue() ).append( "</param-value>\n </" ); - result.append( tagName ).append( ">\n" ); - } - } - - - void addServlet( String urlPattern, Class servletClass ) { - _servlets.add( servletClass ); - _mappings.add( urlPattern ); - } - - void addServlet( String urlPattern, Class servletClass, Properties initParams ) { - _initParams.put( new Integer( _servlets.size() ), initParams ); - addServlet( urlPattern, servletClass ); - } - - void requireBasicAuthorization( String realmName ) { - _loginConfig = " <login-config>\n" + - " <auth-method>BASIC</auth-method>\n" + - " <realm-name>" + realmName + "</realm-name>\n" + - " </login-config>\n"; - } - - void requireBasicAuthentication( String realmName ) { - _loginConfig = " <login-config>\n" + - " <auth-method>BASIC</auth-method>\n" + - " <realm-name>" + realmName + "</realm-name>\n" + - " </login-config>\n"; - } - - void requireFormAuthentication( String realmName, String loginPagePath, String errorPagePath ) { - _loginConfig = " <login-config>\n" + - " <auth-method>FORM</auth-method>\n" + - " <realm-name>" + realmName + "</realm-name>\n" + - " <form-login-config>" + - " <form-login-page>" + loginPagePath + "</form-login-page>\n" + - " <form-error-page>" + errorPagePath + "</form-error-page>\n" + - " </form-login-config>" + - " </login-config>\n"; - } - - void addSecureURL( String resourceName, String urlPattern ) { - getWebResource( resourceName ).addURLPattern( urlPattern ); - } - - void addAuthorizedRole( String resourceName, String roleName ) { - getWebResource( resourceName ).addAuthorizedRole( roleName ); - } - - private ArrayList _servlets = new ArrayList(); - private ArrayList _mappings = new ArrayList(); - private String _loginConfig = ""; - private Hashtable _resources = new Hashtable(); - private Hashtable _initParams = new Hashtable(); - - - private WebResourceSpec getWebResource( String resourceName ) { - WebResourceSpec result = (WebResourceSpec) _resources.get( resourceName ); - if (result == null) { - result = new WebResourceSpec( resourceName ); - _resources.put( resourceName, result ); - } - return result; - } - } - - - static class WebResourceSpec { - - WebResourceSpec( String name ) { - _name = name; - } - - void addURLPattern( String urlPattern ) { - _urls.add( urlPattern ); - } - - void addAuthorizedRole( String roleName ) { - _roles.add( roleName ); - } - - String asText() { - StringBuffer sb = new StringBuffer(); - sb.append( " <security-constraint>\n" ); - sb.append( " <web-resource-collection>\n" ); - sb.append( " <web-resource-name>" ).append( _name ).append( "</web-resource-name>\n" ); - for (Iterator i = _urls.iterator(); i.hasNext();) { - sb.append( " <url-pattern>" ).append( i.next() ).append( "</url-pattern>\n" ); - } - sb.append( " </web-resource-collection>\n" ); - sb.append( " <auth-constraint>\n" ); - for (Iterator i = _roles.iterator(); i.hasNext();) { - sb.append( " <role-name>" ).append( i.next() ).append( "</role-name>\n" ); - } - sb.append( " </auth-constraint>\n" ); - sb.append( " </security-constraint>\n" ); - return sb.toString(); - } - - private String _name; - private ArrayList _urls = new ArrayList(); - private ArrayList _roles = new ArrayList(); - } //=============================================================================================================== |
From: Russell G. <rus...@us...> - 2001-12-03 15:40:40
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv9456/src/com/meterware/httpunit Modified Files: HttpUnitOptions.java Log Message: Javadoc and visibility corrections Index: HttpUnitOptions.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- HttpUnitOptions.java 2001/11/14 17:11:28 1.13 +++ HttpUnitOptions.java 2001/12/03 15:40:33 1.14 @@ -186,7 +186,7 @@ /** - * If true, text matches in methods such as {@link HTMLFragment#getLinkWith} are + * If true, text matches in methods such as {@link HTMLSegment#getLinkWith} are * case insensitive. The default is true (matches ignore case). **/ public static boolean getMatchesIgnoreCase() { @@ -195,7 +195,7 @@ /** - * If true, text matches in methods such as {@link HTMLFragment#getLinkWith} are + * If true, text matches in methods such as {@link HTMLSegment#getLinkWith} are * case insensitive. The default is true (matches ignore case). **/ public static void setMatchesIgnoreCase( boolean ignoreCase ) { |
From: Russell G. <rus...@us...> - 2001-12-03 15:40:39
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv9456/doc Modified Files: todo.txt Log Message: Javadoc and visibility corrections Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- todo.txt 2001/11/27 17:31:54 1.22 +++ todo.txt 2001/12/03 15:40:33 1.23 @@ -3,6 +3,7 @@ Medium priority: o Support optional tags which hide their contents (as in IFRAME, OBJECT, etc.) +o Check conformance with RFC 2109 - not currently sending $Version=1 string o Support IFRAME tag o Support reset button detection o Support _new frame tag |
From: Russell G. <rus...@us...> - 2001-12-03 15:40:39
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv9456/src/com/meterware/servletunit Modified Files: InvocationContextImpl.java Log Message: Javadoc and visibility corrections Index: InvocationContextImpl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContextImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InvocationContextImpl.java 2001/11/30 15:27:36 1.1 +++ InvocationContextImpl.java 2001/12/03 15:40:33 1.2 @@ -41,7 +41,7 @@ * This class represents the context in which a specific servlet request is being made. * It contains the objects needed to unit test the methods of a servlet. **/ -public class InvocationContextImpl implements InvocationContext { +class InvocationContextImpl implements InvocationContext { /** |
From: Russell G. <rus...@us...> - 2001-12-03 15:39:36
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv9017/doc Modified Files: release_notes.txt Log Message: corrected handling of disabled submit buttons and parameter name lookup Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.73 retrieving revision 1.74 diff -u -r1.73 -r1.74 --- release_notes.txt 2001/11/28 18:25:33 1.73 +++ release_notes.txt 2001/12/03 15:39:31 1.74 @@ -13,8 +13,19 @@ Revision History: -28-Nov-2001 1.3.0 + 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. + + +28-Nov-2001 1.3.0 Acknowledgements: Thanks to Oliver Imbusch for finding and fixing problems with parsing of encoded link parameter names and values and of link URLs with parameters and fragments. |
From: Russell G. <rus...@us...> - 2001-12-03 15:39:36
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv9017/src/com/meterware/httpunit Modified Files: SubmitButton.java WebForm.java Log Message: corrected handling of disabled submit buttons and parameter name lookup Index: SubmitButton.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SubmitButton.java 2001/11/09 18:35:14 1.4 +++ SubmitButton.java 2001/12/03 15:39:31 1.5 @@ -62,6 +62,14 @@ } + /** + * Returns true if this submit button is disabled. Requests cannot be made for disabled buttons. + **/ + public boolean isDisabled() { + return _isDisabled; + } + + //------------------------------------ Object methods ---------------------------------------- @@ -88,6 +96,7 @@ _name = NodeUtils.getNodeAttribute( node, "name" ); _value = NodeUtils.getNodeAttribute( _node, "value" ); _isImageButton = NodeUtils.getNodeAttribute( _node, "type" ).equalsIgnoreCase( "image" ); + _isDisabled = _node.getAttributes().getNamedItem( "disabled" ) != null; } @@ -97,6 +106,7 @@ private String _name; private String _value; private boolean _isImageButton; + private boolean _isDisabled; private SubmitButton() { Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- WebForm.java 2001/11/26 14:20:12 1.32 +++ WebForm.java 2001/12/03 15:39:31 1.33 @@ -67,25 +67,45 @@ **/ public boolean hasParameterNamed( String soughtName ) { NamedNodeMap[] parameters = getParameters(); - for (int i = 0; i < parameters.length; i++) { String name = getValue( parameters[ i ].getNamedItem( "name" ) ); if (name.equals( soughtName )) return true; } + + HTMLSelectElement[] selections = getSelections(); + for (int i = 0; i < selections.length; i++) { + if (soughtName.equals( selections[ i ].getName() )) return true; + } + + HTMLTextAreaElement[] textAreas = getTextAreas(); + for (int i = 0; i < textAreas.length; i++) { + if (soughtName.equals( textAreas[ i ].getName() )) return true; + } + return false; } /** - * Returns true if a parameter starting with given name exists, + * Returns true if a parameter starting with a given name exists, **/ public boolean hasParameterStartingWithPrefix( String prefix ) { NamedNodeMap[] parameters = getParameters(); - for (int i = 0; i < parameters.length; i++) { - String name = getValue( parameters[i].getNamedItem( "name" ) ); + String name = getValue( parameters[ i ].getNamedItem( "name" ) ); if (name.startsWith( prefix )) return true; } + + HTMLSelectElement[] selections = getSelections(); + for (int i = 0; i < selections.length; i++) { + if (selections[ i ].getName().startsWith( prefix )) return true; + } + + HTMLTextAreaElement[] textAreas = getTextAreas(); + for (int i = 0; i < textAreas.length; i++) { + if (textAreas[ i ].getName().startsWith( prefix )) return true; + } + return false; } @@ -141,8 +161,7 @@ NodeList nl = ((Element) getNode()).getElementsByTagName( "input" ); for (int i = 0; i < nl.getLength(); i++) { - if ((hasMatchingAttribute( nl.item(i), "type", "submit" ) || hasMatchingAttribute( nl.item(i), "type", "image" )) - && nl.item(i).getAttributes().getNamedItem( "disabled" ) == null) { + if (hasMatchingAttribute( nl.item(i), "type", "submit" ) || hasMatchingAttribute( nl.item(i), "type", "image" )) { _buttonVector.addElement( new SubmitButton( nl.item(i) ) ); } } @@ -275,6 +294,8 @@ throw new IllegalUnnamedSubmitButtonException(); } else if (!getSubmitButtonVector().contains( button )) { throw new IllegalSubmitButtonException( button ); + } else if (button.isDisabled()) { + throw new DisabledSubmitButtonException( button ); } } @@ -868,7 +889,7 @@ public String getMessage() { - return "This form has no unnamed buttons"; + return "This form has more than one submit button, none unnamed. You must specify the button to be used."; } } @@ -904,5 +925,32 @@ private String _value; } + +//============================= exception class IllegalUnnamedSubmitButtonException ====================================== + + +/** + * This exception is thrown on an attempt to define a form request with a button not defined on that form. + **/ +class DisabledSubmitButtonException extends IllegalRequestParameterException { + + + DisabledSubmitButtonException( SubmitButton button ) { + _name = button.getName(); + _value = button.getValue(); + } + + + public String getMessage() { + return "The specified button (name='" + _name + "' value='" + _value + + "' is disabled and may not be used to submit this form."; + } + + + private String _name; + private String _value; + +} + |
From: Russell G. <rus...@us...> - 2001-12-03 15:39:36
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv9017/test/com/meterware/httpunit Modified Files: FormParametersTest.java FormSubmitTest.java Log Message: corrected handling of disabled submit buttons and parameter name lookup Index: FormParametersTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FormParametersTest.java 2001/11/08 22:07:53 1.7 +++ FormParametersTest.java 2001/12/03 15:39:31 1.8 @@ -215,8 +215,7 @@ "<Input type=radio name=species value=kangaroo checked>" + "<Input type=radio name=species value=lemur>" + "<textarea name='big' readonly rows=2 cols=40>stop me</textarea>" + - "<Input type=text name=age value=12 readonly value='12'>" + - "<Input type=submit name=change disabled></form>" ); + "<Input type=text name=age value=12 readonly value='12'></form>" ); WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" ); WebForm form = page.getForms()[0]; WebRequest request = page.getForms()[0].getRequest(); @@ -225,7 +224,6 @@ assertEquals( "selected animal", "kangaroo", form.getParameterValue( "species" ) ); assertEquals( "age", "12", form.getParameterValue( "age" ) ); - assertNull( "Found disabled button", form.getSubmitButton( "change" ) ); assertMatchingSet( "color choices", new String[] { "red", "blue" }, form.getOptionValues( "color" ) ); assertMatchingSet( "species choices", new String[] { "kangaroo", "lemur" }, form.getOptionValues( "species" ) ); Index: FormSubmitTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- FormSubmitTest.java 2001/07/31 16:08:59 1.10 +++ FormSubmitTest.java 2001/12/03 15:39:31 1.11 @@ -131,6 +131,26 @@ } + public void testDisabledSubmitButtonDetection() 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 disabled>" + + "</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 ); + SubmitButton sb = form.getSubmitButton( "recalculate" ); + assertNotNull( "Failed to find disabled button" ); + assertTrue( "Disabled button not marked as disabled", sb.isDisabled() ); + try { + form.getRequest( sb ); + fail( "Allowed to create a request for a disabled button" ); + } catch (IllegalRequestParameterException e) {} + } + + public void testButtonIDDetection() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Input type=text name=age value=12>" + |
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv9104/src/com/meterware/servletunit Modified Files: InvocationContext.java ServletRunner.java ServletUnitClient.java Added Files: InvocationContextFactory.java InvocationContextImpl.java Log Message: Refactored to break dependancy between ServletUnitClient and ServletRunner ***** Error reading new file[Errno 2] No such file or directory: 'InvocationContextFactory.java' ***** Error reading new file[Errno 2] No such file or directory: 'InvocationContextImpl.java' Index: InvocationContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/InvocationContext.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InvocationContext.java 2001/11/26 14:20:12 1.3 +++ InvocationContext.java 2001/11/30 15:27:35 1.4 @@ -1,161 +1,69 @@ package com.meterware.servletunit; + /******************************************************************************************************************** -* $Id$ -* -* Copyright (c) 2001, Russell Gold -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -* to permit persons to whom the Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or substantial portions -* of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -* -*******************************************************************************************************************/ -import com.meterware.httpunit.WebRequest; + * $Id$ + * + * Copyright (c) 2001, Russell Gold + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *******************************************************************************************************************/ import com.meterware.httpunit.WebResponse; -import com.meterware.httpunit.Base64; -import com.meterware.httpunit.HttpException; - -import java.net.MalformedURLException; -import java.net.URL; -import java.io.IOException; -import java.util.Dictionary; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.servlet.Servlet; import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; /** - * This class represents the context in which a specific servlet request is being made. - * It contains the objects needed to unit test the methods of a servlet. + * + * @author <a href="mailto:rus...@ac...">Russell Gold</a> **/ -public class InvocationContext { +public interface InvocationContext { /** * Returns the request to be processed by the servlet. **/ - public HttpServletRequest getRequest() { - return _request; - } + HttpServletRequest getRequest(); /** * Returns the response which the servlet should modify during its operation. **/ - public HttpServletResponse getResponse() { - return _response; - } + HttpServletResponse getResponse(); /** * Returns the selected servlet, initialized to provide access to sessions * and servlet context information. **/ - public Servlet getServlet() throws ServletException { - if (_servlet == null) { - if (!_application.requiresAuthorization( _requestURL ) || userIsAuthorized() ) { - _servlet = _application.getServlet( _requestURL ); - } else if (_request.getRemoteUser() != null) { - throw new AccessDeniedException( _requestURL ); - } else if (_application.usesBasicAuthentication()) { - throw new BasicAuthenticationRequiredException( _application.getAuthenticationRealm() ); - } else if (_application.usesFormAuthentication()) { - _servlet = _application.getServlet( _application.getLoginURL() ); - ((ServletUnitHttpRequest) getRequest()).setOriginalURL( _requestURL ); - } else { - throw new IllegalStateException( "Authorization required but no authentication method defined" ); - } - } - return _servlet; - } - - - private boolean userIsAuthorized() { - final String[] roles = _request.getRoles(); - for (int i = 0; i < roles.length; i++) { - if (_application.roleMayAccess( roles[i], _requestURL )) return true; - } - return false; - } - - - class AccessDeniedException extends HttpException { - public AccessDeniedException( URL baseURL ) { - super( 403, "Access Denied", baseURL ); - } - } + Servlet getServlet() throws ServletException; /** * Returns the final response from the servlet. Note that this method should * only be invoked after all processing has been done to the servlet response. **/ - public WebResponse getServletResponse() { - if (_webResponse == null) { - HttpSession session = _request.getSession( /* create */ false ); - if (session != null && session.isNew()) { - _response.addCookie( new Cookie( ServletUnitHttpSession.SESSION_COOKIE_NAME, session.getId() ) ); - } - _webResponse = new ServletUnitWebResponse( _target, _requestURL, _response ); - } - return _webResponse; - } + WebResponse getServletResponse(); -//------------------------------ package methods --------------------------------------- - - /** - * Constructs a servlet invocation context for a specified servlet container, - * request, and cookie headers. - **/ - InvocationContext( ServletRunner runner, WebRequest request, Cookie[] cookies, Dictionary clientHeaders ) throws IOException, MalformedURLException { - _application = runner._application; - _requestURL = request.getURL(); - _target = request.getTarget(); - - _request = new ServletUnitHttpRequest( request, runner.getContext(), clientHeaders ); - for (int i = 0; i < cookies.length; i++) _request.addCookie( cookies[i] ); - - if (_application.usesBasicAuthentication()) _request.readBasicAuthentication(); - else if (_application.usesFormAuthentication()) _request.readFormAuthentication(); + * Returns the target for the original request. + */ + String getTarget(); - HttpSession session = _request.getSession( /* create */ false ); - if (session != null) ((ServletUnitHttpSession) session).access(); - } - - - String getTarget() { - return _target; - } - - -//------------------------------ private members --------------------------------------- - - - private WebApplication _application; - private ServletUnitHttpRequest _request; - private ServletUnitHttpResponse _response = new ServletUnitHttpResponse(); - private URL _requestURL; - private String _target; - - private Servlet _servlet; - private WebResponse _webResponse; } - - - - Index: ServletRunner.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletRunner.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ServletRunner.java 2001/11/26 14:20:12 1.8 +++ ServletRunner.java 2001/11/30 15:27:36 1.9 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -28,9 +28,11 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.Dictionary; import javax.servlet.Servlet; import javax.servlet.ServletException; +import javax.servlet.http.Cookie; import org.apache.xerces.parsers.DOMParser; @@ -84,7 +86,7 @@ * @exception SAXException thrown if there is an error parsing the response **/ public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException { - return _client.getResponse( request ); + return getClient().getResponse( request ); } @@ -93,7 +95,7 @@ * @exception SAXException thrown if there is an error parsing the response **/ public WebResponse getResponse( String url ) throws MalformedURLException, IOException, SAXException { - return _client.getResponse( url ); + return getClient().getResponse( url ); } @@ -101,11 +103,11 @@ * Creates and returns a new web client that communicates with this servlet runner. **/ public ServletUnitClient newClient() { - return new ServletUnitClient( this ); + return ServletUnitClient.newClient( _factory ); } -//-------------------------------- package methods ------------------------------------- +//-------------------------------------------- package methods --------------------------------------------------------- Servlet getServlet( URL url ) throws ServletException { @@ -122,7 +124,20 @@ WebApplication _application; - private ServletUnitClient _client = new ServletUnitClient( this ); + private ServletUnitClient _client; + private ServletUnitContext _context = new ServletUnitContext(); + + private InvocationContextFactory _factory = new InvocationContextFactory() { + public InvocationContext newInvocation( WebRequest request, Cookie[] clientCookies, Dictionary clientHeaders ) throws IOException, MalformedURLException { + return new InvocationContextImpl( ServletRunner.this, request, clientCookies, clientHeaders ); + } + }; + + + private ServletUnitClient getClient() { + if (_client == null) _client = newClient(); + return _client; + } } Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ServletUnitClient.java 2001/11/26 14:20:12 1.3 +++ ServletUnitClient.java 2001/11/30 15:27:36 1.4 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -48,8 +48,16 @@ **/ public class ServletUnitClient extends WebClient { - + /** + * Creates and returns a new servlet unit client instance. + **/ + public static ServletUnitClient newClient( InvocationContextFactory factory ) { + return new ServletUnitClient( factory ); + } + + + /** * Creates and returns a new invocation context from a GET request. **/ public InvocationContext newInvocation( String requestString ) throws IOException, MalformedURLException { @@ -61,7 +69,7 @@ * Creates and returns a new invocation context to test calling of servlet methods. **/ public InvocationContext newInvocation( WebRequest request ) throws IOException, MalformedURLException { - return new InvocationContext( _runner, request, getCookies(), this.getHeaderFields() ); + return _invocationContextFactory.newInvocation( request, getCookies(), this.getHeaderFields() ); } @@ -74,16 +82,8 @@ updateClient( invocation.getServletResponse() ); return getFrameContents( invocation.getTarget() ); } - - -//--------------------------------- package methods --------------------------------------- - ServletUnitClient( ServletRunner runner ) { - _runner = runner; - } - - //-------------------------------- WebClient methods -------------------------------------- @@ -106,9 +106,17 @@ //-------------------------- private members ----------------------------------- - private ServletRunner _runner; + private InvocationContextFactory _invocationContextFactory; final private static Cookie[] NO_COOKIES = new Cookie[0]; + + +//--------------------------------- package methods --------------------------------------- + + + private ServletUnitClient( InvocationContextFactory factory ) { + _invocationContextFactory = factory; + } private Cookie[] getCookies() { |
From: Russell G. <rus...@us...> - 2001-11-28 18:34:28
|
Update of /cvsroot/httpunit/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv30315 Modified Files: build.xml Log Message: prepare for 1.3 release Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- build.xml 2001/11/27 17:31:54 1.35 +++ build.xml 2001/11/28 18:34:26 1.36 @@ -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.2.7" /> + <property name="version" value="1.3" /> <property name="src.dir" value="src" /> <property name="tstsrc.dir" value="test" /> |
From: Russell G. <rus...@us...> - 2001-11-28 18:30:00
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory usw-pr-cvs1:/tmp/cvs-serv29158/doc/tutorial Removed Files: task1.zip Log Message: Add link to tutorial |
From: Russell G. <rus...@us...> - 2001-11-28 18:29:59
|
Update of /cvsroot/httpunit/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv29158 Modified Files: index.html Log Message: Add link to tutorial Index: index.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/index.html,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- index.html 2001/07/06 17:11:03 1.17 +++ index.html 2001/11/28 18:29:55 1.18 @@ -29,7 +29,8 @@ It was designed and implemented by <a href="mailto:rus...@us...">Russell Gold.</a></blockquote> <h2>Documentation</h2> -<blockquote>A rudimentary <A HREF="doc/Cookbook.html">User's manual</A> is available, as is a <A HREF="doc/faq.html">FAQ</A> and +<blockquote>A rudimentary <A HREF="doc/Cookbook.html">User's manual</A> is +available, as are a <a href="doc/tutorial/index.html">tutorial</a>, a <A HREF="doc/faq.html">FAQ</A> and the <A HREF="doc/api/index.html">javadoc</A>. Several working example files come with the distribution download.</blockquote> |
From: Russell G. <rus...@us...> - 2001-11-28 18:25:36
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv28022/doc Modified Files: release_notes.txt servletunit-intro.html Log Message: prepare for 1.3 release Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- release_notes.txt 2001/11/27 19:51:27 1.72 +++ release_notes.txt 2001/11/28 18:25:33 1.73 @@ -9,90 +9,61 @@ Limitations: 1. HttpUnit does not support JavaScript - 2. JDK 1.2 or higher is required + 2. JDK 1.2 or higher is now required Revision History: -27-Nov-2001 -Acknowledgements: - Thanks to Peter Roßbach for catching some typos in the tutorial. - Thanks to Benoit Xhenseval for optimizing the use of DOMs and StringBuffers. - -Additions: - 1. The tutorial now includes an explanation of security testing in ServletUnit - 2. Archives are now rooted with the build name - 3. HttpUnit is now more efficient in its use of memory, pre-allocating buffers to the most likely needed size and - avoiding unnecessary copying of DOMs. +28-Nov-2001 1.3.0 -26-Nov-2001 Acknowledgements: - Thanks to Oliver Imbusch for finding and supplying a fix for bad parsing of link URLs with parameters and fragments. - -Additions: - 1. ServletUnit now handles protected URLs defined in web.xml, along with both Basic and Form authentication. Logins - with non-blank usernames are also accepted, with the password being interpreted as a comma-separated list of - role names. - 2. ServletUnit now handles servlet initialization parameters defined in web.xml - -Problems fixed: - 1. ServletUnit now handles URL-encoded parameter names properly. - -14-Nov-2001 -Acknowledgements: + Thanks to Oliver Imbusch for finding and fixing problems with parsing of encoded link parameter names and values and + of link URLs with parameters and fragments. + Thanks to Paul Frantz and Dave Glowacki for finding and fixing problems with parsing of link parameter names without values. + Thanks to Didier Besset for new WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix + Thanks to Peter Roßbach for catching some typos in the tutorial. Thanks to Benoit Xhenseval for adding a mechanism to handle HTML parser errors. - -Additions: - 1. ServletUnit now compiles against Servlet 2.3 - 2. HttpUnitOptions now has methods addHtmlErrorListener and removeHtmlErrorListener. If a listener is registered, - it will be invoked for every error or warning generated by the parser, indicating the URL, line and column number - of the error and a textual description of the problem. - -Problems fixed: - 1. HttpUnit should now be more tolerant of missing character encodings - -12-Nov-2001 -Problems fixed: - 1. WebSphere cookie values ending with "=" or "==" are now handled. - - 9-Nov-2001 - -Acknowledgements: - Thanks to Dave Glowacki for finding and fixing another problem with parsing of link parameter names without values. - -Problems Fixed: - 1. Links with parameters with no "=" were being treated as though they had "=" - - 8-Nov-2001 -Acknowledgements: + Thanks to Benoit Xhenseval for optimizing the use of DOMs and StringBuffers. Thanks to Bradley Smith for implementing getParameterNames in ServletUnit. Problems fixed: - 1. ServletUnit was not decoding its request parameters - 2. ServletUnit's HttpRequest.getParameterNames method was not implemented - -Additions: - 1. ServletUnit now handles web.xml partially, supporting mapping of single paths to a servlet class - 2. Disabled submit buttons may no longer be selected from a form - 3. When enabled, parameter validation now prevents changes to readonly controls. - 4. It is now possible to obtain the reason message associated with the status code, either from - HttpException.getResponseMessageweb() or if exceptions are disabled, from WebResponse.getResponseMessage() - - 5-Nov-2001 - -Acknowledgements: - Thanks to Oliver Imbusch for finding and fixing a problem with parsing of encoded link parameter names and values. - Thanks to Paul Frantz for finding and fixing a problem with parsing of link parameter names without values. - Thanks to Didier Besset for new WebForm methods: hasParameterNamed and hasParameterStartingWithPrefix - -Problems Fixed: 1. Links with parameters whose names were encoded were being mis-parsed 2. Links with empty parameter values were being mis-parsed 3. Most references to TestCase.assert have been renamed to assertTrue in order to prepare for JDK 1.4 and JUnit 3.7 compatibility. HttpUnitTest and ServletUnitTest implement assertTrue to continue support for JUnit 3.6 and earlier. - 4. Some incompatibilities with JDK 1.1 had been inadvertantly introduced. + 4. ServletUnit was not decoding its request parameters and names + 5. ServletUnit's HttpRequest.getParameterNames method was not implemented + 7. WebSphere cookie values ending with "=" or "==" are now handled. + 8. HttpUnit should now be more tolerant of missing character encodings Additions: - 1. It is now possible to check a WebForm for the presence of a named parameter. + Content and parsing enhancements + 1. It is now possible to check a WebForm for the presence of a named parameter. + 2. Disabled submit buttons may no longer be selected from a form + 3. When enabled, parameter validation now prevents changes to readonly controls. + 4. It is now possible to obtain the reason message associated with the status code, either from + HttpException.getResponseMessageweb() or if exceptions are disabled, from WebResponse.getResponseMessage() + 5. HttpUnitOptions now has methods addHtmlErrorListener and removeHtmlErrorListener. If a listener is registered, + it will be invoked for every error or warning generated by the parser, indicating the URL, line and column number + of the error and a textual description of the problem. + + ServletUnit enhancements + 6. ServletUnit now compiles against Servlet 2.3 + 7. ServletUnit now handles web.xml partially, supporting: + a. mapping of exact paths to a servlet class + b. protected URLs (exact paths only) + c. Basic and Form authentication + d. Servlet initialization parameters + + Documentation and Packaging + 8. There is now the beginnings of a tutorial, focused on ServletUnit but covering much of the HttpUnit API + in doc/tutorial + 9. Archives are now rooted with the build name, following unix conventions + + Optimizations + 10. HttpUnit now pre-allocates StringBuffer instances to their most likely size + 11. DOMs are no longer copied when passed internally' + 12. ByteTag objects no longer allocate Hashtable unless required + 25-Oct-2001 1.2.7 Index: servletunit-intro.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/servletunit-intro.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- servletunit-intro.html 2001/06/18 20:21:30 1.1 +++ servletunit-intro.html 2001/11/28 18:25:33 1.2 @@ -7,25 +7,26 @@ <BODY> <H1>ServletUnit</H1> -<P>As a testing tool, HttpUnit is primarily designed for "black-box" testing of web sites. +<P>As a testing tool, HttpUnit is primarily designed for "black-box" testing of web sites. In many cases that may be all you need; however, if you are developing complex servlets, you may wish to test smaller pieces of your code. Sometimes you can isolate them into simple tests using only JUnit. In other cases, you will want to test in a servlet environment. At this point you have two basic approaches available. You can test in a real servlet container, using -a tool such as <A HREF="http://jakarta.apache.org/commons/cactus">Apache Cactus</A>, which has you -deploy your tests into the container along with your servlets. Or you can use a simulated servlet +a tool such as <A HREF="http://jakarta.apache.org/cactus/">Apache Cactus</A>, which has you +deploy your tests into the container along with your servlets. Or you can use a simulated servlet container. ServletUnit takes the latter approach.</P> -<P>To test a servlet in ServletUnit, you first instantiate a <CODE>ServletRunner</CODE> -(the simulated container), and register your servlet: +<P>To test a servlet in ServletUnit, you first instantiate a <CODE>ServletRunner</CODE> +(the simulated container), and register your servlets: <PRE><CODE> ServletRunner sr = new ServletRunner(); sr.registerServlet( "myServlet", StatefulServlet.class.getName() ); </CODE></PRE> -Note that for complex tests, you can register multiple servlets in a single <CODE>ServletRunner</CODE>. +Note that for complex tests, you can register multiple servlets in a single <CODE>ServletRunner</CODE> or initialize +the <code>ServletRunner</code> with the name of a web.xml file from which to read an entire application full of servlets. You are now ready to begin. You need a <CODE>ServletUnitClient</CODE>, which performs much the -same function as HttpUnit's <CODE>WebConversation</CODE> - in fact, they both extend the base +same function as HttpUnit's <CODE>WebConversation</CODE> - in fact, they both extend the base class <CODE>WebClient</CODE>, so you can use it the same way, except of course that <CODE>ServletUnitClient</CODE> ignores the host portion of URLs in requests passed to it and goes directly to its <CODE>ServletRunner</CODE>. @@ -44,7 +45,7 @@ Of course, this is still black-box testing. To really take advantage of the power of ServletUnit, you can handle your request in steps. To do this, instead of asking the client for the final response, you ask it for an invocation context: -<PRE><CODE> +<PRE><CODE> ServletUnitClient sc = sr.newClient(); WebRequest request = new PostMethodWebRequest( "http://test.meterware.com/myServlet" ); request.setParameter( "color", "red" ); @@ -55,7 +56,7 @@ with the appropriate session information, as well as the request and response objects which the servlet will process. Now you can call methods on the servlet, on the servlet session, or on the request and response objects. For example, given the following servlet definition: -<PRE><CODE> +<PRE><CODE> public class StatefulServlet extends HttpServlet { protected void doPost( HttpServletRequest req, HttpServletResponse resp ) throws ServletException,IOException { @@ -63,7 +64,7 @@ writeSelectMessage( req.getParameter( "color" ), resp.getWriter() ); setColor( req, req.getParameter( "color" ) ); } - + void writeSelectMessage( String color, PrintWriter pw ) throws IOException { pw.print( "You selected " + color ); pw.close(); @@ -75,10 +76,10 @@ } </CODE></PRE> you might want to test the individual methods one at a time. The following code obtains the servlet and -casts it to get access to its package-level methods (the tests should be in the same package as -the servlet to do this). It then invokes the setColor method to ensure that it is creating and -updating the session correctly. -<PRE><CODE> +casts it to get access to its package-level methods (the tests should be in the same package as +the servlet to do this). It then invokes the setColor method to ensure that it is creating and +updating the session correctly. +<PRE><CODE> StatefulServlet ss = (StatefulServlet) ic.getServlet(); assertNull( "A session already exists", ic.getRequest().getSession( false ) ); @@ -88,7 +89,7 @@ </CODE></PRE> You can test the response from the servlet as well, if you invoke the code which creates it: -<PRE><CODE> +<PRE><CODE> StatefulServlet ss = (StatefulServlet) ic.getServlet(); ss.writeSelectMessage( "blue", ic.getResponse().getWriter() ); @@ -96,7 +97,7 @@ assertEquals( "requested resource", "You selected blue", response.getText() ); assertEquals( "Returned cookie count", 1, response.getNewCookieNames().length ); </CODE></PRE> -Note that the response returned from <CODE>getServletResponse</CODE> is the actual one returned by the +Note that the response returned from <CODE>getServletResponse</CODE> is the actual one returned by the servlet, without any processing by the client. For example, if the request contains a bad status or a forward request, the client might do some additional processing, which is not done at this time. Of course, since the response extends <CODE>WebResponse</CODE>, all of the normal HTML parsing methods @@ -105,7 +106,7 @@ Finally, if you are writing a test which depends on the maintenance of state across servlet invocations, you will want to reinvolve the <CODE>ServletUnitClient</CODE>, giving it a chance to process the response, including updating its own list of cookies: -<PRE><CODE> +<PRE><CODE> WebResponse response sc.getResponse( ic ); // pass the already processed InvocationContext response = sc.getResponse( "http://test.meterware.com/ReadColorFromSession" ); @@ -116,7 +117,13 @@ </CODE></PRE> This allows any subsequent request through the same client object to take advantage of the session state established by the just completed request, just as is possible with HttpUnit. + +If you are using a web.xml file to define your servlets, you can also test protected resources. ServletUnit supports +both Basic and Form authentication, and handles them just as HttpUnit does. For Basic authentication, you must call +setAuthorization passing a username and password, while Form authentication is handled just like any other form. Since +ServletUnit does not maintain a database of users, it will accept any user/password combination as valid, and treat the +password as a comma-separated list of role names. </BODY> -</HTML> - - +</HTML> + + |
From: Russell G. <rus...@us...> - 2001-11-28 18:25:36
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv28022/src/com/meterware/httpunit Modified Files: WebResponse.java Log Message: prepare for 1.3 release Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- WebResponse.java 2001/11/27 19:51:27 1.55 +++ WebResponse.java 2001/11/28 18:25:33 1.56 @@ -871,10 +871,10 @@ String token = nextToken(); while (token.length() != 0) { if (token.equals( "=" ) && attribute.length() != 0) { - _attributes.put( attribute.toLowerCase(), nextToken() ); + getAttributes().put( attribute.toLowerCase(), nextToken() ); attribute = ""; } else { - if (attribute.length() > 0) _attributes.put( attribute.toLowerCase(), "" ); + if (attribute.length() > 0) getAttributes().put( attribute.toLowerCase(), "" ); attribute = token; } token = nextToken(); @@ -887,15 +887,22 @@ } public String getAttribute( String attributeName ) { - return (String) _attributes.get( attributeName ); + return (String) getAttributes().get( attributeName ); } public String toString() { return "ByteTag[ name=" + _name + ";attributes = " + _attributes + ']'; } + + private Hashtable getAttributes() { + if (_attributes == null) _attributes = new Hashtable(); + return _attributes; + } + + private String _name = ""; - private Hashtable _attributes = new Hashtable(); + private Hashtable _attributes; private char[] _buffer; |
From: Russell G. <rus...@us...> - 2001-11-27 20:14:25
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory usw-pr-cvs1:/tmp/cvs-serv22384/doc/tutorial Modified Files: task1editor-validation.html Log Message: minor reformatting Index: task1editor-validation.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/tutorial/task1editor-validation.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- task1editor-validation.html 2001/11/27 16:40:47 1.3 +++ task1editor-validation.html 2001/11/27 20:14:20 1.4 @@ -185,8 +185,11 @@ makes the form display read-only once the pool is open:</p> <pre class="servlet-code"> for (int i = 0; i < games.length; i++) { - pw.println( "<tr><td><input name='home" + i + "' value='" + games[i].getHomeTeam() + "'" + getReadOnlyFlag() + "></td>" ); - pw.println( "<td><input name='away" + i + "' value='" + games[i].getAwayTeam() + "'" + getReadOnlyFlag() + "></td>" ); + pw.println( "<tr><td>" ); + pw.print( "<input name='home" + i + "' value='" + games[i].getHomeTeam() + "'" ); + pw.println( getReadOnlyFlag() + "></td>" ); + pw.print( "<td><input name='away" + i + "' value='" + games[i].getAwayTeam() + "'" ); + pw.println( getReadOnlyFlag() + "></td>" ); pw.print( "<td><input type='radio' name='tiebreaker' value='" + i + "'" + getReadOnlyFlag() ); if (i == BettingPool.getTieBreakerIndex()) pw.print( " checked" ); pw.println( " /></td></tr>" ); |
From: Russell G. <rus...@us...> - 2001-11-27 19:51:30
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv14340/src/com/meterware/httpunit Modified Files: HttpException.java HttpUnitUtils.java MimeEncodedMessageBody.java NodeUtils.java ParsedHTML.java ReceivedPage.java WebClient.java WebRequest.java WebResponse.java WebTable.java Log Message: Benoit Xhenseval: optimized DOM and StringBuffer use Index: HttpException.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpException.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HttpException.java 2001/11/26 14:20:12 1.5 +++ HttpException.java 2001/11/27 19:51:27 1.6 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -43,7 +43,7 @@ public String getMessage() { - StringBuffer sb = new StringBuffer( "Error on HTTP request: " ); + StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE).append( "Error on HTTP request: " ); sb.append( _responseCode ); if (_responseMessage != null) { sb.append( " " ); @@ -74,4 +74,4 @@ private String _responseMessage; -} +} \ No newline at end of file Index: HttpUnitUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- HttpUnitUtils.java 2001/11/14 17:28:25 1.4 +++ HttpUnitUtils.java 2001/11/27 19:51:27 1.5 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -26,6 +26,9 @@ **/ public class HttpUnitUtils { + public static final int DEFAULT_TEXT_BUFFER_SIZE = 2048; + public static final int DEFAULT_BUFFER_SIZE = 128; + /** * Returns the content type and encoding as a pair of strings. * If no character set is specified, the second entry will be null. @@ -55,8 +58,8 @@ * FIXME: currently assumes iso-8859-1 character set. **/ public static String decode( String byteString ) { - StringBuffer sb = new StringBuffer(); char[] chars = byteString.toCharArray(); + StringBuffer sb = new StringBuffer(chars.length); char[] hexNum = { '0', '0', '0' }; int i = 0; @@ -75,5 +78,4 @@ } return sb.toString(); } - -} +} \ No newline at end of file Index: MimeEncodedMessageBody.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/MimeEncodedMessageBody.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- MimeEncodedMessageBody.java 2001/11/09 18:35:14 1.9 +++ MimeEncodedMessageBody.java 2001/11/27 19:51:27 1.10 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -99,8 +99,8 @@ private String encode( String string ) { - StringBuffer sb = new StringBuffer(); char[] chars = string.toCharArray(); + StringBuffer sb = new StringBuffer(chars.length+20); for (int i = 0; i < chars.length; i++ ) { if (chars[i] == '\\') { sb.append( "\\\\" ); // accomodate MS-DOS file paths XXX is this safe?? @@ -124,4 +124,3 @@ } - Index: NodeUtils.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/NodeUtils.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- NodeUtils.java 2001/11/09 18:35:14 1.7 +++ NodeUtils.java 2001/11/27 19:51:27 1.8 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -75,7 +75,7 @@ * any HTML tags. **/ public static String asText( NodeList rootNodes ) { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); Stack pendingNodes = new Stack(); pushNodeList( rootNodes, pendingNodes ); @@ -98,9 +98,9 @@ } else if (node.getNodeName().equalsIgnoreCase( "td" )) { sb.append( " | " ); } else if (node.getNodeName().equalsIgnoreCase( "th" )) { - sb.append( " | " ); + sb.append( " | " ); } else if (node.getNodeName().equalsIgnoreCase( "img" ) && HttpUnitOptions.getImagesTreatedAsAltText()) { - sb.append( getNodeAttribute( node, "alt" ) ); + sb.append( getNodeAttribute( node, "alt" ) ); } pushNodeList( node.getChildNodes(), pendingNodes ); @@ -126,4 +126,4 @@ } } -} +} \ No newline at end of file Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ParsedHTML.java 2001/10/25 14:51:05 1.18 +++ ParsedHTML.java 2001/11/27 19:51:27 1.19 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -25,6 +25,10 @@ import org.w3c.dom.*; +/** + * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a> + **/ class ParsedHTML { @@ -170,7 +174,7 @@ * they appear. **/ public WebTable[] getTables() { - return WebTable.getTables( getDOM(), _baseURL, _baseTarget, _characterSet ); + return WebTable.getTables( getOriginalDOM(), _baseURL, _baseTarget, _characterSet ); } @@ -188,10 +192,10 @@ } } ); } - - + + /** - * Returns the first table in the response which has the specified text as a prefix of the text + * Returns the first table in the response which has the specified text as a prefix of the text * in its first non-blank row and non-blank column. Will recurse into any nested tables, as needed. * @return the selected table, or null if none is found **/ @@ -204,10 +208,10 @@ } } ); } - - + + /** - * Returns the first table in the response which has the specified text as its summary attribute. + * 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 **/ @@ -218,10 +222,10 @@ } } ); } - - + + /** - * Returns the first table in the response which has the specified text as its ID attribute. + * Returns the first table in the response which has the specified text as its ID attribute. * Will recurse into any nested tables, as needed. * @return the selected table, or null if none is found **/ @@ -232,8 +236,8 @@ } } ); } - - + + /** * Returns a copy of the domain object model associated with this page. **/ @@ -241,6 +245,14 @@ return _rootNode.cloneNode( /* deep */ true ); } + /** + * Returns the domain object model associated with this page, to be used internally. + * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a> + **/ + Node getOriginalDOM() { + return _rootNode; + } + //---------------------------------- Object methods -------------------------------- @@ -371,4 +383,4 @@ return null; } -} +} \ No newline at end of file Index: ReceivedPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ReceivedPage.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ReceivedPage.java 2001/11/14 17:11:28 1.17 +++ ReceivedPage.java 2001/11/27 19:51:27 1.18 @@ -53,7 +53,7 @@ * Returns the title of the page. **/ public String getTitle() throws SAXException { - NodeList nl = ((Document) getDOM()).getElementsByTagName( "title" ); + NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName( "title" ); if (nl.getLength() == 0) return ""; if (!nl.item(0).hasChildNodes()) return ""; return nl.item(0).getFirstChild().getNodeValue(); @@ -67,7 +67,7 @@ * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a> **/ public String getExternalStyleSheet() throws SAXException { - NodeList nl = ((Document) getDOM()).getElementsByTagName( "link" ); + NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName( "link" ); int length = nl.getLength(); if (length == 0) return ""; @@ -94,7 +94,7 @@ **/ public String[] getMetaTagContent(String attribute, String attributeValue) { Vector matches = new Vector(); - NodeList nl = ((Document) getDOM()).getElementsByTagName("meta"); + NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName("meta"); int length = nl.getLength(); for (int i = 0; i < length; i++) { @@ -133,7 +133,7 @@ private void setBaseAttributes() throws SAXException { - NodeList nl = ((Document) getDOM()).getElementsByTagName( "base" ); + NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName( "base" ); if (nl.getLength() == 0) return; try { applyBaseAttributes( NodeUtils.getNodeAttribute( nl.item(0), "href" ), @@ -165,4 +165,4 @@ return tidy; } -} +} \ No newline at end of file Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- WebClient.java 2001/11/26 14:20:12 1.12 +++ WebClient.java 2001/11/27 19:51:27 1.13 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2001, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +* documentation files (the "Software"), to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and * to permit persons to whom the Software is furnished to do so, subject to the following conditions: * -* The above copyright notice and this permission notice shall be included in all copies or substantial portions +* The above copyright notice and this permission notice shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO @@ -39,9 +39,9 @@ * * @author Russell Gold * @author Jan Ohrstrom - * @author Seth Ladd + * @author Seth Ladd **/ -abstract +abstract public class WebClient { @@ -121,15 +121,15 @@ return (String) _cookies.get( name ); } - + /** * Specifies the user agent identification. Used to trigger browser-specific server behavior. - **/ + **/ public void setUserAgent( String userAgent ) { setHeaderField( "User-Agent", userAgent ); } - - + + /** * Returns the current user agent setting. **/ @@ -178,20 +178,20 @@ **/ protected String getCookieHeaderField() { String names[] = getCookieNames(); - if (names.length == 0) return null; - - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < names.length; i++) { + if (names.length == 0) return null; + + StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_BUFFER_SIZE); + for (int i = 0; i < names.length; i++) { if (i != 0) sb.append( "; " ); - String name = names[i]; - sb.append( name ).append( '=' ).append( getCookieValue( name ) ); - } + String name = names[i]; + sb.append( name ).append( '=' ).append( getCookieValue( name ) ); + } return sb.toString(); } /** - * Returns the value of all current header fields. + * Returns the value of all current header fields. **/ protected Dictionary getHeaderFields() { Hashtable result = (Hashtable) _headers.clone(); @@ -375,8 +375,8 @@ } } - + //================================================================================================== @@ -394,4 +394,3 @@ private String _frameName; } - Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- WebRequest.java 2001/11/26 14:20:12 1.30 +++ WebRequest.java 2001/11/27 19:51:27 1.31 @@ -333,10 +333,9 @@ return _parameters.size() == 0; } - final protected String getParameterString() { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_BUFFER_SIZE); Enumeration e = _parameters.keys(); while (e.hasMoreElements()) { @@ -496,7 +495,7 @@ } else { try { byte[] rawBytes = source.getBytes( _sourceForm.getCharacterSet() ); - StringBuffer result = new StringBuffer(); + StringBuffer result = new StringBuffer(HttpUnitUtils.DEFAULT_BUFFER_SIZE); for (int i = 0; i < rawBytes.length; i++) { int candidate = rawBytes[i] & 0xff; if (candidate == ' ') { @@ -677,7 +676,7 @@ public String getMessage() { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); sb.append( "May not set parameter '" ).append( _parameterName ).append( "' to '" ); sb.append( _badValue ).append( "'. Value must be one of: { " ); for (int i = 0; i < _allowedValues.length; i++) { @@ -712,7 +711,7 @@ public String getMessage() { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); sb.append( "Parameter '" ).append( _parameterName ).append( "' must have the value '" ); sb.append( _missingValue ).append( "'. Attempted to set it to: { " ); for (int i = 0; i < _proposedValues.length; i++) { @@ -844,4 +843,3 @@ } - Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- WebResponse.java 2001/11/14 14:40:09 1.54 +++ WebResponse.java 2001/11/27 19:51:27 1.55 @@ -776,7 +776,7 @@ private void addFrameTags( Vector list, String frameTagName ) throws SAXException { - NodeList nl = NodeUtils.getElementsByTagName( getReceivedPage().getDOM(), frameTagName ); + 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 ) ); @@ -1039,4 +1039,3 @@ private String _contentType; } - Index: WebTable.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- WebTable.java 2001/10/25 17:30:03 1.14 +++ WebTable.java 2001/11/27 19:51:27 1.15 @@ -97,7 +97,7 @@ for (int i = 0; i < getRowCount(); i++) { for (int j = 0; j < getColumnCount(); j++) { if (_cells[i][j]!=null) { - idToCompare = NodeUtils.getNodeAttribute( _cells[i][j].getDOM(), "id" ); + idToCompare = NodeUtils.getNodeAttribute( _cells[i][j].getOriginalDOM(), "id" ); if (HttpUnitOptions.getMatchesIgnoreCase()) if (id.equalsIgnoreCase(idToCompare)) return _cells[i][j]; @@ -210,7 +210,7 @@ public String toString() { String eol = System.getProperty( "line.separator" ); if (_cells == null) readTable(); - StringBuffer sb = new StringBuffer( "WebTable:" ).append( eol ); + StringBuffer sb = new StringBuffer( HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE).append("WebTable:" ).append( eol ); for (int i = 0; i < _cells.length; i++) { sb.append( "[" ).append( i ).append( "]: " ); for (int j = 0; j < _cells[i].length; j++) { @@ -404,7 +404,6 @@ } - |
From: Russell G. <rus...@us...> - 2001-11-27 19:51:30
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv14340/doc Modified Files: release_notes.txt Log Message: Benoit Xhenseval: optimized DOM and StringBuffer use Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- release_notes.txt 2001/11/27 17:31:54 1.71 +++ release_notes.txt 2001/11/27 19:51:27 1.72 @@ -16,10 +16,13 @@ 27-Nov-2001 Acknowledgements: Thanks to Peter Roßbach for catching some typos in the tutorial. + Thanks to Benoit Xhenseval for optimizing the use of DOMs and StringBuffers. Additions: 1. The tutorial now includes an explanation of security testing in ServletUnit 2. Archives are now rooted with the build name + 3. HttpUnit is now more efficient in its use of memory, pre-allocating buffers to the most likely needed size and + avoiding unnecessary copying of DOMs. 26-Nov-2001 Acknowledgements: |
From: Russell G. <rus...@us...> - 2001-11-27 17:31:57
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv4685/doc Modified Files: release_notes.txt todo.txt Log Message: Use release name as root in zip archive Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- release_notes.txt 2001/11/27 16:40:47 1.70 +++ release_notes.txt 2001/11/27 17:31:54 1.71 @@ -15,10 +15,11 @@ Revision History: 27-Nov-2001 Acknowledgements: - Thanks to Peter Rossbach for catching some typos in the tutorial. + Thanks to Peter Roßbach for catching some typos in the tutorial. Additions: 1. The tutorial now includes an explanation of security testing in ServletUnit + 2. Archives are now rooted with the build name 26-Nov-2001 Acknowledgements: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- todo.txt 2001/10/25 17:31:41 1.21 +++ todo.txt 2001/11/27 17:31:54 1.22 @@ -1,5 +1,4 @@ High Priority -o Allow servlet initialization parameters in registerServlet o Prevent setParameter calls from working on requests built from links if validation is enabled Medium priority: |