I needed the ability for a WebTester to be associated with a different HTTPUnitDialog than the one that was created when beginAt() is called. So, I have added a constructor to WebTester that takes a HTTPUnitDialog.
I have attached a patch for this against HEAD (which seems to be broken btw, so I couldn't test my patch. But I have been using it for a while now without any problems). I'd like to know what the community thinks about this proposed patch.
Cheers Srini
P.S This is what I got when I tried to build HEAD
compile:
[mkdir] Created dir: F:\java\jWebUnit\target\classes
[mkdir] Created dir: F:\java\jWebUnit\target\test-classes
[javac] Compiling 14 source files to F:\java\jWebUnit\target\classes
[javac] Compiling 20 source files to F:\java\jWebUnit\target\test-classes
[javac] F:\java\jWebUnit\test\net\sourceforge\jwebunit\util\JettySetup.java:10: package org.mortbay.jetty does not exist
[javac] import org.mortbay.jetty.Server;
[javac] ^
[javac] F:\java\jWebUnit\test\net\sourceforge\jwebunit\util\JettySetup.java:11: package org.mortbay.util does not exist
[javac] import org.mortbay.util.MultiException;
[javac] ^
[javac] F:\java\jWebUnit\test\net\sourceforge\jwebunit\util\JettySetup.java:26: cannot resolve symbol
[javac] symbol : class Server
[javac] location: class net.sourceforge.jwebunit.util.JettySetup
[javac] private Server jettyServer = null;
[javac] ^
[javac] F:\java\jWebUnit\test\net\sourceforge\jwebunit\util\JettySetup.java:50: cannot resolve symbol
[javac] symbol : class Server
[javac] location: class net.sourceforge.jwebunit.util.JettySetup
[javac] jettyServer = new Server(jettyConfig);
[javac] ^
[javac] F:\java\jWebUnit\test\net\sourceforge\jwebunit\util\JettySetup.java:56: cannot resolve symbol
[javac] symbol : class MultiException
[javac] location: class net.sourceforge.jwebunit.util.JettySetup
[javac] } catch (MultiException e) {
[javac] ^
[javac] 5 errors
BUILD FAILED
Index: src/net/sourceforge/jwebunit/WebTester.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.49
diff -u -r1.49 WebTester.java
--- src/net/sourceforge/jwebunit/WebTester.java 28 Jul 2004 17:39:06 -0000 1.49
+++ src/net/sourceforge/jwebunit/WebTester.java 5 Aug 2004 06:09:19 -0000
@@ -26,6 +26,14 @@
private HttpUnitDialog dialog;
private TestContext context = new TestContext();
+ public WebTester() {
+ }
+
+ public WebTester(HttpUnitDialog dialog) {
+ this();
+ this.dialog = dialog;
+ }
+
/**
* Provides access to the httpunit wrapper for subclasses - in case functionality
not
* yet wrappered required by test.
@@ -832,7 +840,7 @@
* @param formElementLabel label preceding form element.
* @param value
*/
- protected void setFormElementWithLabel(String formElementLabel,
+ public void setFormElementWithLabel(String formElementLabel,
String value) {
String name = dialog.getFormElementNameForLabel(formElementLabel);
Assert.assertNotNull("Did not find form element with label [" +
formElementLabel + "].", name);
