Search in sources :

Example 1 with NameValuePair

use of com.gargoylesoftware.htmlunit.util.NameValuePair 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 2 with NameValuePair

use of com.gargoylesoftware.htmlunit.util.NameValuePair 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 3 with NameValuePair

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

the class HtmlUnitRequestBuilderTests method buildRequestParameterMapViaWebRequestDotSetRequestParametersWithSingleRequestParam.

@Test
public void buildRequestParameterMapViaWebRequestDotSetRequestParametersWithSingleRequestParam() {
    webRequest.setRequestParameters(asList(new NameValuePair("name", "value")));
    MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
    assertThat(actualRequest.getParameterMap().size(), equalTo(1));
    assertThat(actualRequest.getParameter("name"), equalTo("value"));
}
Also used : NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 4 with NameValuePair

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

the class MockWebResponseBuilderTests method buildResponseHeadersNullDomainDefaulted.

// SPR-14169
@Test
public void buildResponseHeadersNullDomainDefaulted() throws Exception {
    Cookie cookie = new Cookie("cookieA", "valueA");
    this.response.addCookie(cookie);
    WebResponse webResponse = this.responseBuilder.build();
    List<NameValuePair> responseHeaders = webResponse.getResponseHeaders();
    assertThat(responseHeaders.size(), equalTo(1));
    NameValuePair header = responseHeaders.get(0);
    assertThat(header.getName(), equalTo("Set-Cookie"));
    assertThat(header.getValue(), equalTo("cookieA=valueA"));
}
Also used : Cookie(javax.servlet.http.Cookie) NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) Test(org.junit.Test)

Example 5 with NameValuePair

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

the class MockWebResponseBuilderTests method buildResponseHeaders.

@Test
public void buildResponseHeaders() throws Exception {
    this.response.addHeader("Content-Type", "text/html");
    this.response.addHeader("X-Test", "value");
    Cookie cookie = new Cookie("cookieA", "valueA");
    cookie.setDomain("domain");
    cookie.setPath("/path");
    cookie.setMaxAge(1800);
    cookie.setSecure(true);
    cookie.setHttpOnly(true);
    this.response.addCookie(cookie);
    WebResponse webResponse = this.responseBuilder.build();
    List<NameValuePair> responseHeaders = webResponse.getResponseHeaders();
    assertThat(responseHeaders.size(), equalTo(3));
    NameValuePair header = responseHeaders.get(0);
    assertThat(header.getName(), equalTo("Content-Type"));
    assertThat(header.getValue(), equalTo("text/html"));
    header = responseHeaders.get(1);
    assertThat(header.getName(), equalTo("X-Test"));
    assertThat(header.getValue(), equalTo("value"));
    header = responseHeaders.get(2);
    assertThat(header.getName(), equalTo("Set-Cookie"));
    assertThat(header.getValue(), startsWith("cookieA=valueA;domain=domain;path=/path;expires="));
    assertThat(header.getValue(), endsWith(";secure;httpOnly"));
}
Also used : Cookie(javax.servlet.http.Cookie) NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) Test(org.junit.Test)

Aggregations

NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)12 Test (org.junit.Test)7 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 Cookie (javax.servlet.http.Cookie)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 BasicClientCookie (org.apache.http.impl.cookie.BasicClientCookie)1