[Webtest] Proxy Server patch

Brian O'Kelley webtest@lists.canoo.com
Fri, 30 May 2003 12:24:52 -0400


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C326C7.FFBB7AD0
Content-Type: text/plain;
	charset="iso-8859-1"

The attached patch (for CVS as of today) adds proxy server support to Canoo.

Attributes "proxyport" and "proxyhost" are added for the, surprise, host and
port of the proxy server. Blank host means "don't use a proxy server".

It's pretty simple, but let me know if there's a better way or if you
encounter problems.

Brian


------_=_NextPart_000_01C326C7.FFBB7AD0
Content-Type: text/plain;
	name="patch.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch.txt"

? TestReport.xml
? build
? deploy
? junit1199190937.properties
? patch.txt
? testExistingNodes-Out.xml
? testNewFile-Out.xml
? testWrongRootNode-Out.xml
? lib/webtest.jar
Index: doc/info/manual/syntax.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /repositories/cvs/public/webtest/doc/info/manual/syntax.xml,v
retrieving revision 1.35
diff -u -r1.35 syntax.xml
--- doc/info/manual/syntax.xml	23 May 2003 13:00:32 -0000	1.35
+++ doc/info/manual/syntax.xml	29 May 2003 17:28:09 -0000
@@ -150,6 +150,18 @@
 					<required>Yes</required>
 				</attribute>
 				<attribute>
+					<name>proxyhost</name>
+					<description>Defines the hostname of the proxy server to use for =
executing requests, e.g.
+      				&quot;localhost&quot; or &quot;www.myhost.com&quot;. If left =
blank, no proxy server will be used (the default =
behavior).</description>
+					<required>No</required>
+				</attribute>
+				<attribute>
+					<name>proxyport</name>
+					<description>Defines the port number of the proxy server to use =
for executing requests, e.g.
+      				&quot;8080&quot;.</description>
+					<required>No</required>
+				</attribute>
+				<attribute>
 					<name>protocol</name>
 					<description>Defines the protocol to use for executing requests.
       				&quot;http:&quot; and &quot;file:&quot; are currently the =
only supported protocols.</description>
Index: src/com/canoo/webtest/engine/Configuration.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: =
/repositories/cvs/public/webtest/src/com/canoo/webtest/engine/Configurat=
ion.java,v
retrieving revision 1.1
diff -u -r1.1 Configuration.java
--- src/com/canoo/webtest/engine/Configuration.java	14 Nov 2002 =
16:29:08 -0000	1.1
+++ src/com/canoo/webtest/engine/Configuration.java	29 May 2003 =
17:28:09 -0000
@@ -33,6 +33,9 @@
     private String fResultPath;
     private String fDefaultPage;
=20
+	private String fProxyHost ;
+	private int fProxyPort =3D -1 ;
+
     private ILogger fLogger =3D null;
 	private IPropertyHandler fPropertyHandler;
 	private List fHeaderList =3D new LinkedList();
@@ -121,6 +124,16 @@
         return fProtocol;
     }
=20
+	public String getProxyhost()
+	{
+		return fProxyHost ;
+	}
+
+	public int getProxyport()
+	{
+		return fProxyPort ;
+	}
+
     public String getResultpath()
     {
         return fResultPath;
@@ -257,6 +270,16 @@
         fProtocol =3D newProtocol;
     }
=20
+	public void setProxyhost(String newProxyHost)
+	{
+		fProxyHost =3D newProxyHost ;
+	}
+
+	public void setProxyport(int newProxyPort)
+	{
+		fProxyPort =3D newProxyPort ;
+	}
+
     public void setResultpath(String newResultPath)
     {
         fResultPath =3D newResultPath;
@@ -313,6 +336,8 @@
         map.put("host", getHost());
         map.put("protocol", getProtocol());
         map.put("port", new Integer(getPort()).toString());
+		map.put("proxyport", String.valueOf(getProxyport())) ;
+		map.put("proxyhost", getProxyhost()) ;
         map.put("defaultpage", getDefaultPage());
         map.put("basepath", getBasePath());
         map.put("resultpath", getResultpath());
@@ -350,4 +375,4 @@
         return fPropertyHandler.getProperty(name);
     }
=20
-}
\ No newline at end of file
+}
Index: src/com/canoo/webtest/steps/request/Target.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: =
/repositories/cvs/public/webtest/src/com/canoo/webtest/steps/request/Tar=
get.java,v
retrieving revision 1.7
diff -u -r1.7 Target.java
--- src/com/canoo/webtest/steps/request/Target.java	23 May 2003 =
12:57:27 -0000	1.7
+++ src/com/canoo/webtest/steps/request/Target.java	29 May 2003 =
17:28:10 -0000
@@ -299,6 +299,13 @@
      */
     protected void prepareConversation(Context context) {
=20
+        String proxyHost =3D =
context.getTestSpecification().getConfig().getProxyhost() ;
+        int proxyPort =3D =
context.getTestSpecification().getConfig().getProxyport() ;
+		if (proxyHost !=3D null) {
+			context.getWebConversation().setProxyServer(proxyHost, proxyPort) ;
+		} else {
+			context.getWebConversation().setProxyServer(null, 0) ;
+		}
         if (fUserName !=3D null && fPassword !=3D null) {
             logText(context, "Setting password for username: " + =
fUserName);
             context.getWebConversation().setAuthorization(fUserName, =
fPassword);

------_=_NextPart_000_01C326C7.FFBB7AD0--