Search in sources :

Example 6 with JumpToApplicationThreadServerStreamListener

use of io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener in project grpc-java by grpc.

the class ServerImplTest method onReady_errorCancelsCall.

@Test
public void onReady_errorCancelsCall() {
    JumpToApplicationThreadServerStreamListener listener = new JumpToApplicationThreadServerStreamListener(executor.getScheduledExecutorService(), stream, Context.ROOT.withCancellation());
    ServerStreamListener mockListener = mock(ServerStreamListener.class);
    listener.setListener(mockListener);
    Throwable expectedT = new AssertionError();
    doThrow(expectedT).when(mockListener).onReady();
    listener.onReady();
    try {
        executor.runDueTasks();
        fail("Expected exception");
    } catch (Throwable t) {
        assertSame(expectedT, t);
        verify(stream).close(statusCaptor.capture(), any(Metadata.class));
        assertSame(expectedT, statusCaptor.getValue().getCause());
    }
}
Also used : JumpToApplicationThreadServerStreamListener(io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener) JumpToApplicationThreadServerStreamListener(io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener) Test(org.junit.Test)

Aggregations

JumpToApplicationThreadServerStreamListener (io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener)6 Test (org.junit.Test)6 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2