Search in sources :

Example 11 with HttpResponse

use of org.apache.hc.core5.http.HttpResponse in project pact-jvm by DiUS.

the class V4HttpPactTest method runTest.

@Test
void runTest(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\"}")));
}
Also used : ClassicHttpResponse(org.apache.hc.core5.http.ClassicHttpResponse) Test(org.junit.jupiter.api.Test)

Example 12 with HttpResponse

use of org.apache.hc.core5.http.HttpResponse in project pact-jvm by DiUS.

the class PactProviderWithMultipleFragmentsTest method runTestWithPactVerificationsAndDefaultResponseValuesArePresent.

@Test
@PactVerifications({ @PactVerification(value = "test_provider2", fragment = "createFragment2") })
public void runTestWithPactVerificationsAndDefaultResponseValuesArePresent() throws IOException {
    HttpResponse httpResponse = Request.get(mockTestProvider2.getUrl()).addHeader("testreqheader", "testreqheadervalue").execute().returnResponse();
    assertThat(Arrays.stream(httpResponse.getHeaders("testresheader")).map(Header::getValue).collect(Collectors.toList()), is(equalTo(List.of("testresheadervalue"))));
}
Also used : Header(org.apache.hc.core5.http.Header) HttpResponse(org.apache.hc.core5.http.HttpResponse) Test(org.junit.Test) PactVerifications(au.com.dius.pact.consumer.junit.PactVerifications)

Aggregations

Test (org.junit.jupiter.api.Test)8 ClassicHttpResponse (org.apache.hc.core5.http.ClassicHttpResponse)7 HttpResponse (org.apache.hc.core5.http.HttpResponse)3 Header (org.apache.hc.core5.http.Header)2 PactVerifications (au.com.dius.pact.consumer.junit.PactVerifications)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 SimpleHttpRequest (org.apache.hc.client5.http.async.methods.SimpleHttpRequest)1 SimpleHttpResponse (org.apache.hc.client5.http.async.methods.SimpleHttpResponse)1 BasicCookieStore (org.apache.hc.client5.http.cookie.BasicCookieStore)1 Cookie (org.apache.hc.client5.http.cookie.Cookie)1 HttpAsyncClientBuilder (org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder)1 PoolingAsyncClientConnectionManager (org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager)1 HttpClientContext (org.apache.hc.client5.http.protocol.HttpClientContext)1 RedirectStrategy (org.apache.hc.client5.http.protocol.RedirectStrategy)1 DefaultClientTlsStrategy (org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy)1 FutureCallback (org.apache.hc.core5.concurrent.FutureCallback)1 HttpRequest (org.apache.hc.core5.http.HttpRequest)1 BasicNameValuePair (org.apache.hc.core5.http.message.BasicNameValuePair)1 TlsStrategy (org.apache.hc.core5.http.nio.ssl.TlsStrategy)1 HttpContext (org.apache.hc.core5.http.protocol.HttpContext)1