Search in sources :

Example 6 with Request

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

the class BinarySerializerCompatibilityTest method testThriftToProvidence_simple.

@Test
public void testThriftToProvidence_simple() throws IOException {
    Request request = new Request("test");
    // Providence client talks to thrift service.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    thrift.serialize(baos, request);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    Request out = providence.deserialize(bais, Request.kDescriptor);
    assertThat(out, equalToMessage(request));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Request(net.morimekta.test.providence.thrift.service.Request) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 7 with Request

use of net.morimekta.test.providence.thrift.service.Request 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

Request (net.morimekta.test.providence.thrift.service.Request)7 Test (org.junit.Test)7 MyService (net.morimekta.test.providence.thrift.service.MyService)3 Iface (net.morimekta.test.thrift.thrift.service.MyService.Iface)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PApplicationException (net.morimekta.providence.PApplicationException)2 MyService2 (net.morimekta.test.providence.thrift.service.MyService2)2 ConnectException (java.net.ConnectException)1 InetSocketAddress (java.net.InetSocketAddress)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 BinarySerializer (net.morimekta.providence.serializer.BinarySerializer)1 Serializer (net.morimekta.providence.serializer.Serializer)1 Failure (net.morimekta.test.providence.thrift.service.Failure)1 Response (net.morimekta.test.providence.thrift.service.Response)1