AbstractServerStream extends AbstractStream<IdT> implements ServerStream { @Override protected void receiveMessage(InputStream is) { inboundPhase(Phase.MESSAGE); listener().messageRead(is); } protected  AbstractServerStream(WritableBufferAllocator bufferAllocator,
                                 int maxMessageSize); final void setListener(ServerStreamListener listener); @Override final void writeHeaders(Metadata headers); @Override final void writeMessage(InputStream message); @Override final void close(Status status, Metadata trailers); void inboundDataReceived(ReadableBuffer frame, boolean endOfStream); void complete(); final void abortStream(Status status, boolean notifyClient); @Override boolean isClosed(); @Override Attributes attributes();  }
@Test public void receiveMessage_listenerCalled() { final ServerStreamListener streamListener = mock(ServerStreamListener.class); AbstractServerStreamBase stream = new AbstractServerStreamBase(allocator, MAX_MESSAGE_SIZE) { @Override protected ServerStreamListener listener() { return streamListener; } }; stream.receiveMessage(new ByteArrayInputStream(new byte[]{})); verify(streamListener).messageRead(isA(InputStream.class)); }
@Test public void receiveMessage_failsIfHalfClosed() { defaultStream.inboundPhase(Phase.STATUS); thrown.expect(IllegalStateException.class); defaultStream.receiveMessage(new ByteArrayInputStream(new byte[]{})); }