use of com.gargoylesoftware.htmlunit.util.NameValuePair in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method buildRequestParameterMapViaWebRequestDotSetRequestParametersWithSingleRequestParamWithValueSetToSpace.
@Test
public void buildRequestParameterMapViaWebRequestDotSetRequestParametersWithSingleRequestParamWithValueSetToSpace() {
webRequest.setRequestParameters(asList(new NameValuePair("name", " ")));
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getParameterMap().size(), equalTo(1));
assertThat(actualRequest.getParameter("name"), equalTo(" "));
}
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();
}
use of com.gargoylesoftware.htmlunit.util.NameValuePair in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilder method params.
private void params(MockHttpServletRequest request, UriComponents uriComponents) {
for (Entry<String, List<String>> entry : uriComponents.getQueryParams().entrySet()) {
String name = entry.getKey();
String urlDecodedName = urlDecode(name);
for (String value : entry.getValue()) {
value = (value != null ? urlDecode(value) : "");
request.addParameter(urlDecodedName, value);
}
}
for (NameValuePair param : this.webRequest.getRequestParameters()) {
request.addParameter(param.getName(), param.getValue());
}
}
use of com.gargoylesoftware.htmlunit.util.NameValuePair in project spring-framework by spring-projects.
the class MockWebResponseBuilder method responseHeaders.
private List<NameValuePair> responseHeaders() {
Collection<String> headerNames = this.response.getHeaderNames();
List<NameValuePair> responseHeaders = new ArrayList<>(headerNames.size());
for (String headerName : headerNames) {
List<Object> headerValues = this.response.getHeaderValues(headerName);
for (Object value : headerValues) {
responseHeaders.add(new NameValuePair(headerName, String.valueOf(value)));
}
}
String location = this.response.getRedirectedUrl();
if (location != null) {
responseHeaders.add(new NameValuePair("Location", location));
}
for (Cookie cookie : this.response.getCookies()) {
responseHeaders.add(new NameValuePair("Set-Cookie", valueOfCookie(cookie)));
}
return responseHeaders;
}
use of com.gargoylesoftware.htmlunit.util.NameValuePair in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method buildRequestParameterMapViaWebRequestDotSetRequestParametersWithMultipleRequestParams.
@Test
public void buildRequestParameterMapViaWebRequestDotSetRequestParametersWithMultipleRequestParams() {
webRequest.setRequestParameters(asList(new NameValuePair("name1", "value1"), new NameValuePair("name2", "value2")));
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getParameterMap().size(), equalTo(2));
assertThat(actualRequest.getParameter("name1"), equalTo("value1"));
assertThat(actualRequest.getParameter("name2"), equalTo("value2"));
}
Aggregations