httpunit-commit Mailing List for httpunit (Page 50)
Brought to you by:
russgold
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
From: Russell G. <rus...@us...> - 2002-10-08 14:36:04
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv11174/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: from Richard Harris: added support for the JavaScript screen object Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- ScriptingTest.java 8 Oct 2002 14:01:11 -0000 1.29 +++ ScriptingTest.java 8 Oct 2002 14:36:00 -0000 1.30 @@ -499,4 +499,21 @@ } + public void testScreenObject() throws Exception { + defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" + + "function viewProperties() { \n" + + " alert( 'dimensions=' + screen.availWidth + 'x' + screen.availHeight );\n" + + "}" + + "</script></head>\n" + + "<body onLoad='viewProperties()'>\n" + + "</body></html>" ); + HttpUnitOptions.setExceptionsThrownOnScriptError( true ); + WebConversation wc = new WebConversation(); + wc.getClientProperties().setAvailableScreenSize( 1024, 752 ); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + assertEquals( "Alert message 1", "dimensions=1024x752", wc.popNextAlert() ); + assertNull( "Alert should have been removed", wc.getNextAlert() ); + } + + } |
From: Russell G. <rus...@us...> - 2002-10-08 14:01:14
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv27586/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: from Richard Harris: title attribute and navigator.platform property Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- ScriptingTest.java 8 Oct 2002 13:14:31 -0000 1.28 +++ ScriptingTest.java 8 Oct 2002 14:01:11 -0000 1.29 @@ -476,6 +476,7 @@ " alert( 'appCodeName=' + navigator.appCodeName )\n;" + " alert( 'appVersion=' + navigator.appVersion )\n;" + " alert( 'userAgent=' + navigator.userAgent )\n;" + + " alert( 'platform=' + navigator.platform )\n;" + " alert( 'javaEnabled=' + navigator.javaEnabled() )\n;" + " alert( '# plugins=' + navigator.plugins.length )\n;" + "}" + @@ -485,13 +486,15 @@ HttpUnitOptions.setExceptionsThrownOnScriptError( true ); WebConversation wc = new WebConversation(); wc.getClientProperties().setApplicationID( "Internet Explorer", "Mozilla", "4.0" ); + wc.getClientProperties().setPlatform( "JVM" ); WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); assertEquals( "Alert message 1", "appName=Internet Explorer", wc.popNextAlert() ); assertEquals( "Alert message 2", "appCodeName=Mozilla", wc.popNextAlert() ); assertEquals( "Alert message 3", "appVersion=4.0", wc.popNextAlert() ); assertEquals( "Alert message 4", "userAgent=Mozilla/4.0", wc.popNextAlert() ); - assertEquals( "Alert message 5", "javaEnabled=false", wc.popNextAlert() ); - assertEquals( "Alert message 6", "# plugins=0", wc.popNextAlert() ); + assertEquals( "Alert message 5", "platform=JVM", wc.popNextAlert() ); + assertEquals( "Alert message 6", "javaEnabled=false", wc.popNextAlert() ); + assertEquals( "Alert message 7", "# plugins=0", wc.popNextAlert() ); assertNull( "Alert should have been removed", wc.getNextAlert() ); } |
From: Russell G. <rus...@us...> - 2002-10-08 14:01:13
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv27586/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: from Richard Harris: title attribute and navigator.platform property Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JavaScript.java 1 Oct 2002 16:11:48 -0000 1.24 +++ JavaScript.java 8 Oct 2002 14:01:10 -0000 1.25 @@ -472,6 +472,11 @@ } + public String jsGet_platform() { + return getDelegate().getClientProperties().getPlatform(); + } + + public Object[] jsGet_plugins() { return new Object[0]; } |
From: Russell G. <rus...@us...> - 2002-10-08 14:01:13
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv27586/doc Modified Files: Javascript-support.html release_notes.txt Log Message: from Richard Harris: title attribute and navigator.platform property Index: Javascript-support.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- Javascript-support.html 1 Oct 2002 16:11:47 -0000 1.17 +++ Javascript-support.html 8 Oct 2002 14:01:10 -0000 1.18 @@ -34,6 +34,7 @@ <li>appName - the name of the browser, as set in ClientProperties.setApplicationName()</li> <li>appVersion - the browser version, set in ClientProperties.setApplicationVersion()</li> <li>plugins - an empty array of objects, since plugins are not universally supported</li> +<li>platform - the platform for the browser, set in ClientProperties.setPlatform</li> <li>userAgent - the name of the user agent, set by ClientProperties.setUserAgent or derived from the code name and version</li> </ul> <h4>methods</h4> Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.177 retrieving revision 1.178 diff -u -r1.177 -r1.178 --- release_notes.txt 4 Oct 2002 15:19:25 -0000 1.177 +++ release_notes.txt 8 Oct 2002 14:01:10 -0000 1.178 @@ -10,6 +10,16 @@ Revision History: + 8-Oct-2002 +Acknowledgements: + Thanks to Richard Harris for adding support for the title attribute for links, + and for adding the JavaScript Navigator.platform property. + +Additions: + 1. Links, forms, and images now have a readable title property. + 2. The navigator object now supports the readable 'platform' property. + + 4-Oct-2002 Additions: 1. WebClient now supports a WebWindowListener which will be called when a new window is opened. |
From: Russell G. <rus...@us...> - 2002-10-08 14:01:13
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv27586/src/com/meterware/httpunit Modified Files: ClientProperties.java WebRequestSource.java Log Message: from Richard Harris: title attribute and navigator.platform property Index: ClientProperties.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ClientProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ClientProperties.java 1 Oct 2002 16:11:47 -0000 1.1 +++ ClientProperties.java 8 Oct 2002 14:01:10 -0000 1.2 @@ -90,6 +90,16 @@ } + public String getPlatform() { + return _platform; + } + + + public void setPlatform( String platform ) { + _platform = platform; + } + + static ClientProperties cloneProperties() { return new ClientProperties( getDefaultProperties() ); } @@ -99,6 +109,7 @@ private String _applicationName = "HttpUnit"; private String _applicationVersion = "1.4"; private String _userAgent; + private String _platform = "Java"; private static ClientProperties _defaultProperties = new ClientProperties(); @@ -112,5 +123,6 @@ _applicationName = source._applicationName; _applicationVersion = source._applicationVersion; _userAgent = source._userAgent; + _platform = source._platform; } } Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- WebRequestSource.java 4 Oct 2002 15:18:37 -0000 1.17 +++ WebRequestSource.java 8 Oct 2002 14:01:10 -0000 1.18 @@ -50,6 +50,14 @@ /** + * Returns the title associated with this request source. + **/ + public String getTitle() { + return getAttribute( "title" ); + } + + + /** * Returns the target for this request source. **/ public String getTarget() { |
From: Russell G. <rus...@us...> - 2002-10-08 13:14:34
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv8408/src/com/meterware/httpunit Modified Files: HttpUnitOptions.java Log Message: some minor cleanup Index: HttpUnitOptions.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- HttpUnitOptions.java 13 Sep 2002 18:34:57 -0000 1.27 +++ HttpUnitOptions.java 8 Oct 2002 13:14:30 -0000 1.28 @@ -57,6 +57,7 @@ _acceptCookies = true; setScriptEngineClassName( DEFAULT_SCRIPT_ENGINE_FACTORY ); setScriptingEnabled( true ); + _exceptionsThrownOnScriptError = true; } @@ -381,6 +382,7 @@ Class factoryClass = Class.forName( _scriptEngineClassName ); final ScriptingEngineFactory factory = (ScriptingEngineFactory) factoryClass.newInstance(); _scriptingEngine = factory.isEnabled() ? factory : NULL_SCRIPTING_ENGINE_FACTORY; + _scriptingEngine.setThrowExceptionsOnError( _exceptionsThrownOnScriptError ); } catch (ClassNotFoundException e) { disableScripting( e, "Unable to find scripting engine factory class " ); } catch (InstantiationException e) { @@ -411,6 +413,7 @@ * Determines whether script errors result in exceptions or warning messages. */ public static void setExceptionsThrownOnScriptError( boolean throwExceptions ) { + _exceptionsThrownOnScriptError = throwExceptions; getScriptingEngine().setThrowExceptionsOnError( throwExceptions ); } @@ -419,7 +422,7 @@ * Returns true if script errors cause exceptions to be thrown. */ public static boolean getExceptionsThrownOnScriptError() { - return getScriptingEngine().isThrowExceptionsOnError(); + return _exceptionsThrownOnScriptError; } @@ -500,6 +503,9 @@ private static ScriptingEngineFactory _scriptingEngine; private static boolean _scriptingEnabled = true; + + private static boolean _exceptionsThrownOnScriptError = true; + static { |
From: Russell G. <rus...@us...> - 2002-10-08 13:14:34
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv8408/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: some minor cleanup Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- ScriptingTest.java 1 Oct 2002 16:11:49 -0000 1.27 +++ ScriptingTest.java 8 Oct 2002 13:14:31 -0000 1.28 @@ -111,6 +111,20 @@ } + public void testJavaScriptURLWithIncludedFunction() throws Exception { + defineResource( "saycheese.js", "function sayCheese() { alert( \"Cheese!\" ); }" ); + defineResource( "OnCommand.html", "<html><head><script language='JavaScript' src='saycheese.js'>" + + "</script></head>" + + "<body>" + + "<a href=\"javascript:sayCheese()\">go</a>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + response.getLinkWith( "go" ).click(); + assertEquals( "Alert message", "Cheese!", wc.popNextAlert() ); + } + + public void testSingleCommandOnLoad() throws Exception { defineResource( "OnCommand.html", "<html><head></head>" + "<body onLoad='alert(\"Ouch!\")'></body>" ); |
From: Russell G. <rus...@us...> - 2002-10-04 15:19:28
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv27236/test/com/meterware/httpunit Modified Files: WebWindowTest.java Log Message: Added listener support for window opening Index: WebWindowTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebWindowTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WebWindowTest.java 4 Oct 2002 00:40:28 -0000 1.1 +++ WebWindowTest.java 4 Oct 2002 15:19:25 -0000 1.2 @@ -19,6 +19,9 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ +import java.util.ArrayList; +import java.io.IOException; + import junit.framework.TestSuite; import junit.textui.TestRunner; @@ -56,6 +59,30 @@ assertEquals( "Main page in original window", initialPage, main.getCurrentPage() ); WebWindow other = wc.getOpenWindows()[1]; assertEquals( "New window contents", "You made it!", other.getCurrentPage().getText() ); + } + + + public void testListeners() throws Exception { + defineResource( "goHere", "You made it!" ); + defineWebPage( "start", "<a href='goHere' id='go' target='_blank'>here</a>" ); + + final ArrayList newWindowContents = new ArrayList(); + WebClient wc = new WebConversation(); + wc.addWindowListener( new WebWindowListener() { + public void windowOpened( WebClient client, WebWindow window ) { + try { + newWindowContents.add( window.getCurrentPage().getText() ); + } catch (IOException e) { + fail( "Error trying to read page" ); + } + } + public void windowClosed( WebClient client, WebWindow window ) { + } + }); + WebResponse initialPage = wc.getResponse( getHostPath() + "/start.html" ); + initialPage.getLinkWithID( "go" ).click(); + assertFalse( "No window opened", newWindowContents.isEmpty() ); + assertEquals( "New window contents", "You made it!", newWindowContents.get(0) ); } |
From: Russell G. <rus...@us...> - 2002-10-04 15:19:28
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv27236/src/com/meterware/httpunit Modified Files: WebClient.java WebWindow.java Added Files: WebWindowListener.java Log Message: Added listener support for window opening ***** Error reading new file[Errno 2] No such file or directory: 'WebWindowListener.java' Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- WebClient.java 4 Oct 2002 00:40:28 -0000 1.35 +++ WebClient.java 4 Oct 2002 15:19:25 -0000 1.36 @@ -316,6 +316,26 @@ /** + * Adds a listener to watch for window openings and closings. + */ + public void addWindowListener( WebWindowListener listener ) { + synchronized (_windowListeners) { + if (listener != null && !_windowListeners.contains( listener )) _windowListeners.add( listener ); + } + } + + + /** + * Removes a listener to watch for window openings and closings. + */ + public void removeWindowListener( WebWindowListener listener ) { + synchronized (_windowListeners) { + _windowListeners.remove( listener ); + } + } + + + /** * Returns the next javascript alert without removing it from the queue. */ public String getNextAlert() { @@ -410,17 +430,38 @@ } - WebWindow getTargetWindow( WebWindow requestWindow, String target ) { - if (WebRequest.NEW_WINDOW.equalsIgnoreCase( target )) { - WebWindow window = new WebWindow( this ); - _openWindows.add( window ); - return window; + void updateFrameContents( WebWindow requestWindow, String requestTarget, WebResponse response ) throws IOException, SAXException { + WebWindow window = getTargetWindow( requestWindow, requestTarget ); + if (window != null) { + window.updateFrameContents( response ); } else { - return requestWindow; + window = new WebWindow( this ); + window.updateFrameContents( response ); + _openWindows.add( window ); + reportWindowOpened( window ); } } + private WebWindow getTargetWindow( WebWindow requestWindow, String target ) { + return WebRequest.NEW_WINDOW.equalsIgnoreCase( target ) ? null : requestWindow; + } + + + private void reportWindowOpened( WebWindow window ) { + List listeners; + + synchronized (_windowListeners) { + listeners = new ArrayList( _windowListeners ); + } + + for (Iterator i = listeners.iterator(); i.hasNext();) { + ((WebWindowListener) i.next()).windowOpened( this, window ); + } + } + + + //------------------------------------------ package members ------------------------------------ @@ -453,6 +494,8 @@ private boolean _exceptionsThrownOnErrorStatus = HttpUnitOptions.getExceptionsThrownOnErrorStatus(); private List _clientListeners = new ArrayList(); + + private List _windowListeners = new ArrayList(); private DialogResponder _dialogResponder = new DialogAdapter(); Index: WebWindow.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebWindow.java 4 Oct 2002 00:40:28 -0000 1.2 +++ WebWindow.java 4 Oct 2002 15:19:25 -0000 1.3 @@ -116,7 +116,7 @@ delay( HttpUnitOptions.getRedirectDelay() ); getResponse( new RedirectWebRequest( response ) ); } else { - _client.getTargetWindow( this, requestTarget ).updateFrameContents( response ); + _client.updateFrameContents( this, requestTarget, response ); } } @@ -130,7 +130,7 @@ } - private void updateFrameContents( WebResponse response ) throws IOException, SAXException { + void updateFrameContents( WebResponse response ) throws IOException, SAXException { response.setWindow( this ); _frameContents.updateFrames( response, response.getTarget() ); } |
From: Russell G. <rus...@us...> - 2002-10-04 15:19:28
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv27236/doc Modified Files: release_notes.txt Log Message: Added listener support for window opening Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.176 retrieving revision 1.177 diff -u -r1.176 -r1.177 --- release_notes.txt 4 Oct 2002 02:15:59 -0000 1.176 +++ release_notes.txt 4 Oct 2002 15:19:25 -0000 1.177 @@ -10,6 +10,10 @@ Revision History: + 4-Oct-2002 +Additions: + 1. WebClient now supports a WebWindowListener which will be called when a new window is opened. + 3-Oct-2002 Acknowledgements: Thanks to Geert Bevin for fixing a problem with generation of cookie headers that affects some servers. |
From: Russell G. <rus...@us...> - 2002-10-04 15:18:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv26798/src/com/meterware/httpunit Modified Files: ParameterHolder.java WebForm.java WebLink.java WebRequestSource.java Log Message: Refactor to simplify adding attribute support Index: ParameterHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParameterHolder.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ParameterHolder.java 4 Feb 2002 22:33:55 -0000 1.5 +++ ParameterHolder.java 4 Oct 2002 15:18:37 -0000 1.6 @@ -27,7 +27,8 @@ /** - * This interface is implemented by classes which hold parameters for web requests. + * This abstract class is extended by classes which hold parameters for web requests. Note that it is an abstract class + * rather than an interface in order to keep its methods package-local. * * @author <a href="mailto:rus...@ac...">Russell Gold</a> **/ Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- WebForm.java 3 Oct 2002 12:35:18 -0000 1.66 +++ WebForm.java 4 Oct 2002 15:18:37 -0000 1.67 @@ -57,7 +57,7 @@ * Submits this form using the web client from which it was originally obtained. **/ WebResponse submit( SubmitButton button ) throws IOException, SAXException { - String event = NodeUtils.getNodeAttribute( getNode(), "onsubmit" ); + String event = getAttribute( "onsubmit" ); if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest( getRequest( button ) ); return getBaseResponse(); } @@ -67,7 +67,7 @@ * Returns the method defined for this form. **/ public String getMethod() { - return NodeUtils.getNodeAttribute( getNode(), "method", "GET" ); + return getAttribute( "method", "GET" ); } @@ -322,7 +322,7 @@ * Returns true if this form is to be submitted using mime encoding (the default is URL encoding). **/ public boolean isSubmitAsMime() { - return "multipart/form-data".equalsIgnoreCase( NodeUtils.getNodeAttribute( getNode(), "enctype" ) ); + return "multipart/form-data".equalsIgnoreCase( getAttribute( "enctype" ) ); } @@ -330,7 +330,7 @@ * Resets all parameters to their initial values. */ public void reset() { - String event = NodeUtils.getNodeAttribute( getNode(), "onreset" ); + String event = getAttribute( "onreset" ); if (event.length() == 0 || getScriptableObject().doEvent( event )) resetControls(); } Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- WebLink.java 2 Oct 2002 16:20:45 -0000 1.30 +++ WebLink.java 4 Oct 2002 15:18:37 -0000 1.31 @@ -67,7 +67,7 @@ **/ public String asText() { if (getNode().getNodeName().equals( "area" )) { - return NodeUtils.getNodeAttribute( getNode(), "alt" ); + return getAttribute( "alt" ); } else if (!getNode().hasChildNodes()) { return ""; } else { @@ -80,7 +80,7 @@ * Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined. **/ public WebResponse click() throws IOException, SAXException { - String event = NodeUtils.getNodeAttribute( getNode(), "onclick" ); + String event = getAttribute( "onclick" ); if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest(); return getBaseResponse(); } @@ -90,7 +90,7 @@ * Simulates moving the mouse over the link. Will fire the 'onMouseOver' event if defined. **/ public void mouseOver() { - String event = NodeUtils.getNodeAttribute( getNode(), "onmouseover" ); + String event = getAttribute( "onmouseover" ); if (event.length() > 0) getScriptableObject().doEvent( event ); } Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- WebRequestSource.java 4 Oct 2002 00:40:28 -0000 1.16 +++ WebRequestSource.java 4 Oct 2002 15:18:37 -0000 1.17 @@ -37,7 +37,7 @@ * Returns the ID associated with this request source. **/ public String getID() { - return NodeUtils.getNodeAttribute( _node, "id" ); + return getAttribute( "id" ); } @@ -45,7 +45,7 @@ * Returns the name associated with this request source. **/ public String getName() { - return NodeUtils.getNodeAttribute( _node, "name" ); + return getAttribute( "name" ); } @@ -216,6 +216,16 @@ protected void addPresetParameter( String name, String value ); + String getAttribute( final String name ) { + return NodeUtils.getNodeAttribute( _node, name ); + } + + + String getAttribute( final String name, String defaultValue ) { + return NodeUtils.getNodeAttribute( _node, name, defaultValue ); + } + + //----------------------------- private members ----------------------------------------------- @@ -236,8 +246,9 @@ /** The DOM node representing this entity. **/ private Node _node; + private String getSpecifiedTarget() { - return NodeUtils.getNodeAttribute( _node, "target" ); + return getAttribute( "target" ); } |
From: Russell G. <rus...@us...> - 2002-10-04 02:16:03
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv16519/src/com/meterware/httpunit Modified Files: HTMLSegment.java ParsedHTML.java WebImage.java WebResponse.java WebTable.java Log Message: Made search mechanism for tables generic, similar to that for links Index: HTMLSegment.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLSegment.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HTMLSegment.java 13 Sep 2002 14:17:25 -0000 1.5 +++ HTMLSegment.java 4 Oct 2002 02:16:00 -0000 1.6 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2001, Russell Gold +* Copyright (c) 2000-2002, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -118,6 +118,14 @@ * @exception SAXException thrown if there is an error parsing the segment. **/ public WebTable[] getTables() throws SAXException; + + + /** + * Returns the first table in the response which matches the specified predicate and value. + * Will recurse into any nested tables, as needed. + * @return the selected table, or null if none is found + **/ + public WebTable getFirstMatchingTable( HTMLElementPredicate predicate, Object criteria ) throws SAXException; /** Index: ParsedHTML.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- ParsedHTML.java 2 Oct 2002 16:20:45 -0000 1.29 +++ ParsedHTML.java 4 Oct 2002 02:16:00 -0000 1.30 @@ -242,18 +242,22 @@ /** + * Returns the first table in the response which matches the specified predicate and value. + * Will recurse into any nested tables, as needed. + * @return the selected table, or null if none is found + **/ + public WebTable getFirstMatchingTable( HTMLElementPredicate predicate, Object criteria ) { + return getTableSatisfyingPredicate( getTables(), predicate, criteria ); + } + + + /** * Returns the first table in the response which has the specified text as the full text of * 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 **/ - public WebTable getTableStartingWith( final String text ) { - return getTableSatisfyingPredicate( getTables(), new TablePredicate() { - public boolean isTrue( WebTable table ) { - table.purgeEmptyCells(); - return table.getRowCount() > 0 && - HttpUnitUtils.matches( table.getCellAsText(0,0), text ); - } - } ); + public WebTable getTableStartingWith( String text ) { + return getFirstMatchingTable( WebTable.MATCH_FIRST_NONBLANK_CELL, text ); } @@ -262,14 +266,8 @@ * 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 **/ - public WebTable getTableStartingWithPrefix( final String text ) { - return getTableSatisfyingPredicate( getTables(), new TablePredicate() { - public boolean isTrue( WebTable table ) { - table.purgeEmptyCells(); - return table.getRowCount() > 0 && - HttpUnitUtils.hasPrefix( table.getCellAsText(0,0).toUpperCase(), text ); - } - } ); + public WebTable getTableStartingWithPrefix( String text ) { + return getFirstMatchingTable( WebTable.MATCH_FIRST_NONBLANK_CELL_PREFIX, text ); } @@ -278,12 +276,8 @@ * Will recurse into any nested tables, as needed. * @return the selected table, or null if none is found **/ - public WebTable getTableWithSummary( final String summary ) { - return getTableSatisfyingPredicate( getTables(), new TablePredicate() { - public boolean isTrue( WebTable table ) { - return HttpUnitUtils.matches( table.getSummary(), summary ); - } - } ); + public WebTable getTableWithSummary( String summary ) { + return getFirstMatchingTable( WebTable.MATCH_SUMMARY, summary ); } @@ -292,12 +286,8 @@ * Will recurse into any nested tables, as needed. * @return the selected table, or null if none is found **/ - public WebTable getTableWithID( final String ID ) { - return getTableSatisfyingPredicate( getTables(), new TablePredicate() { - public boolean isTrue( WebTable table ) { - return HttpUnitUtils.matches( table.getID(), ID ); - } - } ); + public WebTable getTableWithID( String ID ) { + return getFirstMatchingTable( WebTable.MATCH_ID, ID ); } @@ -361,25 +351,6 @@ } - interface TablePredicate { - public boolean isTrue( WebTable table ); - } - - - interface LinkPredicate { - public boolean isTrue( WebLink link ); - } - - - WebLink getLinkSatisfyingPredicate( LinkPredicate predicate ) { - WebLink[] links = getLinks(); - for (int i = 0; i < links.length; i++) { - if (predicate.isTrue( links[ i ] )) return links[ i ]; - } - return null; - } - - //---------------------------------- private members -------------------------------- private Node _rootNode; @@ -416,9 +387,9 @@ /** * Returns the table with the specified text in its summary attribute. **/ - private WebTable getTableSatisfyingPredicate( WebTable[] tables, TablePredicate predicate ) { + private WebTable getTableSatisfyingPredicate( WebTable[] tables, HTMLElementPredicate predicate, Object value ) { for (int i = 0; i < tables.length; i++) { - if (predicate.isTrue( tables[i] )) { + if (predicate.matchesCriteria( tables[i], value )) { return tables[i]; } else { for (int j = 0; j < tables[i].getRowCount(); j++) { @@ -427,7 +398,7 @@ if (cell != null) { WebTable[] innerTables = cell.getTables(); if (innerTables.length != 0) { - WebTable result = getTableSatisfyingPredicate( innerTables, predicate ); + WebTable result = getTableSatisfyingPredicate( innerTables, predicate, value ); if (result != null) return result; } } Index: WebImage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebImage.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WebImage.java 5 Sep 2002 19:10:44 -0000 1.6 +++ WebImage.java 4 Oct 2002 02:16:00 -0000 1.7 @@ -67,15 +67,15 @@ public WebLink getLink() { - return _parsedHTML.getLinkSatisfyingPredicate( new ParsedHTML.LinkPredicate() { + return _parsedHTML.getFirstMatchingLink( new HTMLElementPredicate() { - public boolean isTrue( WebLink link ) { - for (Node parent = _node.getParentNode(); parent != null; parent = parent.getParentNode()) { - if (parent.equals( link.getNode() )) return true; + public boolean matchesCriteria( Object link, Object parentNode ) { + for (Node parent = (Node) parentNode; parent != null; parent = parent.getParentNode()) { + if (parent.equals( ((WebLink) link).getNode() )) return true; } return false; } - } ); + }, _node.getParentNode() ); } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- WebResponse.java 4 Oct 2002 00:40:28 -0000 1.81 +++ WebResponse.java 4 Oct 2002 02:16:00 -0000 1.82 @@ -408,16 +408,6 @@ /** - * Returns the top-level tables found in this page in the order in which - * they appear. - * @exception SAXException thrown if there is an error parsing the response. - **/ - public WebTable[] getTables() throws SAXException { - return getReceivedPage().getTables(); - } - - - /** * 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. @@ -432,6 +422,26 @@ throw new SAXException( e ); } } + } + + + /** + * Returns the top-level tables found in this page in the order in which + * they appear. + * @exception SAXException thrown if there is an error parsing the response. + **/ + public WebTable[] getTables() throws SAXException { + return getReceivedPage().getTables(); + } + + + /** + * Returns the first table in the response which matches the specified predicate and value. + * Will recurse into any nested tables, as needed. + * @return the selected table, or null if none is found + **/ + public WebTable getFirstMatchingTable( HTMLElementPredicate predicate, Object criteria ) throws SAXException { + return getReceivedPage().getFirstMatchingTable( predicate, criteria ); } Index: WebTable.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebTable.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- WebTable.java 6 Aug 2002 21:42:08 -0000 1.18 +++ WebTable.java 4 Oct 2002 02:16:00 -0000 1.19 @@ -34,6 +34,19 @@ public class WebTable { + /** Predicate to match the complete text of a table's first non-blank cell. **/ + public final static HTMLElementPredicate MATCH_FIRST_NONBLANK_CELL; + + /** Predicate to match a prefix of a table's first non-blank cell. **/ + public final static HTMLElementPredicate MATCH_FIRST_NONBLANK_CELL_PREFIX; + + /** Predicate to match a table's summary attribute. **/ + public final static HTMLElementPredicate MATCH_SUMMARY; + + /** Predicate to match a table's ID. **/ + public final static HTMLElementPredicate MATCH_ID; + + /** * Returns the number of rows in the table. **/ @@ -406,6 +419,41 @@ } } + static { + MATCH_FIRST_NONBLANK_CELL = new HTMLElementPredicate() { + public boolean matchesCriteria( Object htmlElement, Object criteria ) { + WebTable table = ((WebTable) htmlElement); + table.purgeEmptyCells(); + return table.getRowCount() > 0 && + HttpUnitUtils.matches( table.getCellAsText(0,0), (String) criteria ); + }; + }; + + + MATCH_FIRST_NONBLANK_CELL_PREFIX = new HTMLElementPredicate() { + public boolean matchesCriteria( Object htmlElement, Object criteria ) { + WebTable table = ((WebTable) htmlElement); + table.purgeEmptyCells(); + return table.getRowCount() > 0 && + HttpUnitUtils.hasPrefix( table.getCellAsText(0,0).toUpperCase(), (String) criteria ); + }; + }; + + + MATCH_ID = new HTMLElementPredicate() { + public boolean matchesCriteria( Object htmlElement, Object criteria ) { + return HttpUnitUtils.matches( ((WebTable) htmlElement).getID(), (String) criteria ); + }; + }; + + + MATCH_SUMMARY = new HTMLElementPredicate() { + public boolean matchesCriteria( Object htmlElement, Object criteria ) { + return HttpUnitUtils.matches( ((WebTable) htmlElement).getSummary(), (String) criteria ); + }; + }; + + } } |
From: Russell G. <rus...@us...> - 2002-10-04 02:16:02
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv16519/doc Modified Files: release_notes.txt Log Message: Made search mechanism for tables generic, similar to that for links Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.175 retrieving revision 1.176 diff -u -r1.175 -r1.176 --- release_notes.txt 4 Oct 2002 00:40:27 -0000 1.175 +++ release_notes.txt 4 Oct 2002 02:15:59 -0000 1.176 @@ -18,6 +18,8 @@ 1. Following the "_blank" target now creates a new web window, with its own set of frames. Following links or submitting forms will update the window from which the request originated. Requests may also now be initiated from an open window. The list of open windows is a property of the web client. + 2. The mechanism for searching for tables has been expanded to permit arbitrary search criteria, similar to that + for links. Problems fixed: 1. The cookie header was being generated with a space after each ";" separator. |
From: Russell G. <rus...@us...> - 2002-10-04 00:40:33
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv24014/src/com/meterware/servletunit Modified Files: ServletUnitClient.java Log Message: Added support for multiple windows Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ServletUnitClient.java 3 Oct 2002 12:35:18 -0000 1.8 +++ ServletUnitClient.java 4 Oct 2002 00:40:28 -0000 1.9 @@ -82,7 +82,7 @@ * servlet invocation unless that invocation results in a redirect request. **/ public WebResponse getResponse( InvocationContext invocation ) throws MalformedURLException,IOException,SAXException { - updateMainWindow( invocation.getServletResponse() ); + updateMainWindow( invocation.getTarget(), invocation.getServletResponse() ); return getFrameContents( invocation.getTarget() ); } @@ -93,7 +93,7 @@ /** * Creates a web response object which represents the response to the specified web request. **/ - protected WebResponse newResponse( WebRequest request ) throws MalformedURLException,IOException { + protected WebResponse newResponse( WebRequest request, String frameName ) throws MalformedURLException,IOException { try { InvocationContext invocation = newInvocation( request ); |
From: Russell G. <rus...@us...> - 2002-10-04 00:40:32
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv24014/src/com/meterware/httpunit Modified Files: FrameHolder.java HTMLPage.java WebClient.java WebConversation.java WebRequest.java WebRequestSource.java WebResponse.java WebWindow.java Log Message: Added support for multiple windows Index: FrameHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FrameHolder.java 5 Aug 2002 18:58:43 -0000 1.3 +++ FrameHolder.java 4 Oct 2002 00:40:28 -0000 1.4 @@ -21,11 +21,10 @@ *******************************************************************************************************************/ import java.io.IOException; import java.net.MalformedURLException; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; -import java.util.Vector; import java.util.List; -import java.util.ArrayList; import org.xml.sax.SAXException; @@ -40,17 +39,19 @@ private Hashtable _contents = new Hashtable(); private Hashtable _subFrames = new Hashtable(); private String _frameName; - private WebResponse _response = WebResponse.BLANK_RESPONSE; FrameHolder( WebClient client, String name ) { _client = client; _frameName = name; + DefaultWebResponse blankResponse = new DefaultWebResponse( _client, null, WebResponse.BLANK_HTML ); + _contents.put( WebRequest.TOP_FRAME, blankResponse ); + HttpUnitOptions.getScriptingEngine().associate( blankResponse ); } - public WebResponse get( String frameName ) { - return (WebResponse) _contents.get( frameName ); + WebResponse get( String target ) { + return (WebResponse) _contents.get( getFrameName( target ) ); } @@ -64,12 +65,23 @@ } - void updateFrames( WebResponse response ) throws MalformedURLException, IOException, SAXException { - removeSubFrames( response.getTarget() ); - _contents.put( response.getTarget(), response ); + String getFrameName( String target ) { + if (WebRequest.TOP_FRAME.equalsIgnoreCase( target )) { + return _frameName; + } else if (WebRequest.NEW_WINDOW.equalsIgnoreCase( target )) { + return _frameName; + } else { + return target; + } + } + + + void updateFrames( WebResponse response, String target ) throws MalformedURLException, IOException, SAXException { + removeSubFrames( target ); + _contents.put( target, response ); if (response.isHTML()) { - createSubFrames( response.getTarget(), response.getFrameNames() ); + createSubFrames( target, response.getFrameNames() ); WebRequest[] requests = response.getFrameRequests(); for (int i = 0; i < requests.length; i++) _client.getResponse( requests[ i ] ); HttpUnitOptions.getScriptingEngine().associate( response ); Index: HTMLPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- HTMLPage.java 25 Sep 2002 16:20:53 -0000 1.9 +++ HTMLPage.java 4 Oct 2002 00:40:28 -0000 1.10 @@ -19,22 +19,21 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ -import com.meterware.httpunit.scripting.ScriptableDelegate; import com.meterware.httpunit.scripting.NamedDelegate; +import com.meterware.httpunit.scripting.ScriptableDelegate; import java.io.ByteArrayInputStream; -import java.io.UnsupportedEncodingException; import java.io.IOException; - +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; - import java.util.Vector; -import org.w3c.dom.*; - +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.w3c.tidy.Tidy; - import org.xml.sax.SAXException; @@ -88,7 +87,7 @@ } else { try { WebRequest req = new GetMethodWebRequest( getBaseURL(), src ); - sb.append( getResponse().getClient().getResource( req ).getText() ); + sb.append( getResponse().getWindow().getResource( req ).getText() ); } catch (IOException e) { throw new RuntimeException( "Error loading included script: " + e ); } Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- WebClient.java 3 Oct 2002 16:48:49 -0000 1.34 +++ WebClient.java 4 Oct 2002 00:40:28 -0000 1.35 @@ -21,8 +21,10 @@ *******************************************************************************************************************/ import java.io.IOException; import java.io.OutputStream; + import java.net.HttpURLConnection; import java.net.MalformedURLException; + import java.util.*; import org.xml.sax.SAXException; @@ -120,7 +122,7 @@ * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. */ public WebResponse getResource( WebRequest request ) throws IOException { - return getResourceForWindow( request, _mainWindow ); + return _mainWindow.getResource( request ); } @@ -133,18 +135,28 @@ private WebResponse getResource( WebRequest request, final WebWindow window ) throws IOException { + final String frameName = getTargetFrame( request.getTarget() ); String urlString = request.getURLString().trim(); if (urlString.startsWith( "about:" )) { return WebResponse.BLANK_RESPONSE; } else if (!urlString.startsWith( "javascript:" )) { - return newResponse( request ); + return newResponse( request, frameName ); } else { WebRequestSource wrs = request.getWebRequestSource(); String result = (wrs == null) ? window.getCurrentPage().getScriptableObject().evaluateURL( urlString ) : wrs.getScriptableDelegate().evaluateURL( urlString ); if (result == null) return null; - return new DefaultWebResponse( this, request.getTarget(), request.getURL(), result ); + return new DefaultWebResponse( this, frameName, request.getURL(), result ); + } + } + + + private String getTargetFrame( String target ) { + if (WebRequest.NEW_WINDOW.equalsIgnoreCase( target )) { + return WebRequest.TOP_FRAME; + } else { + return target; } } @@ -343,7 +355,7 @@ * Creates a web response object which represents the response to the specified web request. **/ abstract - protected WebResponse newResponse( WebRequest request ) throws MalformedURLException, IOException; + protected WebResponse newResponse( WebRequest request, String frameName ) throws MalformedURLException, IOException; /** @@ -387,14 +399,25 @@ * cookies and frames. **/ final - protected void updateMainWindow( WebResponse response ) throws MalformedURLException, IOException, SAXException { - _mainWindow.updateWindow( response ); + protected void updateMainWindow( String target, WebResponse response ) throws MalformedURLException, IOException, SAXException { + _mainWindow.updateWindow( target, response ); } void updateClient( WebResponse response ) throws IOException { updateCookies( response ); validateHeaders( response ); + } + + + WebWindow getTargetWindow( WebWindow requestWindow, String target ) { + if (WebRequest.NEW_WINDOW.equalsIgnoreCase( target )) { + WebWindow window = new WebWindow( this ); + _openWindows.add( window ); + return window; + } else { + return requestWindow; + } } Index: WebConversation.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- WebConversation.java 1 Aug 2002 14:58:59 -0000 1.25 +++ WebConversation.java 4 Oct 2002 00:40:28 -0000 1.26 @@ -53,7 +53,7 @@ /** * Creates a web response object which represents the response to the specified web request. **/ - protected WebResponse newResponse( WebRequest request ) throws MalformedURLException, IOException { + protected WebResponse newResponse( WebRequest request, String frameName ) throws MalformedURLException, IOException { URLConnection connection = openConnection( request.getURL() ); sendHeaders( connection, request.getHeaderDictionary() ); if (HttpUnitOptions.isLoggingHttpHeaders()) { @@ -63,7 +63,7 @@ } } request.completeRequest( connection ); - return new HttpWebResponse( this, request.getTarget(), request.getURL(), connection, getExceptionsThrownOnErrorStatus() ); + return new HttpWebResponse( this, frameName, request.getURL(), connection, getExceptionsThrownOnErrorStatus() ); } Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- WebRequest.java 26 Sep 2002 18:22:32 -0000 1.48 +++ WebRequest.java 4 Oct 2002 00:40:28 -0000 1.49 @@ -20,29 +20,23 @@ * *******************************************************************************************************************/ import java.io.File; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.security.Provider; -import java.security.Security; - import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.net.URLStreamHandler; -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; -import java.util.Arrays; -import java.util.ArrayList; -import java.util.HashSet; +import java.security.Provider; +import java.security.Security; + +import java.util.*; /** * A request sent to a web server. @@ -442,8 +436,14 @@ //---------------------------------- package members -------------------------------- - /** The name of the topmost frame. **/ + /** The target indicating the topmost frame of a window. **/ final static String TOP_FRAME = "_top"; + + /** The target indicating the parent of a frame. **/ + final static String PARENT_FRAME = "_frame"; + + /** The target indicating a new, empty window. **/ + final static String NEW_WINDOW = "_blank"; WebRequestSource getWebRequestSource() { Index: WebRequestSource.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- WebRequestSource.java 27 Sep 2002 15:49:02 -0000 1.15 +++ WebRequestSource.java 4 Oct 2002 00:40:28 -0000 1.16 @@ -195,7 +195,7 @@ protected WebResponse submitRequest( WebRequest request ) throws IOException, SAXException { return getDestination().equals( "#" ) ? _baseResponse - : _baseResponse.getClient().sendRequest( request ); + : _baseResponse.getWindow().sendRequest( request ); } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- WebResponse.java 1 Oct 2002 16:11:48 -0000 1.80 +++ WebResponse.java 4 Oct 2002 00:40:28 -0000 1.81 @@ -19,23 +19,15 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ - import com.meterware.httpunit.scripting.ScriptableDelegate; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.StreamTokenizer; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; -import java.util.LinkedList; import java.util.zip.GZIPInputStream; import org.w3c.dom.Document; @@ -283,8 +275,8 @@ * @param subFrameName the name of the desired frame as defined in the frameset. **/ public WebResponse getSubframeContents( String subFrameName ) { - if (_client == null) throw new NoSuchFrameException( subFrameName ); - return _client.getFrameContents( WebFrame.getNestedFrameName( _frameName, subFrameName ) ); + if (_window == null) throw new NoSuchFrameException( subFrameName ); + return _window.getFrameContents( WebFrame.getNestedFrameName( _frameName, subFrameName ) ); } @@ -578,7 +570,7 @@ public void set( String propertyName, Object value ) { if (propertyName.equalsIgnoreCase( "location" )) { try { - getClient().getResponse( new GetMethodWebRequest( _url, value.toString(), _frameName ) ); + getWindow().getResponse( new GetMethodWebRequest( _url, value.toString(), _frameName ) ); } catch (IOException e) { throw new RuntimeException( "Error handling 'location=': " + e ); } catch (SAXException e) { @@ -670,6 +662,16 @@ final static WebResponse BLANK_RESPONSE = new DefaultWebResponse( BLANK_HTML ); + WebWindow getWindow() { + return _window; + } + + + void setWindow( WebWindow window ) { + _window = window; + } + + /** * Returns the frames found in the page in the order in which they appear. **/ @@ -688,11 +690,6 @@ } - WebClient getClient() { - return _client; - } - - //--------------------------------- private members -------------------------------------- @@ -721,6 +718,8 @@ final private static int UNINITIALIZED_INT = -2; private WebFrame[] _frames; + + private WebWindow _window; private HTMLPage _page; Index: WebWindow.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WebWindow.java 3 Oct 2002 12:35:18 -0000 1.1 +++ WebWindow.java 4 Oct 2002 00:40:28 -0000 1.2 @@ -19,12 +19,10 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ - -import java.lang.String; -import java.util.List; -import java.net.MalformedURLException; -import java.net.HttpURLConnection; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.util.List; import org.xml.sax.SAXException; @@ -66,7 +64,7 @@ public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException { WebResponse response = _client.getResourceForWindow( request, this ); - if (response != null) updateWindow( response ); + if (response != null) updateWindow( request.getTarget(), response ); return getFrameContents( request.getTarget() ); } @@ -103,12 +101,6 @@ WebWindow( WebClient client ) { _client = client; _frameContents = new FrameHolder( _client, WebRequest.TOP_FRAME ); - - try { - _frameContents.updateFrames( new DefaultWebResponse( _client, null, WebResponse.BLANK_HTML ) ); - } catch (IOException e) { - } catch (SAXException e) { - } } @@ -116,16 +108,31 @@ * Updates this web client based on a received response. This includes updating * cookies and frames. **/ - void updateWindow( WebResponse response ) throws MalformedURLException, IOException, SAXException { - _client.updateClient( response ); + void updateWindow( String requestTarget, WebResponse response ) throws MalformedURLException, IOException, SAXException { + _client.updateClient( response ); if (HttpUnitOptions.getAutoRefresh() && response.getRefreshRequest() != null) { getResponse( response.getRefreshRequest() ); } else if (shouldFollowRedirect( response )) { delay( HttpUnitOptions.getRedirectDelay() ); getResponse( new RedirectWebRequest( response ) ); } else { - _frameContents.updateFrames( response ); + _client.getTargetWindow( this, requestTarget ).updateFrameContents( response ); } + } + + + /** + * Returns the resource specified by the request. Does not update the client or load included framesets. + * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. + */ + WebResponse getResource( WebRequest request ) throws IOException { + return _client.getResourceForWindow( request, this ); + } + + + private void updateFrameContents( WebResponse response ) throws IOException, SAXException { + response.setWindow( this ); + _frameContents.updateFrames( response, response.getTarget() ); } |
From: Russell G. <rus...@us...> - 2002-10-04 00:40:32
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv24014/test/com/meterware/httpunit Modified Files: HttpUnitSuite.java Added Files: WebWindowTest.java Log Message: Added support for multiple windows ***** Error reading new file[Errno 2] No such file or directory: 'WebWindowTest.java' Index: HttpUnitSuite.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitSuite.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- HttpUnitSuite.java 16 Aug 2002 18:52:51 -0000 1.21 +++ HttpUnitSuite.java 4 Oct 2002 00:40:28 -0000 1.22 @@ -51,6 +51,7 @@ result.addTest( HtmlTablesTest.suite() ); result.addTest( WebFormTest.suite() ); result.addTest( WebFrameTest.suite() ); + result.addTest( WebWindowTest.suite() ); result.addTest( RequestTargetTest.suite() ); result.addTest( FormParametersTest.suite() ); result.addTest( FormSubmitTest.suite() ); |
From: Russell G. <rus...@us...> - 2002-10-04 00:40:32
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv24014/doc Modified Files: release_notes.txt Log Message: Added support for multiple windows Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.174 retrieving revision 1.175 diff -u -r1.174 -r1.175 --- release_notes.txt 3 Oct 2002 16:48:48 -0000 1.174 +++ release_notes.txt 4 Oct 2002 00:40:27 -0000 1.175 @@ -1,8 +1,7 @@ HttpUnit release notes Known problems: - 1. The "_new" and "_empty" frame targets are not handled correctly - 2. The "accept-charset" attribute for forms is ignored; the page content character set is used to encode any response. + 1. The "accept-charset" attribute for forms is ignored; the page content character set is used to encode any response. This behavior matches that currently used by IE and Navigator. Limitations: @@ -14,6 +13,11 @@ 3-Oct-2002 Acknowledgements: Thanks to Geert Bevin for fixing a problem with generation of cookie headers that affects some servers. + +Additions: + 1. Following the "_blank" target now creates a new web window, with its own set of frames. Following links or submitting + forms will update the window from which the request originated. Requests may also now be initiated from an open window. + The list of open windows is a property of the web client. Problems fixed: 1. The cookie header was being generated with a space after each ";" separator. |
From: Russell G. <rus...@us...> - 2002-10-03 16:48:54
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv17683/doc Modified Files: release_notes.txt Log Message: from Geert Bevin: remove extraneous spaces in cookie header Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.173 retrieving revision 1.174 diff -u -r1.173 -r1.174 --- release_notes.txt 2 Oct 2002 16:37:55 -0000 1.173 +++ release_notes.txt 3 Oct 2002 16:48:48 -0000 1.174 @@ -11,6 +11,13 @@ Revision History: + 3-Oct-2002 +Acknowledgements: + Thanks to Geert Bevin for fixing a problem with generation of cookie headers that affects some servers. + +Problems fixed: + 1. The cookie header was being generated with a space after each ";" separator. + 2-Oct-2002 Acknowledgements: |
From: Russell G. <rus...@us...> - 2002-10-03 16:48:53
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17683/src/com/meterware/httpunit Modified Files: WebClient.java Log Message: from Geert Bevin: remove extraneous spaces in cookie header Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- WebClient.java 3 Oct 2002 12:35:18 -0000 1.33 +++ WebClient.java 3 Oct 2002 16:48:49 -0000 1.34 @@ -363,7 +363,7 @@ StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_BUFFER_SIZE); for (int i = 0; i < names.length; i++) { - if (i != 0) sb.append( "; " ); + if (i != 0) sb.append( ";" ); String name = names[i]; sb.append( name ).append( '=' ).append( getCookieValue( name ) ); } |
From: Russell G. <rus...@us...> - 2002-10-03 12:35:21
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv18765/test/com/meterware/httpunit Modified Files: FormParametersTest.java Log Message: Refactored to facilitate multiple window feature Index: FormParametersTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- FormParametersTest.java 2 Oct 2002 13:57:56 -0000 1.16 +++ FormParametersTest.java 3 Oct 2002 12:35:18 -0000 1.17 @@ -4,12 +4,12 @@ * * Copyright (c) 2000-2002, Russell Gold * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -* documentation files (the "Software"), to deal in the Software without restriction, including without limitation +* 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 @@ -37,8 +37,8 @@ public static void main(String args[]) { junit.textui.TestRunner.run( suite() ); } - - + + public static Test suite() { return new TestSuite( FormParametersTest.class ); } @@ -53,8 +53,8 @@ super.setUp(); _wc = new WebConversation(); } - - + + public void testChoiceParameterValidationBypass() throws Exception { HttpUnitOptions.setParameterValuesValidated( false ); defineWebPage( "Default", "<form method=GET action = \"/ask\">" + @@ -72,7 +72,7 @@ request.setParameter( "fish", new String[] { "red", "pink" } ); } - + public void testChoiceParameterValidation() throws Exception { defineWebPage( "Default", "<form method=GET action = \"/ask\">" + "<Select name=colors><Option>blue<Option>red</Select>" + @@ -88,7 +88,7 @@ validateSetParameterRejected( request, "media", "CDRom", "setting list to illegal value" ); validateSetParameterRejected( request, "colors", new String[] { "blue", "red" }, "setting multiple values on choice" ); validateSetParameterRejected( request, "media", new String[] { "TV", "CDRom" }, "setting one bad value in a group" ); - + request.setParameter( "colors", "blue" ); request.setParameter( "fish", "red" ); request.setParameter( "media", "TV" ); @@ -158,7 +158,7 @@ try { request.setParameter( "secret", "zork" ); fail( "Should have rejected set of unknown parameter" ); - } catch (NoSuchParameterException e) { + } catch (WebForm.NoSuchParameterException e) { } } @@ -363,7 +363,7 @@ } } - + private void validateSetParameterRejected( WebRequest request, String parameterName, String[] values, String comment ) throws Exception { try { request.setParameter( parameterName, values ); |
From: Russell G. <rus...@us...> - 2002-10-03 12:35:21
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory usw-pr-cvs1:/tmp/cvs-serv18765/src/com/meterware/servletunit Modified Files: ServletUnitClient.java Log Message: Refactored to facilitate multiple window feature Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ServletUnitClient.java 1 Aug 2002 14:58:59 -0000 1.7 +++ ServletUnitClient.java 3 Oct 2002 12:35:18 -0000 1.8 @@ -82,7 +82,7 @@ * servlet invocation unless that invocation results in a redirect request. **/ public WebResponse getResponse( InvocationContext invocation ) throws MalformedURLException,IOException,SAXException { - updateClient( invocation.getServletResponse() ); + updateMainWindow( invocation.getServletResponse() ); return getFrameContents( invocation.getTarget() ); } |
From: Russell G. <rus...@us...> - 2002-10-03 12:35:21
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv18765/src/com/meterware/httpunit Modified Files: WebClient.java WebForm.java Added Files: FormParameter.java WebWindow.java Log Message: Refactored to facilitate multiple window feature ***** Error reading new file[Errno 2] No such file or directory: 'FormParameter.java' ***** Error reading new file[Errno 2] No such file or directory: 'WebWindow.java' Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- WebClient.java 1 Oct 2002 16:11:47 -0000 1.32 +++ WebClient.java 3 Oct 2002 12:35:18 -0000 1.33 @@ -21,13 +21,8 @@ *******************************************************************************************************************/ import java.io.IOException; import java.io.OutputStream; - import java.net.HttpURLConnection; import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLStreamHandler; -import java.net.URLConnection; - import java.util.*; import org.xml.sax.SAXException; @@ -46,12 +41,34 @@ abstract public class WebClient { + + /** The current main window. **/ + private WebWindow _mainWindow = new WebWindow( this ); + private ArrayList _openWindows = new ArrayList(); + + + public WebWindow getMainWindow() { + return _mainWindow; + } + + + public void setMainWindow( WebWindow mainWindow ) { + if (!_openWindows.contains( mainWindow )) throw new IllegalArgumentException( "May only select an open window owned by this client" ); + _mainWindow = mainWindow; + } + + + public WebWindow[] getOpenWindows() { + return (WebWindow[]) _openWindows.toArray( new WebWindow[ _openWindows.size() ] ); + } + + /** * Submits a GET method request and returns a response. * @exception SAXException thrown if there is an error parsing the retrieved page **/ public WebResponse getResponse( String urlString ) throws MalformedURLException, IOException, SAXException { - return getResponse( new GetMethodWebRequest( urlString ) ); + return _mainWindow.getResponse( urlString ); } @@ -59,15 +76,15 @@ * Submits a web request and returns a response. This is an alternate name for the getResponse method. */ public WebResponse sendRequest( WebRequest request ) throws MalformedURLException, IOException, SAXException { - return getResponse( request ); + return _mainWindow.sendRequest( request ); } /** - * Returns the response representing the current main page. + * Returns the response representing the current top page in the main window. */ public WebResponse getCurrentPage() { - return getFrameContents( WebRequest.TOP_FRAME ); + return _mainWindow.getCurrentPage(); } @@ -77,15 +94,24 @@ * @exception SAXException thrown if there is an error parsing the retrieved page **/ public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException { - tellListeners( request ); + return _mainWindow.getResponse( request ); + } - WebResponse response = getResource( request ); - if (response != null) { - tellListeners( response ); - updateClient( response ); - } - return getFrameContents( request.getTarget() ); + /** + * Returns the name of the currently active frames in the main window. + **/ + public String[] getFrameNames() { + return _mainWindow.getFrameNames(); + } + + + /** + * Returns the response associated with the specified frame name in the main window. + * Throws a runtime exception if no matching frame is defined. + **/ + public WebResponse getFrameContents( String frameName ) { + return _mainWindow.getFrameContents( frameName ); } @@ -94,6 +120,19 @@ * May return null if the resource is a JavaScript URL which would normally leave the client unchanged. */ public WebResponse getResource( WebRequest request ) throws IOException { + return getResourceForWindow( request, _mainWindow ); + } + + + WebResponse getResourceForWindow( WebRequest request, WebWindow window ) throws IOException { + tellListeners( request ); + WebResponse response = getResource( request, window ); + if (response != null) tellListeners( response ); + return response; + } + + + private WebResponse getResource( WebRequest request, final WebWindow window ) throws IOException { String urlString = request.getURLString().trim(); if (urlString.startsWith( "about:" )) { return WebResponse.BLANK_RESPONSE; @@ -101,7 +140,7 @@ return newResponse( request ); } else { WebRequestSource wrs = request.getWebRequestSource(); - String result = (wrs == null) ? getCurrentPage().getScriptableObject().evaluateURL( urlString ) + String result = (wrs == null) ? window.getCurrentPage().getScriptableObject().evaluateURL( urlString ) : wrs.getScriptableDelegate().evaluateURL( urlString ); if (result == null) return null; @@ -141,33 +180,13 @@ * any listeners or preferences which may have been set. **/ public void clearContents() { - _frameContents = new FrameHolder( this, WebRequest.TOP_FRAME ); + _mainWindow = new WebWindow( this ); _cookies = new Hashtable(); _headers = new HeaderDictionary(); } /** - * Returns the name of the currently active frames. - **/ - public String[] getFrameNames() { - final List names = _frameContents.getActiveFrameNames(); - return (String[]) names.toArray( new String[ names.size() ] ); - } - - - /** - * Returns the response associated with the specified frame name. - * Throws a runtime exception if no matching frame is defined. - **/ - public WebResponse getFrameContents( String frameName ) { - WebResponse response = (WebResponse) _frameContents.get( frameName ); - if (response == null) throw new NoSuchFrameException( frameName ); - return response; - } - - - /** * Defines a cookie to be sent to the server on every request. **/ public void addCookie( String name, String value ) { @@ -316,12 +335,7 @@ if (HttpUnitOptions.isAcceptGzip()) { setHeaderField( "Accept-Encoding", "gzip" ); } - - try { - _frameContents.updateFrames( new DefaultWebResponse( this, null, WebResponse.BLANK_HTML ) ); - } catch (IOException e) { - } catch (SAXException e) { - } + _openWindows.add( _mainWindow ); } @@ -373,25 +387,14 @@ * cookies and frames. **/ final - protected void updateClient( WebResponse response ) throws MalformedURLException, IOException, SAXException { - updateCookies( response ); - validateHeaders( response ); - if (HttpUnitOptions.getAutoRefresh() && response.getRefreshRequest() != null) { - getResponse( response.getRefreshRequest() ); - } else if (shouldFollowRedirect( response )) { - delay( HttpUnitOptions.getRedirectDelay() ); - getResponse( new RedirectWebRequest( response ) ); - } else { - _frameContents.updateFrames( response ); - } + protected void updateMainWindow( WebResponse response ) throws MalformedURLException, IOException, SAXException { + _mainWindow.updateWindow( response ); } - private boolean shouldFollowRedirect( WebResponse response ) { - return HttpUnitOptions.getAutoRedirect() - && response.getResponseCode() >= HttpURLConnection.HTTP_MOVED_PERM - && response.getResponseCode() <= HttpURLConnection.HTTP_MOVED_TEMP - && response.getHeaderField( "Location" ) != null; + void updateClient( WebResponse response ) throws IOException { + updateCookies( response ); + validateHeaders( response ); } @@ -421,10 +424,6 @@ private Hashtable _cookies = new Hashtable(); - /** A map of frame names to current contents. **/ - private FrameHolder _frameContents = new FrameHolder( this, WebRequest.TOP_FRAME ); - - /** A map of header names to values. **/ private HeaderDictionary _headers = new HeaderDictionary(); @@ -464,19 +463,6 @@ String[] names = response.getNewCookieNames(); for (int i = 0; i < names.length; i++) { addCookie( names[i], response.getNewCookieValue( names[i] ) ); - } - } - - - /** - * Delays the specified amount of time. - **/ - private void delay( int numMilliseconds ) { - if (numMilliseconds == 0) return; - try { - Thread.sleep( numMilliseconds ); - } catch (InterruptedException e) { - // ignore the exception } } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- WebForm.java 2 Oct 2002 13:57:55 -0000 1.65 +++ WebForm.java 3 Oct 2002 12:35:18 -0000 1.66 @@ -686,236 +686,175 @@ } } -} +//===========================---===== exception class NoSuchParameterException ========================================= + /** + * This exception is thrown on an attempt to set a parameter to a value not permitted to it by the form. + **/ + class NoSuchParameterException extends IllegalRequestParameterException { -//========================================== class PresetFormParameter ================================================= - - class PresetFormParameter extends FormControl { - - PresetFormParameter( String name, String value ) { - _name = name; - _value = value; + NoSuchParameterException( String parameterName ) { + _parameterName = parameterName; } - /** - * Returns the name of this control.. - **/ - public String getName() { - return _name; + public String getMessage() { + return "No parameter named '" + _parameterName + "' is defined in the form"; } - /** - * Returns true if this control is read-only. - **/ - public boolean isReadOnly() { - return true; - } - + private String _parameterName; - /** - * Returns true if this control accepts free-form text. - **/ - public boolean isTextControl() { - return true; - } + } - /** - * Remove any required values for this control from the list, throwing an exception if they are missing. - **/ - void claimRequiredValues( List values ) { - if (_value != null) claimValueIsRequired( values, _value ); - } +//============================= exception class IllegalUnnamedSubmitButtonException ====================================== - /** - * Returns the current value(s) associated with this control. These values will be transmitted to the server - * if the control is 'successful'. - **/ - public String[] getValues() { - if (_values == null) _values = new String[] { _value }; - return _values; - } + /** + * This exception is thrown on an attempt to define a form request with a button not defined on that form. + **/ + class IllegalUnnamedSubmitButtonException extends IllegalRequestParameterException { - void addValues( ParameterProcessor processor, String characterSet ) throws IOException { - processor.addParameter( _name, _value, characterSet ); + IllegalUnnamedSubmitButtonException() { } - private String _name; - private String _value; - private String[] _values; - } - - -//===========================---===== exception class NoSuchParameterException ========================================= - - -/** - * This exception is thrown on an attempt to set a parameter to a value not permitted to it by the form. - **/ -class NoSuchParameterException extends IllegalRequestParameterException { - + public String getMessage() { + return "This form has more than one submit button, none unnamed. You must specify the button to be used."; + } - NoSuchParameterException( String parameterName ) { - _parameterName = parameterName; } - public String getMessage() { - return "No parameter named '" + _parameterName + "' is defined in the form"; - } +//============================= exception class IllegalSubmitButtonException ====================================== - private String _parameterName; + /** + * 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 ) { + _name = button.getName(); + _value = button.getValue(); + } -//============================= exception class UnusedParameterValueException ====================================== + IllegalSubmitButtonException( String name, String value ) { + _name = name; + _value = value; + } -/** - * This exception is thrown on an attempt to set a parameter to a value not permitted to it by the form. - **/ -class UnusedParameterValueException extends IllegalRequestParameterException { + public String getMessage() { + return "Specified submit button (name=\"" + _name + "\" value=\"" + _value + "\") not part of this form."; + } - UnusedParameterValueException( String parameterName, String badValue ) { - _parameterName = parameterName; - _badValue = badValue; - } + private String _name; + private String _value; - public String getMessage() { - StringBuffer sb = new StringBuffer(HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE); - sb.append( "Attempted to assign to parameter '" ).append( _parameterName ); - sb.append( "' the extraneous value '" ).append( _badValue ).append( "'." ); - return sb.toString(); } +//============================= exception class IllegalUnnamedSubmitButtonException ====================================== - private String _parameterName; - private String _badValue; -} - - -//============================= exception class UnusedUploadFileException ====================================== - - -/** - * This exception is thrown on an attempt to upload more files than permitted by the form. - **/ -class UnusedUploadFileException extends IllegalRequestParameterException { + /** + * This exception is thrown on an attempt to define a form request with a button not defined on that form. + **/ + class DisabledSubmitButtonException extends IllegalRequestParameterException { - UnusedUploadFileException( String parameterName, int numFilesExpected, int numFilesSupplied ) { - _parameterName = parameterName; - _numExpected = numFilesExpected; - _numSupplied = numFilesSupplied; - } - - public String getMessage() { - StringBuffer sb = new StringBuffer( HttpUnitUtils.DEFAULT_TEXT_BUFFER_SIZE ); - sb.append( "Attempted to upload " ).append( _numSupplied ).append( " files using parameter '" ).append( _parameterName ); - if (_numExpected == 0) { - sb.append( "' which is not a file parameter." ); - } else { - sb.append( "' which only has room for " ).append( _numExpected ).append( '.' ); + DisabledSubmitButtonException( SubmitButton button ) { + _name = button.getName(); + _value = button.getValue(); } - return sb.toString(); - } - private String _parameterName; - private int _numExpected; - private int _numSupplied; -} - - -//============================= 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 { - + public String getMessage() { + return "The specified button (name='" + _name + "' value='" + _value + + "' is disabled and may not be used to submit this form."; + } - IllegalUnnamedSubmitButtonException() { - } + private String _name; + private String _value; - public String getMessage() { - return "This form has more than one submit button, none unnamed. You must specify the button to be used."; } } -//============================= exception class IllegalSubmitButtonException ====================================== +//========================================== class PresetFormParameter ================================================= -/** - * This exception is thrown on an attempt to define a form request with a button not defined on that form. - **/ -class IllegalSubmitButtonException extends IllegalRequestParameterException { + class PresetFormParameter extends FormControl { - IllegalSubmitButtonException( SubmitButton button ) { - _name = button.getName(); - _value = button.getValue(); - } + PresetFormParameter( String name, String value ) { + _name = name; + _value = value; + } - IllegalSubmitButtonException( String name, String value ) { - _name = name; - _value = value; - } + /** + * Returns the name of this control.. + **/ + public String getName() { + return _name; + } - public String getMessage() { - return "Specified submit button (name=\"" + _name + "\" value=\"" + _value + "\") not part of this form."; - } + /** + * Returns true if this control is read-only. + **/ + public boolean isReadOnly() { + return true; + } - private String _name; - private String _value; + /** + * Returns true if this control accepts free-form text. + **/ + public boolean isTextControl() { + return true; + } -} -//============================= exception class IllegalUnnamedSubmitButtonException ====================================== + /** + * Remove any required values for this control from the list, throwing an exception if they are missing. + **/ + void claimRequiredValues( List values ) { + if (_value != null) claimValueIsRequired( values, _value ); + } -/** - * This exception is thrown on an attempt to define a form request with a button not defined on that form. - **/ -class DisabledSubmitButtonException extends IllegalRequestParameterException { + /** + * Returns the current value(s) associated with this control. These values will be transmitted to the server + * if the control is 'successful'. + **/ + public String[] getValues() { + if (_values == null) _values = new String[] { _value }; + return _values; + } - DisabledSubmitButtonException( SubmitButton button ) { - _name = button.getName(); - _value = button.getValue(); - } + void addValues( ParameterProcessor processor, String characterSet ) throws IOException { + processor.addParameter( _name, _value, characterSet ); + } - 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; + private String[] _values; } - private String _name; - private String _value; - -} |
From: Russell G. <rus...@us...> - 2002-10-02 16:37:59
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv13498/test/com/meterware/httpunit Modified Files: WebFormTest.java Log Message: Unrecognized <input> types are treated as text boxes Index: WebFormTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFormTest.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- WebFormTest.java 15 Aug 2002 00:06:32 -0000 1.25 +++ WebFormTest.java 2 Oct 2002 16:37:56 -0000 1.26 @@ -149,13 +149,14 @@ "Enter the name 'master': <textarea Name=name>Something</textarea></B>" + "<input type=\"checkbox\" name=first>Disabled" + "<input type=\"checkbox\" name=second checked>Enabled" + + "<input type=textbox name=third value=something>" + "<br><Input type=submit value = \"Log in\">" + "</form>" ); WebForm form = _wc.getResponse( getHostPath() + "/AForm.html" ).getForms()[0]; String[] parameters = form.getParameterNames(); assertNotNull( parameters ); - assertMatchingSet( "form parameter names", new String[] { "first", "name", "second" }, parameters ); + assertMatchingSet( "form parameter names", new String[] { "first", "name", "second", "third" }, parameters ); assertNull( "First checkbox has a non-null value", form.getParameterValue( "first" ) ); assertEquals( "Second checkbox", "on", form.getParameterValue( "second" ) ); @@ -163,6 +164,9 @@ assertTrue( "Did not find parameter 'first'", form.hasParameterNamed( "first" ) ); assertTrue( "Did not find parameter with prefix 'sec'", form.hasParameterStartingWithPrefix( "sec" ) ); assertTrue( "Did not find parameter with prefix 'nam'", form.hasParameterStartingWithPrefix( "nam" ) ); + + assertTrue( "Did not find parameter named 'third'", form.hasParameterNamed( "third" ) ); + assertEquals( "Value of parameter with unknown type", "something", form.getParameterValue( "third" ) ); assertEquals( "Original text area value", "Something", form.getParameterValue( "name" ) ); form.setParameter( "name", "Something Else" ); |
From: Russell G. <rus...@us...> - 2002-10-02 16:37:59
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv13498/doc Modified Files: release_notes.txt Log Message: Unrecognized <input> types are treated as text boxes Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.172 retrieving revision 1.173 diff -u -r1.172 -r1.173 --- release_notes.txt 2 Oct 2002 14:50:39 -0000 1.172 +++ release_notes.txt 2 Oct 2002 16:37:55 -0000 1.173 @@ -21,6 +21,8 @@ particular form parameter. Note that if multiple controls exist with the same name, these methods only return true when all such controls are read-only or disabled, as appropriate. 2. RFE #585495 ServletUnit now supports HttpServletResponse.setContentLength. + 3. RFE #614397 <input> parameters with unrecognized type fields are now treated as text fields. This appears + to match the behavior in most browsers. 2-Oct-2002 1.4.6 Acknowledgements: |
From: Russell G. <rus...@us...> - 2002-10-02 16:37:59
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv13498/src/com/meterware/httpunit Modified Files: FormControl.java Log Message: Unrecognized <input> types are treated as text boxes Index: FormControl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- FormControl.java 1 Oct 2002 18:05:10 -0000 1.26 +++ FormControl.java 2 Oct 2002 16:37:56 -0000 1.27 @@ -296,7 +296,7 @@ } else if (type.equalsIgnoreCase( "file" )) { return new FileSubmitFormControl( node ); } else { - return null; + return new TextFieldFormControl( node ); } } } |