Testing Through a Firewall
Problem
You want to test a remote web site, but your development machines are behind a firewall.
Solution
Set the proxySet
, proxyHost
,
and proxyPort
system properties.
Discussion
HttpUnit uses java.net.HttpURLConnection
, which
checks the proxySet
system property to determine if
it should operate through a proxy server. If this property is set,
the proxyHost
and
proxyPort
properties specify the server name and
port.
You can set these properties in your unit test method using this code:
System.getProperties( ).put("proxySet", "true"); System.getProperties( ).put("proxyHost", "myProxyHostName"); System.getProperties( ).put("proxyPort", "10000");
See Also
Recipe 3.6 shows how to set system properties using Ant.
Get Java Extreme Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.