Search in sources :

Example 1 with Failure

use of net.morimekta.test.providence.thrift.service.Failure in project providence by morimekta.

the class SocketClientHandlerTest method testSimpleRequest_exception.

@Test
public void testSimpleRequest_exception() throws IOException, TException {
    when(impl.test(any(net.morimekta.test.thrift.thrift.service.Request.class))).thenThrow(new net.morimekta.test.thrift.thrift.service.Failure("failure"));
    MyService.Iface client = new MyService.Client(new SocketClientHandler(serializer, address));
    try {
        client.test(new Request(null));
        fail("no exception");
    } catch (Failure f) {
        assertThat(f, is(equalToMessage(new Failure("failure"))));
    }
}
Also used : Iface(net.morimekta.test.thrift.thrift.service.MyService.Iface) MyService(net.morimekta.test.providence.thrift.service.MyService) Request(net.morimekta.test.providence.thrift.service.Request) Failure(net.morimekta.test.providence.thrift.service.Failure) Test(org.junit.Test)

Example 2 with Failure

use of net.morimekta.test.providence.thrift.service.Failure in project providence by morimekta.

the class NonblockingSocketClientHandlerTest method testSimpleRequest_exception.

@Test
public void testSimpleRequest_exception() throws IOException, TException {
    when(impl.test(new net.morimekta.test.thrift.thrift.service.Request("test"))).thenThrow(new net.morimekta.test.thrift.thrift.service.Failure("failure"));
    try (NonblockingSocketClientHandler handler = new NonblockingSocketClientHandler(serializer, address)) {
        MyService.Iface client = new MyService.Client(handler);
        try {
            client.test(Request.builder().setText("test").build());
            fail("no exception");
        } catch (Failure f) {
            assertThat(f, is(equalToMessage(new Failure("failure"))));
        }
    }
    verify(impl).test(any(net.morimekta.test.thrift.thrift.service.Request.class));
}
Also used : Iface(net.morimekta.test.thrift.thrift.service.MyService.Iface) Request(net.morimekta.test.providence.thrift.service.Request) MyService(net.morimekta.test.providence.thrift.service.MyService) Failure(net.morimekta.test.providence.thrift.service.Failure) Test(org.junit.Test)

Aggregations

Failure (net.morimekta.test.providence.thrift.service.Failure)2 MyService (net.morimekta.test.providence.thrift.service.MyService)2 Request (net.morimekta.test.providence.thrift.service.Request)2 Iface (net.morimekta.test.thrift.thrift.service.MyService.Iface)2 Test (org.junit.Test)2