MessageDeframer implements Closeable { public void deframe(ReadableBuffer data, boolean endOfStream) { Preconditions.checkNotNull(data, "data"); boolean needToCloseData = true; try { checkNotClosed(); Preconditions.checkState(!this.endOfStream, "Past end of stream"); unprocessed.addBuffer(data); needToCloseData = false; this.endOfStream = endOfStream; deliver(); } finally { if (needToCloseData) { data.close(); } } } MessageDeframer(Listener listener, Decompressor decompressor, int maxMessageSize); void setDecompressor(Decompressor decompressor); void request(int numMessages); void deframe(ReadableBuffer data, boolean endOfStream); boolean isStalled(); @Override void close(); boolean isClosed();  }
@Test public void endOfStreamShouldNotifyEndOfStream() { deframer.deframe(buffer(new byte[0]), true); verify(listener).endOfStream(); verifyNoMoreInteractions(listener); }