Search in sources :

Example 11 with WebResponse

use of com.gargoylesoftware.htmlunit.WebResponse in project blueocean-plugin by jenkinsci.

the class GitSampleRepoRule method notifyCommit.

public void notifyCommit(JenkinsRule r) throws Exception {
    synchronousPolling(r);
    WebResponse webResponse = r.createWebClient().goTo("git/notifyCommit?url=" + bareUrl(), "text/plain").getWebResponse();
    System.out.println(webResponse.getContentAsString());
    for (NameValuePair pair : webResponse.getResponseHeaders()) {
        if (pair.getName().equals("Triggered")) {
            System.out.println("Triggered: " + pair.getValue());
        }
    }
    r.waitUntilNoActivity();
}
Also used : NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) WebResponse(com.gargoylesoftware.htmlunit.WebResponse)

Example 12 with WebResponse

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

the class MockWebResponseBuilderTests method buildStatus.

@Test
public void buildStatus() throws Exception {
    WebResponse webResponse = this.responseBuilder.build();
    assertThat(webResponse.getStatusCode(), equalTo(200));
    assertThat(webResponse.getStatusMessage(), equalTo("OK"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) Test(org.junit.Test)

Example 13 with WebResponse

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

the class MockWebResponseBuilderTests method buildWebRequest.

@Test
public void buildWebRequest() throws Exception {
    WebResponse webResponse = this.responseBuilder.build();
    assertThat(webResponse.getWebRequest(), equalTo(this.webRequest));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) Test(org.junit.Test)

Example 14 with WebResponse

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

the class MockWebResponseBuilderTests method buildContentType.

@Test
public void buildContentType() throws Exception {
    this.response.addHeader("Content-Type", "text/html; charset-UTF-8");
    WebResponse webResponse = this.responseBuilder.build();
    assertThat(webResponse.getContentType(), equalTo("text/html"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) Test(org.junit.Test)

Example 15 with WebResponse

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

the class MockWebResponseBuilderTests method buildStatusWithCustomMessage.

@Test
public void buildStatusWithCustomMessage() throws Exception {
    this.response.sendError(401, "Custom");
    WebResponse webResponse = this.responseBuilder.build();
    assertThat(webResponse.getStatusCode(), equalTo(401));
    assertThat(webResponse.getStatusMessage(), equalTo("Custom"));
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) Test(org.junit.Test)

Aggregations

WebResponse (com.gargoylesoftware.htmlunit.WebResponse)22 Test (org.junit.Test)14 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)5 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)4 URL (java.net.URL)4 WebClient (com.gargoylesoftware.htmlunit.WebClient)3 WebResponseData (com.gargoylesoftware.htmlunit.WebResponseData)3 StringWebResponse (com.gargoylesoftware.htmlunit.StringWebResponse)2 Cookie (javax.servlet.http.Cookie)2 JvmAttributeGaugeSet (com.codahale.metrics.JvmAttributeGaugeSet)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HttpWebConnection (com.gargoylesoftware.htmlunit.HttpWebConnection)1 NicelyResynchronizingAjaxController (com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController)1 WebConnection (com.gargoylesoftware.htmlunit.WebConnection)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1