use of io.grpc.internal.ServerCallImpl.ServerStreamListenerImpl in project grpc-java by grpc.
the class ServerCallImplTest method streamListener_messageRead_onlyOnce.
@Test
public void streamListener_messageRead_onlyOnce() {
ServerStreamListenerImpl<Long> streamListener = new ServerCallImpl.ServerStreamListenerImpl<>(call, callListener, context);
streamListener.messagesAvailable(new SingleMessageProducer(UNARY_METHOD.streamRequest(1234L)));
// canceling the call should short circuit future halfClosed() calls.
streamListener.closed(Status.CANCELLED);
streamListener.messagesAvailable(new SingleMessageProducer(UNARY_METHOD.streamRequest(1234L)));
verify(callListener).onMessage(1234L);
}
use of io.grpc.internal.ServerCallImpl.ServerStreamListenerImpl in project grpc-java by grpc.
the class ServerCallImplTest method streamListener_unexpectedRuntimeException.
@Test
public void streamListener_unexpectedRuntimeException() {
ServerStreamListenerImpl<Long> streamListener = new ServerCallImpl.ServerStreamListenerImpl<>(call, callListener, context);
doThrow(new RuntimeException("unexpected exception")).when(callListener).onMessage(any(Long.class));
InputStream inputStream = UNARY_METHOD.streamRequest(1234L);
thrown.expect(RuntimeException.class);
thrown.expectMessage("unexpected exception");
streamListener.messagesAvailable(new SingleMessageProducer(inputStream));
}
use of io.grpc.internal.ServerCallImpl.ServerStreamListenerImpl in project grpc-java by grpc.
the class ServerCallImplTest method streamListener_messageRead.
@Test
public void streamListener_messageRead() {
ServerStreamListenerImpl<Long> streamListener = new ServerCallImpl.ServerStreamListenerImpl<>(call, callListener, context);
streamListener.messagesAvailable(new SingleMessageProducer(UNARY_METHOD.streamRequest(1234L)));
verify(callListener).onMessage(1234L);
}
Aggregations