Search in sources :

Example 1 with Response

use of net.morimekta.test.providence.client.Response in project providence by morimekta.

the class HttpClientHandlerTest method testSimpleRequest.

@Test
public void testSimpleRequest() throws IOException, TException, Failure {
    TestService.Iface client = new TestService.Client(new HttpClientHandler(this::endpoint, factory(), provider, instrumentation));
    when(impl.test(any(net.morimekta.test.thrift.client.Request.class))).thenReturn(new net.morimekta.test.thrift.client.Response("response"));
    Response response = client.test(new Request("request"));
    waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).until(() -> contentTypes.size() > 0);
    verify(impl).test(any(net.morimekta.test.thrift.client.Request.class));
    verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class));
    verifyNoMoreInteractions(impl, instrumentation);
    assertThat(response, is(equalToMessage(new Response("response"))));
    assertThat(contentTypes, is(equalTo(ImmutableList.of("application/vnd.apache.thrift.binary"))));
}
Also used : TestService(net.morimekta.test.providence.client.TestService) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(net.morimekta.test.providence.client.Request) Response(net.morimekta.test.providence.client.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) PServiceCall(net.morimekta.providence.PServiceCall) Test(org.junit.Test)

Example 2 with Response

use of net.morimekta.test.providence.client.Response in project providence by morimekta.

the class HttpClientHandlerTest method testSimple.

@Test
public void testSimple() throws IOException, TException, Failure {
    TestService.Iface client = new TestService.Client(new HttpClientHandler(this::endpoint));
    when(impl.test(any(net.morimekta.test.thrift.client.Request.class))).thenReturn(new net.morimekta.test.thrift.client.Response("response"));
    Response response = client.test(new Request("request"));
    waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).until(() -> contentTypes.size() > 0);
    verify(impl).test(any(net.morimekta.test.thrift.client.Request.class));
    verifyNoMoreInteractions(impl);
    assertThat(response, is(equalToMessage(new Response("response"))));
    assertThat(contentTypes, is(equalTo(ImmutableList.of("application/vnd.apache.thrift.binary"))));
}
Also used : Response(net.morimekta.test.providence.client.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) TestService(net.morimekta.test.providence.client.TestService) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(net.morimekta.test.providence.client.Request) Test(org.junit.Test)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Request (net.morimekta.test.providence.client.Request)2 Response (net.morimekta.test.providence.client.Response)2 TestService (net.morimekta.test.providence.client.TestService)2 Test (org.junit.Test)2 PServiceCall (net.morimekta.providence.PServiceCall)1