use of org.apache.hc.core5.http.HttpResponse in project pact-jvm by DiUS.
the class BeforeEachTest method testPactExecutedAfterBeforeEach.
@Test
@PactTestFor(pactMethod = "pactExecutedAfterBeforeEach")
void testPactExecutedAfterBeforeEach(MockServer mockServer) throws IOException {
ClassicHttpResponse httpResponse = (ClassicHttpResponse) Request.get(mockServer.getUrl() + "/").execute().returnResponse();
assertThat(IOUtils.toString(httpResponse.getEntity().getContent()), is(equalTo(EXPECTED_RESPONSE)));
}
use of org.apache.hc.core5.http.HttpResponse in project pact-jvm by DiUS.
the class UrlEncocdedFormPostTest method testFormPost.
@Test
void testFormPost(MockServer mockServer) throws IOException {
HttpResponse httpResponse = Request.post(mockServer.getUrl() + "/form").bodyForm(new BasicNameValuePair("id", UUID.randomUUID().toString()), new BasicNameValuePair("value", "3"), new BasicNameValuePair("value", "1"), new BasicNameValuePair("value", "2")).execute().returnResponse();
assertThat(httpResponse.getCode(), is(equalTo(200)));
}
use of org.apache.hc.core5.http.HttpResponse in project pact-jvm by DiUS.
the class V4PactBuilderTest method runHttpTest.
@Test
@PactTestFor(pactMethod = "httpInteraction")
void runHttpTest(MockServer mockServer) throws IOException {
ClassicHttpResponse httpResponse = (ClassicHttpResponse) Request.get(mockServer.getUrl()).execute().returnResponse();
assertThat(httpResponse.getCode(), is(200));
assertThat(new String(httpResponse.getEntity().getContent().readAllBytes()), is(equalTo("{\"responsetest\": true, \"version\": \"v3\"}")));
}
use of org.apache.hc.core5.http.HttpResponse in project pact-jvm by DiUS.
the class NullValuesTest method testArticles.
@Test
void testArticles(MockServer mockServer) throws IOException {
ClassicHttpResponse httpResponse = (ClassicHttpResponse) Request.get(mockServer.getUrl()).execute().returnResponse();
assertThat(httpResponse.getCode(), is(equalTo(200)));
assertThat(IOUtils.toString(httpResponse.getEntity().getContent()), is(equalTo("{\"transaction\":{\"amount\":{\"amount\":null,\"currency\":null,\"salesAmount\":null,\"surchargeAmount\":null},\"description\":null}}")));
}
use of org.apache.hc.core5.http.HttpResponse in project feign by OpenFeign.
the class AsyncApacheHttp5Client method toFeignResponse.
Response toFeignResponse(SimpleHttpResponse httpResponse, Request request) {
final int statusCode = httpResponse.getCode();
final String reason = httpResponse.getReasonPhrase();
final Map<String, Collection<String>> headers = new HashMap<String, Collection<String>>();
for (final Header header : httpResponse.getHeaders()) {
final String name = header.getName();
final String value = header.getValue();
Collection<String> headerValues = headers.get(name);
if (headerValues == null) {
headerValues = new ArrayList<String>();
headers.put(name, headerValues);
}
headerValues.add(value);
}
return Response.builder().status(statusCode).reason(reason).headers(headers).request(request).body(httpResponse.getBodyBytes()).build();
}
Aggregations