PooledByteBufferOutputStream extends OutputStream implements AutoCloseable { public PooledByteBuffer getPooledByteBuffer() { PooledByteBuffer pooledByteBuffer = getCurrentPooledBuffer(); pooledByteBuffer.getByteBuffer().flip(); return pooledByteBuffer; } @Inject  PooledByteBufferOutputStream(final ByteBufferPool byteBufferPool,
                                        @Assisted final int initialCapacity); PooledByteBuffer getPooledByteBuffer(); @Override void write(int b); @Override void write(byte[] b); void release(); void clear(); @Override void close(); @Override String toString();  }
@Test void testWrite_noWrites() { ByteBufferPool byteBufferPool = getByteBufferPool(); PooledByteBufferOutputStream pooledByteBufferOutputStream = new PooledByteBufferOutputStream( byteBufferPool, 2); int initialCapacity = pooledByteBufferOutputStream.getPooledByteBuffer().getByteBuffer().capacity(); PooledByteBuffer pooledByteBuffer = pooledByteBufferOutputStream.getPooledByteBuffer(); assertThat(pooledByteBuffer.getByteBuffer().capacity()) .isEqualTo(initialCapacity); }