private WebClient getWebClientWithWrongSocksProxy() { final WebClient client = getWebClient(); client .getOptions() .setProxyConfig(new ProxyConfig(SOCKS_PROXY_HOST, SOCKS_PROXY_PORT + 1, true)); return client; }
private void doHttpsTest(final WebClient webClient) throws Exception { localServer_ = new InsecureHttpsServer(SocksProxyTestServlet.HTML); localServer_.start(); webClient.getOptions().setUseInsecureSSL(true); final String url = "https://" + localServer_.getHostName() + ":" + localServer_.getPort(); final HtmlPage page = webClient.getPage(url); assertEquals("hello", page.getTitleText()); }
public static WebClient buildWebClient() { WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setCssEnabled(true); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setUseInsecureSSL(true); webClient.setCssErrorHandler( new ErrorHandler() { @Override public void warning(CSSParseException exception) throws CSSException { // nothing to do here } @Override public void error(CSSParseException exception) throws CSSException { // todo: log or throw exception } @Override public void fatalError(CSSParseException exception) throws CSSException { // todo: log or throw exception } }); webClient.setIncorrectnessListener( new IncorrectnessListener() { @Override public void notify(String message, Object origin) { // todo: analyze and throw exception } }); webClient.waitForBackgroundJavaScript(100000); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setRedirectEnabled(true); return webClient; }
private WebClient getWebClientWithSocksProxy() { final WebClient client = getWebClient(); client.getOptions().setTimeout(10_000); client.getOptions().setProxyConfig(new ProxyConfig(SOCKS_PROXY_HOST, SOCKS_PROXY_PORT, true)); return client; }