use of com.gargoylesoftware.htmlunit.HttpWebConnection in project saga by timurstrekalov.
the class WebClientFactory method newInstance.
// New version allows for creation of web drivers without the need for a config object
// which may not be readily available if the driver is created by third-party code.
public static WebClient newInstance(final BrowserVersion version) {
final WebClient client = new WebClient(version) {
@Override
public WebResponse loadWebResponse(final WebRequest webRequest) throws IOException {
return new WebResponseProxy(super.loadWebResponse(webRequest));
}
};
client.setIncorrectnessListener(quietIncorrectnessListener);
client.setJavaScriptErrorListener(loggingJsErrorListener);
client.setHTMLParserListener(quietHtmlParserListener);
client.setCssErrorHandler(quietCssErrorHandler);
client.getOptions().setJavaScriptEnabled(true);
client.setAjaxController(new NicelyResynchronizingAjaxController());
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.getOptions().setPrintContentOnFailingStatusCode(false);
client.setWebConnection(new HttpWebConnection(client) {
@Override
protected WebResponse newWebResponseInstance(final WebResponseData responseData, final long loadTime, final WebRequest request) {
return new WebResponseProxy(super.newWebResponseInstance(responseData, loadTime, request));
}
});
return client;
}
use of com.gargoylesoftware.htmlunit.HttpWebConnection in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method verifyExampleInClassLevelJavadoc.
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void verifyExampleInClassLevelJavadoc() throws Exception {
WebClient webClient = new WebClient();
MockMvc mockMvc = MockMvcBuilders.standaloneSetup().build();
MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient);
WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
WebConnection httpConnection = new HttpWebConnection(webClient);
webClient.setWebConnection(new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection)));
Page page = webClient.getPage("https://code.jquery.com/jquery-1.11.0.min.js");
assertThat(page.getWebResponse().getStatusCode()).isEqualTo(200);
assertThat(page.getWebResponse().getContentAsString()).isNotEmpty();
}
Aggregations