Search in sources :

Example 1 with MyService2

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

the class SocketClientHandlerTest method testSimpleRequest_wrongMethod.

@Test
public void testSimpleRequest_wrongMethod() throws IOException, TException, Failure, InterruptedException {
    when(impl.test(any(net.morimekta.test.thrift.thrift.service.Request.class))).thenThrow(new net.morimekta.test.thrift.thrift.service.Failure("failure"));
    MyService2.Iface client = new MyService2.Client(new SocketClientHandler(serializer, address));
    try {
        client.testing(new Request(null));
        fail("no exception");
    } catch (PApplicationException e) {
        assertThat(e.getId(), is(UNKNOWN_METHOD));
        assertThat(e.getMessage(), is(equalTo("Invalid method name: 'testing'")));
    }
    Thread.sleep(10L);
    verifyZeroInteractions(impl);
}
Also used : MyService2(net.morimekta.test.providence.thrift.service.MyService2) PApplicationException(net.morimekta.providence.PApplicationException) Request(net.morimekta.test.providence.thrift.service.Request) Test(org.junit.Test)

Example 2 with MyService2

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

the class NonblockingSocketClientHandlerTest method testSimpleRequest_wrongMethod.

@Test
public void testSimpleRequest_wrongMethod() throws IOException, TException, Failure {
    when(impl.test(any(net.morimekta.test.thrift.thrift.service.Request.class))).thenThrow(new net.morimekta.test.thrift.thrift.service.Failure("failure"));
    try (NonblockingSocketClientHandler handler = new NonblockingSocketClientHandler(serializer, address)) {
        MyService2.Iface client = new MyService2.Client(handler);
        try {
            client.testing(new Request("test"));
            fail("no exception");
        } catch (PApplicationException e) {
            assertThat(e.getId(), is(UNKNOWN_METHOD));
            assertThat(e.getMessage(), is(equalTo("Invalid method name: 'testing'")));
        }
        verifyZeroInteractions(impl);
    }
}
Also used : MyService2(net.morimekta.test.providence.thrift.service.MyService2) PApplicationException(net.morimekta.providence.PApplicationException) Request(net.morimekta.test.providence.thrift.service.Request) Test(org.junit.Test)

Aggregations

PApplicationException (net.morimekta.providence.PApplicationException)2 MyService2 (net.morimekta.test.providence.thrift.service.MyService2)2 Request (net.morimekta.test.providence.thrift.service.Request)2 Test (org.junit.Test)2