[Webtest] Multiple proxies (was: Re: Re: webtest cannot handle the lack of a secure certificate in our test environment)

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Tue, 19 Dec 2006 05:17:25 -0800 (PST)


Hi John,

> So, I think I need to be able to use different proxies for different
> domains. Is it possible to do this with WebTest / HTMLUnit? If not is it a
> possible future enhancement?

htmlunit doesn't allow it currently BUT a workaround is only a few lines of
code

<groovy>
import com.gargoylesoftware.htmlunit.*

class MyWebConnection extends
com.gargoylesoftware.htmlunit.util.WebConnectionWrapper
{
  MyWebConnection(WebConnection webConnection)
  {
    super(webConnection)
  }

  WebResponse getResponse(WebRequestSettings webRequestSettings)
  {
    // change proxy settings here with your own logic
    webRequestSettings.proxyHost = "what.you.want"
    webRequestSettings.proxyPort = 12345

    return super.getResponse(webRequestSettings)
  }
}

def webClient = step.context.webClient
webClient.webConnection = new MyWebConnection(webClient.webConnection)
</groovy>

(as always, I haven't tested this code and my email client doesn't even
provide syntax highlighting to detect trivial typing problems ;-))

Hope this helps.

Marc.
-- 
View this message in context: http://www.nabble.com/webtest-cannot-handle-the-lack-of-a-secure-certificate-in-our-test-environment-tf2791697.html#a7946828
Sent from the WebTest mailing list archive at Nabble.com.