AbstractServerStream extends AbstractStream<IdT> implements ServerStream { @Override public final void writeMessage(InputStream message) { if (outboundPhase() != Phase.MESSAGE) { throw new IllegalStateException("Messages are only permitted after headers and before close"); } super.writeMessage(message); } 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 writeMessage() { final AtomicBoolean sendCalled = new AtomicBoolean(); AbstractServerStreamBase stream = new AbstractServerStreamBase(allocator, MAX_MESSAGE_SIZE) { @Override protected void sendFrame(WritableBuffer frame, boolean endOfStream, boolean flush) { sendCalled.set(true); } }; stream.writeHeaders(new Metadata()); stream.writeMessage(new ByteArrayInputStream(new byte[]{})); stream.closeFramer(); assertTrue(sendCalled.get()); assertEquals(Phase.MESSAGE, stream.outboundPhase()); }