use of com.gargoylesoftware.htmlunit.WebResponse in project spring-framework by spring-projects.
the class MockWebResponseBuilderTests method buildContent.
// --- build
@Test
public void buildContent() throws Exception {
this.response.getWriter().write("expected content");
WebResponse webResponse = this.responseBuilder.build();
assertThat(webResponse.getContentAsString(), equalTo("expected content"));
}
use of com.gargoylesoftware.htmlunit.WebResponse in project spring-framework by spring-projects.
the class MockWebResponseBuilderTests method buildContentCharset.
@Test
public void buildContentCharset() throws Exception {
this.response.addHeader("Content-Type", "text/html; charset=UTF-8");
WebResponse webResponse = this.responseBuilder.build();
assertThat(webResponse.getContentCharset(), equalTo(StandardCharsets.UTF_8));
}
use of com.gargoylesoftware.htmlunit.WebResponse in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method getResponseDefault.
@Test
public void getResponseDefault() throws Exception {
when(defaultConnection.getResponse(request)).thenReturn(expectedResponse);
WebResponse response = webConnection.getResponse(request);
assertThat(response, sameInstance(expectedResponse));
verify(matcher1).matches(request);
verify(matcher2).matches(request);
verifyNoMoreInteractions(connection1, connection2);
verify(defaultConnection).getResponse(request);
}
use of com.gargoylesoftware.htmlunit.WebResponse in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method getResponseAllMatches.
@Test
public void getResponseAllMatches() throws Exception {
when(matcher1.matches(request)).thenReturn(true);
when(connection1.getResponse(request)).thenReturn(expectedResponse);
WebResponse response = webConnection.getResponse(request);
assertThat(response, sameInstance(expectedResponse));
verify(matcher1).matches(request);
verifyNoMoreInteractions(matcher2, connection2, defaultConnection);
verify(connection1).getResponse(request);
}
use of com.gargoylesoftware.htmlunit.WebResponse in project spring-framework by spring-projects.
the class DelegatingWebConnectionTests method setup.
@Before
public void setup() throws Exception {
request = new WebRequest(new URL("http://localhost/"));
WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.<NameValuePair>emptyList());
expectedResponse = new WebResponse(data, request, 100L);
webConnection = new DelegatingWebConnection(defaultConnection, new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
}
Aggregations