use of net.morimekta.test.providence.service.Failure in project providence by morimekta.
the class ProvidenceServletTest method testSimpleRequest_exception.
@Test
public void testSimpleRequest_exception() throws IOException, Failure {
AtomicBoolean called = new AtomicBoolean();
when(impl.test(any(Request.class))).thenAnswer(i -> {
called.set(true);
throw Failure.builder().setText("failure").build();
});
TestService.Iface client = new TestService.Client(new HttpClientHandler(this::endpoint, factory(), provider));
try {
client.test(new Request("request"));
fail("No exception");
} catch (Failure ex) {
assertEquals("failure", ex.getText());
}
waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called);
verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class));
verifyNoMoreInteractions(instrumentation);
}
use of net.morimekta.test.providence.service.Failure in project providence by morimekta.
the class ProvidenceServlet_ThriftClientTest method testThriftClient_failure.
@Test
public void testThriftClient_failure() 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);
AtomicBoolean called = new AtomicBoolean();
doAnswer(i -> {
called.set(true);
throw new Failure("test");
}).when(impl).voidMethod(55);
try {
client.voidMethod(55);
} catch (net.morimekta.test.thrift.service.Failure e) {
assertEquals("test", e.getText());
}
waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called);
verify(impl).voidMethod(55);
verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class));
verifyNoMoreInteractions(impl, instrumentation);
}
Aggregations