Search in sources :

Example 1 with WebResponseData

use of com.gargoylesoftware.htmlunit.WebResponseData in project spring-framework by spring-projects.

the class MockWebResponseBuilder method build.

public WebResponse build() throws IOException {
    WebResponseData webResponseData = webResponseData();
    long endTime = System.currentTimeMillis();
    return new WebResponse(webResponseData, this.webRequest, endTime - this.startTime);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebResponseData(com.gargoylesoftware.htmlunit.WebResponseData)

Example 2 with WebResponseData

use of com.gargoylesoftware.htmlunit.WebResponseData 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;
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) NicelyResynchronizingAjaxController(com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController) HttpWebConnection(com.gargoylesoftware.htmlunit.HttpWebConnection) WebResponseData(com.gargoylesoftware.htmlunit.WebResponseData) WebClient(com.gargoylesoftware.htmlunit.WebClient)

Example 3 with WebResponseData

use of com.gargoylesoftware.htmlunit.WebResponseData in project spring-security by spring-projects.

the class MockWebResponseBuilder method build.

WebResponse build() throws IOException {
    WebResponseData webResponseData = webResponseData();
    long endTime = System.currentTimeMillis();
    return new WebResponse(webResponseData, this.webRequest, endTime - this.startTime);
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebResponseData(com.gargoylesoftware.htmlunit.WebResponseData)

Example 4 with WebResponseData

use of com.gargoylesoftware.htmlunit.WebResponseData in project spring-security by spring-projects.

the class MockWebResponseBuilder method webResponseData.

private WebResponseData webResponseData() {
    List<NameValuePair> responseHeaders = responseHeaders();
    HttpStatus status = this.exchangeResult.getStatus();
    return new WebResponseData(this.exchangeResult.getResponseBodyContent(), status.value(), status.getReasonPhrase(), responseHeaders);
}
Also used : NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) HttpStatus(org.springframework.http.HttpStatus) WebResponseData(com.gargoylesoftware.htmlunit.WebResponseData)

Example 5 with WebResponseData

use of com.gargoylesoftware.htmlunit.WebResponseData in project spring-framework by spring-projects.

the class DelegatingWebConnectionTests method setup.

@BeforeEach
public void setup() throws Exception {
    request = new WebRequest(new URL("http://localhost/"));
    WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.emptyList());
    expectedResponse = new WebResponse(data, request, 100L);
    webConnection = new DelegatingWebConnection(defaultConnection, new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) WebResponseData(com.gargoylesoftware.htmlunit.WebResponseData) DelegateWebConnection(org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection) URL(java.net.URL) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

WebResponseData (com.gargoylesoftware.htmlunit.WebResponseData)5 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)4 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)2 HttpWebConnection (com.gargoylesoftware.htmlunit.HttpWebConnection)1 NicelyResynchronizingAjaxController (com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)1 URL (java.net.URL)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 HttpStatus (org.springframework.http.HttpStatus)1 DelegateWebConnection (org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection)1