httpunit-commit Mailing List for httpunit (Page 54)
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-08-30 18:17:51
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv5119/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
Added support for location property
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ScriptingTest.java 30 Aug 2002 15:20:09 -0000 1.18
+++ ScriptingTest.java 30 Aug 2002 18:17:48 -0000 1.19
@@ -178,6 +178,28 @@
}
+ public void testLocationProperty() throws Exception {
+ defineResource( "Target.html", "You made it!" );
+ defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
+ "<body onLoad='alert(\"Window location is \" + window.location);alert(\"Document location is \" + document.location)'>" +
+ "<a href='#' onMouseOver=\"window.location='" + getHostPath() + "/Target.html';\">go</a>" +
+ "<a href='#' onMouseOver=\"document.location='" + getHostPath() + "/Target.html';\">go</a>" +
+ "</body>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "Alert message", "Window location is " + getHostPath() + "/OnCommand.html", wc.popNextAlert() );
+ assertEquals( "Alert message", "Document location is " + getHostPath() + "/OnCommand.html", wc.popNextAlert() );
+ response.getLinks()[0].mouseOver();
+ assertEquals( "2nd page URL", getHostPath() + "/Target.html", wc.getCurrentPage().getURL().toExternalForm() );
+ assertEquals( "2nd page", "You made it!", wc.getCurrentPage().getText() );
+
+ response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ response.getLinks()[1].mouseOver();
+ assertEquals( "3rd page URL", getHostPath() + "/Target.html", wc.getCurrentPage().getURL().toExternalForm() );
+ assertEquals( "3rd page", "You made it!", wc.getCurrentPage().getText() );
+ }
+
+
public void testDocumentFindForms() throws Exception {
defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
"function getFound( object ) {" +
|
|
From: Russell G. <rus...@us...> - 2002-08-30 18:17:51
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv5119/src/com/meterware/httpunit
Modified Files:
HTMLPage.java WebResponse.java
Log Message:
Added support for location property
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HTMLPage.java 30 Aug 2002 15:20:08 -0000 1.7
+++ HTMLPage.java 30 Aug 2002 18:17:48 -0000 1.8
@@ -157,8 +157,25 @@
WebImage wi = getImageWithName( propertyName );
if (wi != null) return wi.getScriptableObject();
- return super.get( propertyName );
+ if (propertyName.equalsIgnoreCase( "location" )) {
+ return getResponse().getScriptableObject().get( "location" );
+ } else {
+ return super.get( propertyName );
+ }
}
+
+
+ /**
+ * Sets the value of the named property. Will throw a runtime exception if the property does not exist or
+ * cannot accept the specified value.
+ **/
+ public void set( String propertyName, Object value ) {
+ if (propertyName.equalsIgnoreCase( "location" )) {
+ getResponse().getScriptableObject().set( "location", value );
+ } else {
+ super.set( propertyName, value );
+ }
+ }
public String getTitle() throws SAXException {
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- WebResponse.java 23 Aug 2002 19:33:13 -0000 1.77
+++ WebResponse.java 30 Aug 2002 18:17:48 -0000 1.78
@@ -534,6 +534,37 @@
runScript( getReceivedPage().getScripts() );
doEvent( getReceivedPage().getOnLoadEvent() );
}
+
+
+ /**
+ * Returns the value of the named property. Will return null if the property does not exist.
+ **/
+ public Object get( String propertyName ) {
+ if (propertyName.equalsIgnoreCase( "location" )) {
+ return WebResponse.this._url.toExternalForm();
+ } else {
+ return super.get( propertyName );
+ }
+ }
+
+
+ /**
+ * Sets the value of the named property. Will throw a runtime exception if the property does not exist or
+ * cannot accept the specified value.
+ **/
+ public void set( String propertyName, Object value ) {
+ if (propertyName.equalsIgnoreCase( "location" )) {
+ try {
+ getClient().getResponse( new GetMethodWebRequest( _url, value.toString(), _frameName ) );
+ } catch (IOException e) {
+ throw new RuntimeException( "Error handling 'location=': " + e );
+ } catch (SAXException e) {
+ throw new RuntimeException( "Error handling 'location=': " + e );
+ }
+ } else {
+ super.set( propertyName, value );
+ }
+ }
}
|
|
From: Russell G. <rus...@us...> - 2002-08-30 15:20:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv9438/src/com/meterware/httpunit
Modified Files:
HTMLPage.java HttpUnitOptions.java ParsedHTML.java
WebClient.java
Log Message:
Added support for JavaScript includes
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HTMLPage.java 8 Aug 2002 20:47:21 -0000 1.6
+++ HTMLPage.java 30 Aug 2002 15:20:08 -0000 1.7
@@ -23,6 +23,7 @@
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -77,7 +78,22 @@
*/
public String getScripts() throws SAXException {
NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName( "script" );
- return NodeUtils.asText( nl );
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node scriptNode = nl.item(i);
+ String src = NodeUtils.getNodeAttribute( scriptNode, "src", null );
+ if (src == null) {
+ sb.append( NodeUtils.asText( scriptNode.getChildNodes() ) );
+ } else {
+ try {
+ WebRequest req = new GetMethodWebRequest( getBaseURL(), src );
+ sb.append( getResponse().getClient().getResource( req ).getText() );
+ } catch (IOException e) {
+ throw new RuntimeException( "Error loading included script: " + e );
+ }
+ }
+ }
+ return sb.toString();
}
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- HttpUnitOptions.java 29 Aug 2002 15:32:44 -0000 1.25
+++ HttpUnitOptions.java 30 Aug 2002 15:20:09 -0000 1.26
@@ -222,8 +222,8 @@
/**
* If true, tells HttpUnit to throw an exception on any attempt to set a form parameter to a value
- * which could not be set via the browser. The default is true (parameters are validated).
- * Note: this only applies to a WebRequest created after this setting is changed. A request created
+ * which could not be set via the browser. The default is true (parameters are validated).<br>
+ * <b>Note:</b> this only applies to a WebRequest created after this setting is changed. A request created
* with this option disabled will not only not be checked for correctness, its parameter submission
* order will not be guaranteed, and changing parameters will not trigger Javascript onChange / onClick events.
**/
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ParsedHTML.java 29 Aug 2002 15:32:44 -0000 1.26
+++ ParsedHTML.java 30 Aug 2002 15:20:09 -0000 1.27
@@ -347,6 +347,11 @@
}
+ WebResponse getResponse() {
+ return _response;
+ }
+
+
interface TablePredicate {
public boolean isTrue( WebTable table );
}
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WebClient.java 23 Aug 2002 19:33:12 -0000 1.28
+++ WebClient.java 30 Aug 2002 15:20:09 -0000 1.29
@@ -79,7 +79,7 @@
public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException {
tellListeners( request );
- WebResponse response = getNextPage( request );
+ WebResponse response = getResource( request );
if (response != null) {
tellListeners( response );
updateClient( response );
@@ -90,9 +90,10 @@
/**
- * Evaluates the request and returns the desired page. Will return null if the current target is to be unaffected.
+ * 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.
*/
- private WebResponse getNextPage( WebRequest request ) throws IOException {
+ public WebResponse getResource( WebRequest request ) throws IOException {
String urlString = request.getURLString().trim();
if (urlString.startsWith( "about:" )) {
return WebResponse.BLANK_RESPONSE;
|
|
From: Russell G. <rus...@us...> - 2002-08-30 15:20:12
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv9438/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
Added support for JavaScript includes
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ScriptingTest.java 23 Aug 2002 19:33:13 -0000 1.17
+++ ScriptingTest.java 30 Aug 2002 15:20:09 -0000 1.18
@@ -158,6 +158,17 @@
}
+ public void testIncludedFunction() throws Exception {
+ defineResource( "saycheese.js", "function sayCheese() { alert( \"Cheese!\" ); }" );
+ defineResource( "OnCommand.html", "<html><head><script language='JavaScript' src='saycheese.js'>" +
+ "</script></head>" +
+ "<body onLoad='sayCheese()'></body>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "Alert message", "Cheese!", wc.popNextAlert() );
+ }
+
+
public void testDocumentTitle() throws Exception {
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
"<body onLoad='alert(\"Window title is \" + document.title)'></body>" );
|
|
From: Russell G. <rus...@us...> - 2002-08-30 15:20:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv9438/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java JavaScriptEngineFactory.java
Log Message:
Added support for JavaScript includes
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- JavaScript.java 27 Aug 2002 16:26:04 -0000 1.17
+++ JavaScript.java 30 Aug 2002 15:20:09 -0000 1.18
@@ -88,6 +88,8 @@
Context.getCurrentContext().evaluateString( this, script, "httpunit", 0, null );
} catch (JavaScriptException e) {
throw new RuntimeException( "Script '" + script + "' failed: " + e );
+ } catch (EcmaError e) {
+ throw new RuntimeException( "Syntax Error at line " + e.getLineNumber() + ": " + e.getLineSource() );
}
}
Index: JavaScriptEngineFactory.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScriptEngineFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JavaScriptEngineFactory.java 20 Aug 2002 15:09:28 -0000 1.4
+++ JavaScriptEngineFactory.java 30 Aug 2002 15:20:09 -0000 1.5
@@ -44,6 +44,7 @@
try {
JavaScript.run( response );
} catch (Exception e) {
+ e.printStackTrace();
throw new RuntimeException( e.toString() );
}
}
|
|
From: Russell G. <rus...@us...> - 2002-08-30 15:20:11
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv9438/doc
Modified Files:
release_notes.txt
Log Message:
Added support for JavaScript includes
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -r1.152 -r1.153
--- release_notes.txt 29 Aug 2002 20:51:02 -0000 1.152
+++ release_notes.txt 30 Aug 2002 15:20:07 -0000 1.153
@@ -11,8 +11,12 @@
Revision History:
+30-Aug-2002
+Additions:
+ 1. Added support for included scripts using <script src=...>
+
29-Aug-2002
-Acknolwedgements:
+Acknowledgements:
Thanks to Geert Bevin for implementing ServletUnit support for HttpServletRequest.getParameterMap
Additions:
|
|
From: Russell G. <rus...@us...> - 2002-08-29 20:51:18
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv29952/doc
Modified Files:
release_notes.txt
Log Message:
WebRequest.getRequestParameterNames now only lists sent parameter names
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -r1.151 -r1.152
--- release_notes.txt 29 Aug 2002 18:39:11 -0000 1.151
+++ release_notes.txt 29 Aug 2002 20:51:02 -0000 1.152
@@ -21,6 +21,7 @@
Problems fixed:
1. Submitting a request created with parameter validation disabled would send disabled parameters as well as enabled ones.
+ 2. WebRequest.getRequestParameterNames now returns only the names of the parameters that will be submitted with the request.
27-Aug-2002
Additions:
|
|
From: Russell G. <rus...@us...> - 2002-08-29 20:51:18
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv29952/src/com/meterware/httpunit
Modified Files:
WebRequest.java
Log Message:
WebRequest.getRequestParameterNames now only lists sent parameter names
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- WebRequest.java 23 Aug 2002 19:33:13 -0000 1.45
+++ WebRequest.java 29 Aug 2002 20:51:02 -0000 1.46
@@ -40,6 +40,8 @@
import java.util.Hashtable;
import java.util.Vector;
import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.HashSet;
/**
* A request sent to a web server.
@@ -186,7 +188,7 @@
/**
- * Returns an enumeration of all parameters in this web request.
+ * Returns an enumeration of all parameters in this web request. May include some parameters that will not be sent.
* @deprecated use getRequestParameterNames instead
**/
public Enumeration getParameterNames() {
@@ -195,11 +197,26 @@
/**
- * Returns an array of all parameter names in this web request.
+ * Returns an array of all parameter names defined as part of this web request.
* @since 1.3.1
**/
public String[] getRequestParameterNames() {
- return _parameterHolder.getParameterNames();
+ final HashSet names = new HashSet();
+ ParameterProcessor pp = new ParameterProcessor() {
+ public void addParameter( String name, String value, String characterSet ) throws IOException {
+ names.add( name );
+ }
+ public void addFile( String parameterName, UploadFileSpec fileSpec ) throws IOException {
+ names.add( parameterName );
+ }
+ };
+
+ try {
+ _parameterHolder.recordPredefinedParameters( pp );
+ _parameterHolder.recordParameters( pp );
+ } catch (IOException e) {}
+
+ return (String[]) names.toArray( new String[ names.size() ] );
}
|
|
From: Russell G. <rus...@us...> - 2002-08-29 20:51:18
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv29952/test/com/meterware/httpunit
Modified Files:
FormSubmitTest.java
Log Message:
WebRequest.getRequestParameterNames now only lists sent parameter names
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- FormSubmitTest.java 29 Aug 2002 18:39:11 -0000 1.24
+++ FormSubmitTest.java 29 Aug 2002 20:51:02 -0000 1.25
@@ -148,13 +148,15 @@
public void testSubmitButtonDetection() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age value=12>" +
- "<Input type=submit name=update>" +
- "<Input type=submit name=recalculate>" +
+ "<Input type=submit name=update value=update>" +
+ "<Input type=submit name=recalculate value=value>" +
"</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 );
+ assertMatchingSet( "selected request parameters", new String[]{"age","update"},
+ form.getRequest( "update" ).getRequestParameterNames() );
}
|
|
From: Russell G. <rus...@us...> - 2002-08-29 18:39:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv17008/src/com/meterware/httpunit
Modified Files:
HttpUnitUtils.java UncheckedParameterHolder.java
Log Message:
Only preload unvalidated requests with active parameters
Index: HttpUnitUtils.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitUtils.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HttpUnitUtils.java 24 Jul 2002 17:28:56 -0000 1.9
+++ HttpUnitUtils.java 29 Aug 2002 18:39:11 -0000 1.10
@@ -117,4 +117,20 @@
}
return result;
}
+
+
+ /**
+ * Returns a string array created by appending an object to an existing array. The existing array may be null.
+ **/
+ static Object[] withNewValue( Object[] oldValue, Object newValue ) {
+ Object[] result;
+ if (oldValue == null) {
+ result = new Object[] { newValue };
+ } else {
+ result = new Object[ oldValue.length+1 ];
+ System.arraycopy( oldValue, 0, result, 0, oldValue.length );
+ result[ oldValue.length ] = newValue;
+ }
+ return result;
+ }
}
Index: UncheckedParameterHolder.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/UncheckedParameterHolder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UncheckedParameterHolder.java 4 Feb 2002 22:33:55 -0000 1.5
+++ UncheckedParameterHolder.java 29 Aug 2002 18:39:11 -0000 1.6
@@ -32,7 +32,7 @@
*
* @author <a href="mailto:rus...@ac...">Russell Gold</a>
**/
-class UncheckedParameterHolder extends ParameterHolder {
+final class UncheckedParameterHolder extends ParameterHolder implements ParameterProcessor {
private static final String[] NO_VALUES = new String[ 0 ];
private final String _characterSet;
@@ -49,15 +49,34 @@
UncheckedParameterHolder( WebRequestSource source ) {
_characterSet = source.getCharacterSet();
_submitAsMime = source.isSubmitAsMime();
- String[] names = source.getParameterNames();
- for (int i = 0; i < names.length; i++) {
- if (!source.isFileParameter( names[i] )) {
- _parameters.put( names[i], source.getParameterValues( names[i] ) );
- }
+
+ try {
+ source.recordPredefinedParameters( this );
+ source.recordParameters( this );
+ } catch (IOException e) {
+ throw new RuntimeException( "This should never happen" );
}
}
+//----------------------------------- ParameterProcessor methods -------------------------------------------------------
+
+
+ public void addParameter( String name, String value, String characterSet ) throws IOException {
+ Object[] values = (Object[]) _parameters.get( name );
+ _parameters.put( name, HttpUnitUtils.withNewValue( values, value ) );
+ }
+
+
+ public void addFile( String parameterName, UploadFileSpec fileSpec ) throws IOException {
+ Object[] values = (Object[]) _parameters.get( parameterName );
+ _parameters.put( parameterName, HttpUnitUtils.withNewValue( values, fileSpec ) );
+ }
+
+
+//----------------------------------- ParameterHolder methods ----------------------------------------------------------
+
+
/**
* Specifies the position at which an image button (if any) was clicked.
**/
@@ -82,15 +101,13 @@
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
- Object value = _parameters.get( name );
- if (value instanceof String) {
- processor.addParameter( name, (String) value, _characterSet );
- } else if (value instanceof String[]) {
- String[] values = (String[]) value;
- for (int i = 0; i < values.length; i++) processor.addParameter( name, values[i], _characterSet );
- } else if (value instanceof UploadFileSpec[]) {
- UploadFileSpec[] files = (UploadFileSpec[]) value;
- for (int i = 0; i < files.length; i++) processor.addFile( name, files[i] );
+ Object[] values = (Object[]) _parameters.get( name );
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] instanceof String) {
+ processor.addParameter( name, (String) values[i], _characterSet );
+ } else if (values[i] instanceof UploadFileSpec) {
+ processor.addFile( name, (UploadFileSpec) values[i] );
+ }
}
}
}
@@ -108,11 +125,14 @@
String[] getParameterValues( String name ) {
- Object result = _parameters.get( name );
- if (result instanceof String) return new String[] { (String) result };
- if (result instanceof String[]) return (String[]) result;
- if (result instanceof UploadFileSpec) return new String[] { result.toString() };
- return NO_VALUES;
+ Object[] values = (Object[]) _parameters.get( name );
+ if (values == null) return NO_VALUES;
+
+ String[] result = new String[ values.length ];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = values[i].toString();
+ }
+ return result;
}
@@ -122,7 +142,7 @@
void setParameter( String name, String value ) {
- _parameters.put( name, value );
+ _parameters.put( name, new Object[] { value } );
}
|
|
From: Russell G. <rus...@us...> - 2002-08-29 18:39:14
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv17008/test/com/meterware/httpunit
Modified Files:
FormSubmitTest.java
Log Message:
Only preload unvalidated requests with active parameters
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- FormSubmitTest.java 29 Aug 2002 15:32:44 -0000 1.23
+++ FormSubmitTest.java 29 Aug 2002 18:39:11 -0000 1.24
@@ -313,6 +313,18 @@
}
+ public void testImageButtonNoValueUncheckedPositionalSubmit() throws Exception {
+ HttpUnitOptions.setParameterValuesValidated( false );
+ defineWebPage( "Default", "<form method='GET' action='test.jsp'>" +
+ "<input type='image' src='image.gif' name='aButton'>" +
+ "</form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getForms()[0];
+ WebRequest request = form.getRequest( form.getSubmitButton( "aButton" ), 20, 5 );
+ assertEqualQueries( getHostPath() + "/test.jsp?aButton.x=20&aButton.y=5", request.getURL().toExternalForm() );
+ }
+
+
public void testSubmitButtonAttributes() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age value=12>" +
|
|
From: Russell G. <rus...@us...> - 2002-08-29 18:39:14
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv17008/doc
Modified Files:
release_notes.txt
Log Message:
Only preload unvalidated requests with active parameters
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- release_notes.txt 29 Aug 2002 15:32:44 -0000 1.150
+++ release_notes.txt 29 Aug 2002 18:39:11 -0000 1.151
@@ -19,6 +19,9 @@
1. ServletUnit now supports HttpServletRequest.getParameterMap
2. WebImage now supports getRequest() to return a request for retrieving the image
+Problems fixed:
+ 1. Submitting a request created with parameter validation disabled would send disabled parameters as well as enabled ones.
+
27-Aug-2002
Additions:
1. Reset buttons may now be clicked to reset the form
|
|
From: Russell G. <rus...@us...> - 2002-08-29 18:39:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver
In directory usw-pr-cvs1:/tmp/cvs-serv17008/src/com/meterware/pseudoserver
Modified Files:
HttpUserAgentTest.java
Log Message:
Only preload unvalidated requests with active parameters
Index: HttpUserAgentTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpUserAgentTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpUserAgentTest.java 24 Jul 2002 17:28:56 -0000 1.1
+++ HttpUserAgentTest.java 29 Aug 2002 18:39:11 -0000 1.2
@@ -20,6 +20,8 @@
*
*******************************************************************************************************************/
import java.util.Vector;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
import junit.framework.TestCase;
@@ -92,6 +94,12 @@
}
+ protected void assertEqualQueries( String query1, String query2 ) {
+ assertEquals( new QuerySpec( query1 ), new QuerySpec( query2 ) );
+ }
+
+
+
protected void assertEquals( String comment, Object[] expected, Object[] found ) {
if (!equals( expected, found )) {
fail( comment + " expected: " + asText( expected ) + " but found " + asText( found ) );
@@ -172,4 +180,44 @@
return sb.toString();
}
+ static class QuerySpec {
+ QuerySpec( String urlString ) {
+ if (urlString.indexOf( '?' ) < 0) {
+ _path = urlString;
+ } else {
+ _path = urlString.substring( 0, urlString.indexOf( '?' ) );
+ }
+ _fullString = urlString;
+
+ StringTokenizer st = new StringTokenizer( urlString.substring( urlString.indexOf( '?' )+ 1 ), "&" );
+ while (st.hasMoreTokens()) _parameters.addElement( st.nextToken() );
+ }
+
+ public String toString() {
+ return _fullString;
+ }
+
+ public boolean equals( Object o ) {
+ return getClass().equals( o.getClass() ) && equals( (QuerySpec) o );
+ }
+
+ private String _path;
+ private String _fullString;
+ private Vector _parameters = new Vector();
+
+ private boolean equals( QuerySpec o ) {
+ if (!_path.equals( o._path )) {
+ return false;
+ } else if (_parameters.size() != o._parameters.size() ) {
+ return false;
+ } else {
+ for (Enumeration e = o._parameters.elements(); e.hasMoreElements();) {
+ if (!_parameters.contains( e.nextElement() )) return false;
+ }
+ return true;
+ }
+ }
+ }
}
+
+
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv19200/src/com/meterware/httpunit
Modified Files:
GetMethodWebRequest.java HttpUnitOptions.java ParsedHTML.java
WebImage.java WebLink.java
Added Files:
FixedURLWebRequestSource.java
Log Message:
Added WebImage.getRequest
***** Error reading new file[Errno 2] No such file or directory: 'FixedURLWebRequestSource.java'
Index: GetMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/GetMethodWebRequest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- GetMethodWebRequest.java 19 Aug 2002 18:52:26 -0000 1.15
+++ GetMethodWebRequest.java 29 Aug 2002 15:32:44 -0000 1.16
@@ -95,9 +95,9 @@
/**
- * Constructs a web request for a link.
+ * Constructs a web request for a link or image.
**/
- GetMethodWebRequest( WebLink sourceLink ) {
+ GetMethodWebRequest( FixedURLWebRequestSource sourceLink ) {
super( sourceLink );
}
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- HttpUnitOptions.java 20 Aug 2002 15:09:28 -0000 1.24
+++ HttpUnitOptions.java 29 Aug 2002 15:32:44 -0000 1.25
@@ -223,6 +223,9 @@
/**
* If true, tells HttpUnit to throw an exception on any attempt to set a form parameter to a value
* which could not be set via the browser. The default is true (parameters are validated).
+ * Note: this only applies to a WebRequest created after this setting is changed. A request created
+ * with this option disabled will not only not be checked for correctness, its parameter submission
+ * order will not be guaranteed, and changing parameters will not trigger Javascript onChange / onClick events.
**/
public static void setParameterValuesValidated( boolean validated ) {
_parameterValuesValidated = validated;
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ParsedHTML.java 22 Aug 2002 16:19:54 -0000 1.25
+++ ParsedHTML.java 29 Aug 2002 15:32:44 -0000 1.26
@@ -177,7 +177,7 @@
_images = new WebImage[ images.getLength() ];
for (int i = 0; i < _images.length; i++) {
- _images[i] = new WebImage( this, _baseURL, images.item( i ) );
+ _images[i] = new WebImage( _response, this, _baseURL, images.item( i ), _baseTarget );
}
}
return _images;
Index: WebImage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebImage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WebImage.java 22 Aug 2002 16:19:54 -0000 1.4
+++ WebImage.java 29 Aug 2002 15:32:44 -0000 1.5
@@ -30,7 +30,7 @@
*
* @author <a href="mailto:rus...@ac...">Russell Gold</a>
**/
-public class WebImage {
+public class WebImage extends FixedURLWebRequestSource {
private URL _baseURL;
private Node _node;
@@ -40,7 +40,8 @@
private String _alt;
- WebImage( ParsedHTML parsedHTML, URL baseURL, Node node ) {
+ WebImage( WebResponse response, ParsedHTML parsedHTML, URL baseURL, Node node, String parentTarget ) {
+ super( response, node, baseURL, NodeUtils.getNodeAttribute( node, "src" ), parentTarget );
_baseURL = baseURL;
_node = node;
_parsedHTML = parsedHTML;
@@ -107,4 +108,14 @@
}
+//---------------------------------- WebRequestSource methods ------------------------------------------
+
+
+ /**
+ * Returns the scriptable delegate.
+ */
+
+ ScriptableDelegate getScriptableDelegate() {
+ return getScriptableObject();
+ }
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WebLink.java 23 Aug 2002 19:33:13 -0000 1.25
+++ WebLink.java 29 Aug 2002 15:32:44 -0000 1.26
@@ -21,17 +21,9 @@
*******************************************************************************************************************/
import com.meterware.httpunit.scripting.ScriptableDelegate;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.List;
-import java.util.Arrays;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
@@ -44,7 +36,7 @@
* @author <a href="mailto:rus...@ac...">Russell Gold</a>
* @author <a href="mailto:ben...@av...>Benoit Xhenseval</a>
**/
-public class WebLink extends WebRequestSource {
+public class WebLink extends FixedURLWebRequestSource {
private Scriptable _scriptable;
@@ -96,141 +88,6 @@
}
-//----------------------------------------- WebRequestSource methods ---------------------------------------------------
-
-
- /**
- * Creates and returns a web request which will simulate clicking on this link.
- **/
- public WebRequest getRequest() {
- return new GetMethodWebRequest( this );
- }
-
-
- /**
- * Returns the scriptable delegate.
- */
- ScriptableDelegate getScriptableDelegate() {
- return getScriptableObject();
- }
-
-
- /**
- * Returns an array containing the names of any parameters defined as part of this link's URL.
- **/
- public String[] getParameterNames() {
- ArrayList parameterNames = new ArrayList( getPresetParameterMap().keySet() );
- return (String[]) parameterNames.toArray( new String[ parameterNames.size() ] );
- }
-
-
- /**
- * Returns the multiple default values of the named parameter.
- **/
- public String[] getParameterValues( String name ) {
- final String[] values = (String[]) getPresetParameterMap().get( name );
- return values == null ? NO_VALUES : values;
- }
-
-
-//--------------------------------- ParameterHolder methods --------------------------------------
-
-
- /**
- * Specifies the position at which an image button (if any) was clicked.
- **/
- void selectImageButtonPosition( SubmitButton imageButton, int x, int y ) {
- throw new IllegalLinkParametersRequest();
- }
-
-
- /**
- * Iterates through the fixed, predefined parameters in this holder, recording them in the supplied parameter processor.\
- * These parameters always go on the URL, no matter what encoding method is used.
- **/
-
- void recordPredefinedParameters( ParameterProcessor processor ) throws IOException {
- }
-
-
- /**
- * Iterates through the parameters in this holder, recording them in the supplied parameter processor.
- **/
- void recordParameters( ParameterProcessor processor ) throws IOException {
- Iterator i = getPresetParameterList().iterator();
- while (i.hasNext()) {
- LinkParameter o = (LinkParameter) i.next();
- processor.addParameter( o.getName(), o.getValue(), getCharacterSet() );
- }
- }
-
-
- /**
- * Removes a parameter name from this collection.
- **/
- void removeParameter( String name ) {
- throw new IllegalLinkParametersRequest();
- }
-
-
- /**
- * Sets the value of a parameter in a web request.
- **/
- void setParameter( String name, String value ) {
- setParameter( name, new String[] { value } );
- }
-
-
- /**
- * Sets the multiple values of a parameter in a web request.
- **/
- void setParameter( String name, String[] values ) {
- if (values == null) {
- throw new IllegalArgumentException( "May not supply a null argument array to setParameter()" );
- } else if (!getPresetParameterMap().containsKey( name )) {
- throw new IllegalLinkParametersRequest();
- } else if (!equals( getParameterValues( name ), values )) {
- throw new IllegalLinkParametersRequest();
- }
- }
-
-
- private boolean equals( String[] left, String[] right ) {
- if (left.length != right.length) return false;
- List rightValues = Arrays.asList( right );
- for (int i = 0; i < left.length; i++) {
- if (!rightValues.contains( left[i] )) return false;
- }
- return true;
- }
-
-
- /**
- * Sets the multiple values of a file upload parameter in a web request.
- **/
- void setParameter( String name, UploadFileSpec[] files ) {
- throw new IllegalLinkParametersRequest();
- }
-
-
- /**
- * Returns true if the specified parameter is a file field.
- **/
- boolean isFileParameter( String name ) {
- return false;
- }
-
-
- boolean isSubmitAsMime() {
- return false;
- }
-
-
- void setSubmitAsMime( boolean mimeEncoded ) {
- throw new IllegalStateException( "May not change the encoding for a validated request created from a link" );
- }
-
-
public class Scriptable extends ScriptableDelegate {
public Object get( String propertyName ) {
@@ -252,6 +109,17 @@
}
+//----------------------------------------- WebRequestSource methods ---------------------------------------------------
+
+
+ /**
+ * Returns the scriptable delegate.
+ */
+ ScriptableDelegate getScriptableDelegate() {
+ return getScriptableObject();
+ }
+
+
//--------------------------------------------------- package members --------------------------------------------------
@@ -271,75 +139,6 @@
if (_scriptable == null) _scriptable = new Scriptable();
return _scriptable;
}
-
-
-//--------------------------------------------------- private members --------------------------------------------------
-
-
- private static final String[] NO_VALUES = new String[0];
-
- private Map _presetParameterMap;
- private ArrayList _presetParameterList;
-
-
- private Map getPresetParameterMap() {
- if (_presetParameterMap == null) loadPresetParameters();
- return _presetParameterMap;
- }
-
-
- private ArrayList getPresetParameterList() {
- if (_presetParameterList == null) loadPresetParameters();
- return _presetParameterList;
- }
-
-
- private void loadPresetParameters() {
- _presetParameterMap = new HashMap();
- _presetParameterList = new ArrayList();
- loadDestinationParameters();
- }
-
-
- protected void addPresetParameter( String name, String value ) {
- _presetParameterMap.put( name, HttpUnitUtils.withNewValue( (String[]) _presetParameterMap.get( name ), value ) );
- _presetParameterList.add( new LinkParameter( name, value ) );
- }
-
-
-}
-
-
-class LinkParameter {
- private String _name;
- private String _value;
-
-
- public LinkParameter( String name, String value ) {
- _name = name;
- _value = value;
- }
-
-
- public String getName() {
- return _name;
- }
-
-
- public String getValue() {
- return _value;
- }
-}
-
-
-class IllegalLinkParametersRequest extends IllegalRequestParameterException {
-
- public IllegalLinkParametersRequest() {
- }
-
- public String getMessage() {
- return "May not modify parameters for a request derived from a link with parameter checking enabled.";
- }
}
|
|
From: Russell G. <rus...@us...> - 2002-08-29 15:32:47
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv19200/test/com/meterware/httpunit
Modified Files:
FormSubmitTest.java WebImageTest.java
Log Message:
Added WebImage.getRequest
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- FormSubmitTest.java 27 Aug 2002 16:26:05 -0000 1.22
+++ FormSubmitTest.java 29 Aug 2002 15:32:44 -0000 1.23
@@ -367,7 +367,7 @@
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age value=12>" +
"<Input type=submit name=update value=age>" +
- "<Input type=submit name=update value=name>" +
+ "<Button type=submit name=update value=name>" +
"</form>" );
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
WebForm form = page.getForms()[0];
Index: WebImageTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebImageTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebImageTest.java 22 Aug 2002 16:19:54 -0000 1.2
+++ WebImageTest.java 29 Aug 2002 15:32:44 -0000 1.3
@@ -90,4 +90,20 @@
assertEquals( "Link URL", "somewhere.htm", link.getURLString() );
}
+
+ public void testImageRequest() throws Exception {
+ defineResource( "grouped/SimplePage.html",
+ "<html><head><title>A Sample Page</title></head>\n" +
+ "<body><img name='this_one' src='sample.jpg'>\n" +
+ "<IMG SRC='another.png'>" +
+ " and <img src='onemore.gif' alt='one'>\n" +
+ "</body></html>\n" );
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( getHostPath() + "/grouped/SimplePage.html" );
+ WebResponse simplePage = wc.getResponse( request );
+ WebRequest imageRequest = simplePage.getImageWithName( "this_one" ).getRequest();
+ assertEquals( "Image URL", getHostPath() + "/grouped/sample.jpg", imageRequest.getURL().toExternalForm() );
+ }
+
+
}
|
|
From: Russell G. <rus...@us...> - 2002-08-29 15:32:47
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv19200/doc
Modified Files:
release_notes.txt todo.txt
Log Message:
Added WebImage.getRequest
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -r1.149 -r1.150
--- release_notes.txt 28 Aug 2002 15:05:06 -0000 1.149
+++ release_notes.txt 29 Aug 2002 15:32:44 -0000 1.150
@@ -11,12 +11,13 @@
Revision History:
-28-Aug-2002
+29-Aug-2002
Acknolwedgements:
Thanks to Geert Bevin for implementing ServletUnit support for HttpServletRequest.getParameterMap
Additions:
1. ServletUnit now supports HttpServletRequest.getParameterMap
+ 2. WebImage now supports getRequest() to return a request for retrieving the image
27-Aug-2002
Additions:
Index: todo.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- todo.txt 27 Aug 2002 16:26:03 -0000 1.29
+++ todo.txt 29 Aug 2002 15:32:44 -0000 1.30
@@ -8,7 +8,7 @@
o Documentation, Documentation
JavaScript priorities:
-o Document.write
+o Document.write - may required substantial parser rewrite
o Javascript includes
o Navigator object
|
|
From: Russell G. <rus...@us...> - 2002-08-28 15:05:12
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv14949/src/com/meterware/servletunit
Modified Files:
ServletUnitHttpRequest.java
Log Message:
from Geert Bevin: implemented HttpServletRequest.getParameterMap
Index: ServletUnitHttpRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitHttpRequest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ServletUnitHttpRequest.java 22 Aug 2002 20:18:31 -0000 1.14
+++ ServletUnitHttpRequest.java 28 Aug 2002 15:05:07 -0000 1.15
@@ -604,7 +604,7 @@
* @since 1.3
**/
public Map getParameterMap() {
- return null; // XXX implement me!
+ return _parameters;
}
|
|
From: Russell G. <rus...@us...> - 2002-08-28 15:05:12
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv14949/test/com/meterware/servletunit
Modified Files:
HttpServletRequestTest.java
Log Message:
from Geert Bevin: implemented HttpServletRequest.getParameterMap
Index: HttpServletRequestTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/HttpServletRequestTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HttpServletRequestTest.java 19 Jun 2002 13:47:20 -0000 1.7
+++ HttpServletRequestTest.java 28 Aug 2002 15:05:08 -0000 1.8
@@ -21,6 +21,7 @@
*******************************************************************************************************************/
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -84,6 +85,19 @@
assertMatchingSet( "age parameter", new String[] { "12" }, request.getParameterValues( "age" ) );
assertMatchingSet( "color parameter", new String[] { "red", "blue" }, request.getParameterValues( "color" ) );
assertNull( "unset parameter should be null", request.getParameterValues( "unset" ) );
+ }
+
+
+ public void testParameterMap() throws Exception {
+ WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
+ wr.setParameter( "age", "12" );
+ wr.setParameter( "color", new String[] { "red", "blue" } );
+ HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
+
+ Map map = request.getParameterMap();
+ assertMatchingSet( "age parameter", new String[] { "12" }, (Object[]) map.get( "age" ) );
+ assertMatchingSet( "color parameter", new String[] { "red", "blue" }, (Object[]) map.get( "color" ) );
+ assertNull( "unset parameter should be null", map.get( "unset" ) );
}
|
|
From: Russell G. <rus...@us...> - 2002-08-28 15:05:12
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv14949/doc
Modified Files:
release_notes.txt
Log Message:
from Geert Bevin: implemented HttpServletRequest.getParameterMap
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -r1.148 -r1.149
--- release_notes.txt 27 Aug 2002 16:26:02 -0000 1.148
+++ release_notes.txt 28 Aug 2002 15:05:06 -0000 1.149
@@ -11,6 +11,13 @@
Revision History:
+28-Aug-2002
+Acknolwedgements:
+ Thanks to Geert Bevin for implementing ServletUnit support for HttpServletRequest.getParameterMap
+
+Additions:
+ 1. ServletUnit now supports HttpServletRequest.getParameterMap
+
27-Aug-2002
Additions:
1. Reset buttons may now be clicked to reset the form
|
|
From: Russell G. <rus...@us...> - 2002-08-27 16:26:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv9481/test/com/meterware/httpunit/javascript
Modified Files:
FormScriptingTest.java
Log Message:
Added support for reset button and associated JavaScript
Index: FormScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FormScriptingTest.java 23 Aug 2002 19:33:13 -0000 1.6
+++ FormScriptingTest.java 27 Aug 2002 16:26:05 -0000 1.7
@@ -88,6 +88,51 @@
}
+ public void testResetViaScript() throws Exception {
+ defineResource( "OnCommand.html", "<html><head></head>" +
+ "<body>" +
+ "<form name=spectrum action='DoIt'>" +
+ " <input type=text name=color value=green>" +
+ " <input type=text name=change value=color>" +
+ "</form>" +
+ "<a href='#' onClick='document.spectrum.reset(); return false;'>" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+
+ WebForm form = response.getFormWithName( "spectrum" );
+ form.setParameter( "color", "blue" );
+ response.getLinks()[ 0 ].click();
+ assertEquals( "Value after reset", "green", form.getParameterValue( "color" ) );
+ }
+
+
+ public void testOnResetEvent() throws Exception {
+ defineResource( "OnCommand.html", "<html><head></head>" +
+ "<body>" +
+ "<form name=spectrum action='DoIt' onreset='alert( \"Ran the event\" );'>" +
+ " <input type=text name=color value=green>" +
+ " <input type=reset id='clear'>" +
+ "</form>" +
+ "<a href='#' onClick='document.spectrum.reset(); return false;'>" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+
+ WebForm form = response.getFormWithName( "spectrum" );
+
+ form.setParameter( "color", "blue" );
+ form.getButtonWithID( "clear" ).click();
+ assertEquals( "Value after reset", "green", form.getParameterValue( "color" ) );
+ assertEquals( "Alert message", "Ran the event", wc.popNextAlert() );
+
+ form.setParameter( "color", "blue" );
+ response.getLinks()[ 0 ].click();
+ assertEquals( "Value after reset", "green", form.getParameterValue( "color" ) );
+ assertNull( "Event ran unexpectedly", wc.getNextAlert() );
+ }
+
+
public void testSubmitViaScript() throws Exception {
defineResource( "DoIt?color=green", "You made it!" );
defineResource( "OnCommand.html", "<html><head></head>" +
|
|
From: Russell G. <rus...@us...> - 2002-08-27 16:26:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv9481/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added support for reset button and associated JavaScript
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- JavaScript.java 23 Aug 2002 19:33:13 -0000 1.16
+++ JavaScript.java 27 Aug 2002 16:26:04 -0000 1.17
@@ -438,6 +438,11 @@
}
+ public void jsFunction_reset() throws IOException, SAXException {
+ getDelegate().reset();
+ }
+
+
void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )
throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {
super.initialize( parent, scriptable );
|
|
From: Russell G. <rus...@us...> - 2002-08-27 16:26:07
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv9481/test/com/meterware/httpunit
Modified Files:
FormSubmitTest.java
Log Message:
Added support for reset button and associated JavaScript
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- FormSubmitTest.java 19 Aug 2002 18:52:26 -0000 1.21
+++ FormSubmitTest.java 27 Aug 2002 16:26:05 -0000 1.22
@@ -172,6 +172,22 @@
}
+ public void testResetButtonDetection() throws Exception {
+ defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
+ "<Input type=text name=age value=12>" +
+ "<Input type=submit name=update>" +
+ "<Input type=reset id=clear>" +
+ "<Input type=button value=recalculate>" +
+ "</form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getForms()[0];
+ form.setParameter( "age", "15" );
+ Button reset = form.getButtonWithID( "clear" );
+ reset.click();
+ assertEquals( "Value after reset", "12", form.getParameterValue( "age" ) );
+ }
+
+
public void testDisabledSubmitButtonDetection() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input type=text name=age value=12>" +
|
|
From: Russell G. <rus...@us...> - 2002-08-27 16:26:07
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv9481/src/com/meterware/httpunit
Modified Files:
Button.java FormControl.java WebForm.java
Added Files:
ResetButton.java
Log Message:
Added support for reset button and associated JavaScript
***** Error reading new file[Errno 2] No such file or directory: 'ResetButton.java'
Index: Button.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Button.java 19 Aug 2002 18:52:25 -0000 1.1
+++ Button.java 27 Aug 2002 16:26:03 -0000 1.2
@@ -64,8 +64,15 @@
}
+ final
protected boolean doOnClickEvent() {
return _onClickEvent.length() == 0 || getScriptableObject().doEvent( _onClickEvent );
+ }
+
+
+ final
+ protected WebForm getForm() {
+ return _form;
}
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FormControl.java 21 Aug 2002 03:45:01 -0000 1.20
+++ FormControl.java 27 Aug 2002 16:26:03 -0000 1.21
@@ -269,6 +269,8 @@
final String type = NodeUtils.getNodeAttribute( node, "type", "submit" );
if (type.equalsIgnoreCase( "submit" )) {
return new SubmitButton( form, node );
+ } else if (type.equalsIgnoreCase( "reset" )) {
+ return new ResetButton( form, node );
} else {
return new Button( form, node );
}
@@ -289,7 +291,7 @@
} else if (type.equalsIgnoreCase( "button" )) {
return new Button( form, node );
} else if (type.equalsIgnoreCase( "reset" )) {
- return new Button( form, node );
+ return new ResetButton( form, node );
} else if (type.equalsIgnoreCase( "file" )) {
return new FileSubmitFormControl( node );
} else {
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- WebForm.java 23 Aug 2002 19:33:12 -0000 1.60
+++ WebForm.java 27 Aug 2002 16:26:04 -0000 1.61
@@ -118,6 +118,18 @@
/**
+ * Returns the button with the specified ID
+ */
+ public Button getButtonWithID( String buttonID ) {
+ Button[] buttons = getButtons();
+ for (int i = 0; i < buttons.length; i++) {
+ if (buttons[i].getID().equalsIgnoreCase( buttonID )) return buttons[i];
+ }
+ return null;
+ }
+
+
+ /**
* Returns an array containing the submit buttons defined for this form.
**/
public SubmitButton[] getSubmitButtons() {
@@ -319,6 +331,12 @@
* Resets all parameters to their initial values.
*/
public void reset() {
+ String event = NodeUtils.getNodeAttribute( getNode(), "onreset" );
+ if (event.length() == 0 || getScriptableObject().doEvent( event )) resetControls();
+ }
+
+
+ private void resetControls() {
FormControl[] controls = getFormControls();
for (int i = 0; i < controls.length; i++) {
controls[i].reset();
@@ -471,6 +489,11 @@
public void submit() throws IOException, SAXException {
submitRequest( getScriptedSubmitRequest() );
+ }
+
+
+ public void reset() throws IOException, SAXException {
+ resetControls();
}
|
|
From: Russell G. <rus...@us...> - 2002-08-27 16:26:06
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv9481/doc
Modified Files:
Javascript-support.html release_notes.txt todo.txt
Log Message:
Added support for reset button and associated JavaScript
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Javascript-support.html 21 Aug 2002 19:06:27 -0000 1.12
+++ Javascript-support.html 27 Aug 2002 16:26:02 -0000 1.13
@@ -45,11 +45,13 @@
</ul>
<h4>events</h4>
<ul>
-<li>onSubmit - invoked when the form.submit() is invoked</li>
+<li>onReset - invoked when form.reset() is invoked or a reset button is clicked</li>
+<li>onSubmit - invoked when form.submit() is invoked or a submit button is clicked</li>
</ul>
<h4>methods</h4>
<ul>
<li>submit - submits the form</li>
+<li>reset - resets the form controls to their default values</li>
</ul>
<h3>Image</h3>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- release_notes.txt 23 Aug 2002 19:33:12 -0000 1.147
+++ release_notes.txt 27 Aug 2002 16:26:02 -0000 1.148
@@ -11,6 +11,12 @@
Revision History:
+27-Aug-2002
+Additions:
+ 1. Reset buttons may now be clicked to reset the form
+ 2. WebForm supports getButtonWithID
+ 3. JavaScript: Form now supports reset() and onReset event.
+
23-Aug-2002
Additions:
1. javascript URLs are now supported.
Index: todo.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- todo.txt 21 Aug 2002 20:49:39 -0000 1.28
+++ todo.txt 27 Aug 2002 16:26:03 -0000 1.29
@@ -4,14 +4,13 @@
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
o Documentation, Documentation
JavaScript priorities:
o Document.write
-o JavaScript URLs
-o Form.onreset and Form.reset
+o Javascript includes
+o Navigator object
Possibles:
o replace JTidy with a simpler custom parser
|
|
From: Russell G. <rus...@us...> - 2002-08-23 19:33:16
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv15716/src/com/meterware/httpunit
Modified Files:
WebClient.java WebForm.java WebLink.java WebRequest.java
WebRequestSource.java WebResponse.java
Log Message:
Added support for javascript: URLs
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- WebClient.java 21 Aug 2002 19:06:27 -0000 1.27
+++ WebClient.java 23 Aug 2002 19:33:12 -0000 1.28
@@ -24,14 +24,11 @@
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
+import java.util.*;
import org.xml.sax.SAXException;
@@ -80,16 +77,39 @@
* @exception SAXException thrown if there is an error parsing the retrieved page
**/
public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException {
- if (request.getURLString().startsWith( "about:" )) return WebResponse.BLANK_RESPONSE;
-
tellListeners( request );
- WebResponse response = newResponse( request );
- tellListeners( response );
- updateClient( response );
+
+ WebResponse response = getNextPage( request );
+ if (response != null) {
+ tellListeners( response );
+ updateClient( response );
+ }
+
return getFrameContents( request.getTarget() );
}
+ /**
+ * Evaluates the request and returns the desired page. Will return null if the current target is to be unaffected.
+ */
+ private WebResponse getNextPage( WebRequest request ) throws IOException {
+ String urlString = request.getURLString().trim();
+ if (urlString.startsWith( "about:" )) {
+ return WebResponse.BLANK_RESPONSE;
+ } else if (!urlString.startsWith( "javascript:" )) {
+ return newResponse( request );
+ } else {
+ WebRequestSource wrs = request.getWebRequestSource();
+ String result = (wrs == null) ? getCurrentPage().getScriptableObject().evaluateURL( urlString )
+ : wrs.getScriptableDelegate().evaluateURL( urlString );
+ if (result == null) return null;
+
+ URL url = new URL( "javascript", null, -1, urlString.substring( "javascript:".length() ), JAVASCRIPT_STREAM_HANDLER );
+ return new DefaultWebResponse( this, request.getTarget(), url, result );
+ }
+ }
+
+
private void tellListeners( WebRequest request ) {
List listeners;
@@ -255,6 +275,23 @@
/**
+ * Returns the next javascript alert without removing it from the queue.
+ */
+ public String getNextAlert() {
+ return _alerts.isEmpty() ? null : (String) _alerts.getFirst();
+ }
+
+
+ /**
+ * Returns the next javascript alert and removes it from the queue.
+ */
+ public String popNextAlert() {
+ if (_alerts.isEmpty()) throw new IllegalStateException( "Tried to pop a non-existent alert" );
+ return (String) _alerts.removeFirst();
+ }
+
+
+ /**
* Specifies the object which will respond to all dialogs.
**/
public void setDialogResponder( DialogResponder responder ) {
@@ -269,6 +306,12 @@
if (HttpUnitOptions.isAcceptGzip()) {
setHeaderField( "Accept-Encoding", "gzip" );
}
+
+ try {
+ _frameContents.updateFrames( new DefaultWebResponse( this, null, WebResponse.BLANK_HTML ) );
+ } catch (IOException e) {
+ } catch (SAXException e) {
+ }
}
@@ -354,8 +397,14 @@
}
+ void postAlert( String message ) {
+ _alerts.addLast( message );
+ }
+
//------------------------------------------ private members -------------------------------------
+ /** The list of alerts generated by JavaScript. **/
+ private LinkedList _alerts = new LinkedList();
/** The currently defined cookies. **/
private Hashtable _cookies = new Hashtable();
@@ -374,6 +423,8 @@
private DialogResponder _dialogResponder = new DialogAdapter();
+ private static URLStreamHandler JAVASCRIPT_STREAM_HANDLER = new JavascriptURLStreamHandler();
+
/**
* Examines the headers in the response and throws an exception if appropriate.
@@ -482,6 +533,19 @@
**/
public String getMethod() {
return "GET";
+ }
+}
+
+
+
+
+//==================================================================================================
+
+
+class JavascriptURLStreamHandler extends URLStreamHandler {
+
+ protected URLConnection openConnection( URL u ) throws IOException {
+ return null;
}
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- WebForm.java 21 Aug 2002 03:45:01 -0000 1.59
+++ WebForm.java 23 Aug 2002 19:33:12 -0000 1.60
@@ -334,6 +334,7 @@
return _scriptable;
}
+
//---------------------------------- WebRequestSource methods --------------------------------
/**
@@ -375,6 +376,15 @@
**/
public WebRequest getRequest() {
return getRequest( (SubmitButton) null );
+ }
+
+
+ /**
+ * Returns the scriptable delegate.
+ */
+
+ ScriptableDelegate getScriptableDelegate() {
+ return getScriptableObject();
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- WebLink.java 8 Aug 2002 20:47:21 -0000 1.24
+++ WebLink.java 23 Aug 2002 19:33:13 -0000 1.25
@@ -96,15 +96,6 @@
}
- /**
- * Returns an object which provides scripting access to this link.
- **/
- public Scriptable getScriptableObject() {
- if (_scriptable == null) _scriptable = new Scriptable();
- return _scriptable;
- }
-
-
//----------------------------------------- WebRequestSource methods ---------------------------------------------------
@@ -117,6 +108,14 @@
/**
+ * Returns the scriptable delegate.
+ */
+ ScriptableDelegate getScriptableDelegate() {
+ return getScriptableObject();
+ }
+
+
+ /**
* Returns an array containing the names of any parameters defined as part of this link's URL.
**/
public String[] getParameterNames() {
@@ -262,6 +261,15 @@
**/
WebLink( WebResponse response, URL baseURL, String parentTarget, Node node ) {
super( response, node, baseURL, NodeUtils.getNodeAttribute( node, "href" ), parentTarget );
+ }
+
+
+ /**
+ * Returns an object which provides scripting access to this link.
+ **/
+ Scriptable getScriptableObject() {
+ if (_scriptable == null) _scriptable = new Scriptable();
+ return _scriptable;
}
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- WebRequest.java 16 Aug 2002 17:24:00 -0000 1.44
+++ WebRequest.java 23 Aug 2002 19:33:13 -0000 1.45
@@ -288,6 +288,7 @@
protected WebRequest( WebRequestSource requestSource ) {
this( requestSource.getBaseURL(), requestSource.getRelativeURL(), requestSource.getTarget(), newParameterHolder( requestSource ) );
+ _webRequestSource = requestSource;
setHeaderField( "Referer", requestSource.getBaseURL().toExternalForm() );
}
@@ -306,7 +307,7 @@
**/
private WebRequest( URL urlBase, String urlString, String target, ParameterHolder parameterHolder ) {
_urlBase = urlBase;
- _urlString = escape( urlString );
+ _urlString = urlString.toLowerCase().startsWith( "http" ) ? escape( urlString ) : urlString;
_target = target;
_parameterHolder = parameterHolder;
}
@@ -421,6 +422,11 @@
final static String TOP_FRAME = "_top";
+ WebRequestSource getWebRequestSource() {
+ return _webRequestSource;
+ }
+
+
Hashtable getHeaderDictionary() {
if (_headers == null) {
_headers = new Hashtable();
@@ -448,6 +454,7 @@
private String _urlString;
private String _target = TOP_FRAME;
private Hashtable _headers;
+ private WebRequestSource _webRequestSource;
private boolean _httpsProtocolSupportEnabled;
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebRequestSource.java 13 Aug 2002 17:57:47 -0000 1.12
+++ WebRequestSource.java 23 Aug 2002 19:33:13 -0000 1.13
@@ -20,6 +20,8 @@
*******************************************************************************************************************/
package com.meterware.httpunit;
+import com.meterware.httpunit.scripting.ScriptableDelegate;
+
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
@@ -87,6 +89,13 @@
**/
abstract
public String[] getParameterValues( String name );
+
+
+ /**
+ * Returns the scriptable delegate.
+ */
+ abstract
+ ScriptableDelegate getScriptableDelegate();
/**
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- WebResponse.java 22 Aug 2002 16:19:54 -0000 1.76
+++ WebResponse.java 23 Aug 2002 19:33:13 -0000 1.77
@@ -475,27 +475,27 @@
//---------------------------------------- JavaScript methods ----------------------------------------
- private LinkedList _alerts = new LinkedList();
-
/**
* Returns the next javascript alert without removing it from the queue.
+ * @deprecated use WebClient#getNextAlert. Will be removed in next release.
*/
public String getNextAlert() {
- return _alerts.isEmpty() ? null : (String) _alerts.getFirst();
+ return _client.getNextAlert();
}
/**
* Returns the next javascript alert and removes it from the queue.
+ * @deprecated use WebClient#popNextAlert. Will be removed in next release.
*/
public String popNextAlert() {
- if (_alerts.isEmpty()) throw new IllegalStateException( "Tried to pop a non-existent alert" );
- return (String) _alerts.removeFirst();
+ return _client.popNextAlert();
}
public Scriptable getScriptableObject() {
- return new Scriptable();
+ if (_scriptable == null) _scriptable = new Scriptable();
+ return _scriptable;
}
@@ -511,7 +511,7 @@
public class Scriptable extends ScriptableDelegate {
public void alert( String message ) {
- _alerts.addLast( message );
+ _client.postAlert( message );
}
@@ -612,8 +612,8 @@
//------------------------------------------ package members ------------------------------------------------
-
- final static WebResponse BLANK_RESPONSE = new DefaultWebResponse( "<html><head></head><body></body></html>" );
+ final static String BLANK_HTML = "<html><head><title>Blank</title></head><body></body></html>";
+ final static WebResponse BLANK_RESPONSE = new DefaultWebResponse( BLANK_HTML );
/**
@@ -698,6 +698,8 @@
private WebClient _client;
+ private Scriptable _scriptable;
+
protected void loadResponseText() throws IOException {
if (_responseText != null) throw new IllegalStateException( "May only invoke loadResponseText once" );
@@ -1087,7 +1089,17 @@
DefaultWebResponse( String text ) {
- super( null, "", null );
+ this( null, null, text );
+ }
+
+
+ DefaultWebResponse( WebClient client, URL url, String text ) {
+ this( client, WebRequest.TOP_FRAME, url, text );
+ }
+
+
+ DefaultWebResponse( WebClient client, String target, URL url, String text ) {
+ super( client, target, url );
_responseText = text;
}
|