use of net.morimekta.test.providence.service.Response in project providence by morimekta.
the class ProvidenceServletTest method testSimpleRequest.
@Test
public void testSimpleRequest() throws IOException, Failure {
AtomicBoolean called = new AtomicBoolean();
when(impl.test(any(Request.class))).thenAnswer(i -> {
called.set(true);
return new Response("response");
});
TestService.Iface client = new TestService.Client(new HttpClientHandler(this::endpoint, factory(), provider));
Response response = client.test(new Request("request"));
waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called);
assertNotNull(response);
assertEquals("{text:\"response\"}", response.asString());
verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class));
verifyNoMoreInteractions(instrumentation);
}
use of net.morimekta.test.providence.service.Response in project providence by morimekta.
the class ProvidenceServlet_ThriftClientTest method testThriftClient.
@Test
public void testThriftClient() throws TException, IOException, Failure {
ApacheHttpTransport transport = new ApacheHttpTransport();
THttpClient httpClient = new THttpClient(endpoint().toString(), transport.getHttpClient());
TBinaryProtocol protocol = new TBinaryProtocol(httpClient);
net.morimekta.test.thrift.service.TestService.Iface client = new net.morimekta.test.thrift.service.TestService.Client(protocol);
doAnswer(i -> new Response("reply")).when(impl).test(any(Request.class));
net.morimekta.test.thrift.service.Response response = client.test(new net.morimekta.test.thrift.service.Request("call"));
assertThat(response.getText(), is("reply"));
verify(impl).test(any(Request.class));
verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class));
verifyNoMoreInteractions(impl, instrumentation);
}
Aggregations