### Question:
AbstractServerStream extends AbstractStream implements ServerStream, MessageFramer.Sink { @Override public final void writeHeaders(Metadata headers) { Preconditions.checkNotNull(headers, "headers"); headersSent = true; abstractServerStreamSink().writeHeaders(headers); } protected  AbstractServerStream(
      WritableBufferAllocator bufferAllocator, StatsTraceContext statsTraceCtx); @Override final void request(int numMessages); @Override final void writeHeaders(Metadata headers); @Override final void deliverFrame(
      WritableBuffer frame, boolean endOfStream, boolean flush, int numMessages); @Override final void close(Status status, Metadata trailers); @Override final void cancel(Status status); @Override final boolean isReady(); @Override final void setDecompressor(Decompressor decompressor); @Override Attributes getAttributes(); @Override String getAuthority(); @Override final void setListener(ServerStreamListener serverStreamListener); @Override StatsTraceContext statsTraceContext();  }### Answer:
@Test public void writeHeaders_failsOnNullHeaders() { thrown.expect(NullPointerException.class); stream.writeHeaders(null); }
@Test public void writeHeaders() { Metadata headers = new Metadata(); stream.writeHeaders(headers); verify(sink).writeHeaders(same(headers)); }
@Test public void writeMessage_dontWriteDuplicateHeaders() { stream.writeHeaders(new Metadata()); stream.writeMessage(new ByteArrayInputStream(new byte[]{})); verify(sink).writeHeaders(any(Metadata.class)); }
@Test public void writeMessage_ignoreIfFramerClosed() { stream.writeHeaders(new Metadata()); stream.endOfMessages(); reset(sink); stream.writeMessage(new ByteArrayInputStream(new byte[]{})); verify(sink, never()) .writeFrame(any(WritableBuffer.class), any(Boolean.class), any(Integer.class)); }
@Test public void writeMessage() { stream.writeHeaders(new Metadata()); stream.writeMessage(new ByteArrayInputStream(new byte[]{})); stream.flush(); verify(sink).writeFrame(any(WritableBuffer.class), eq(true), eq(1)); }