NettyWritableBufferAllocator implements WritableBufferAllocator { @Override public WritableBuffer allocate(int capacityHint) { capacityHint = Math.min(MAX_BUFFER, Math.max(MIN_BUFFER, capacityHint)); return new NettyWritableBuffer(allocator.buffer(capacityHint, capacityHint)); } NettyWritableBufferAllocator(ByteBufAllocator allocator); @Override WritableBuffer allocate(int capacityHint);  }
@Test public void testCapacityHasMinimum() { WritableBuffer buffer = allocator().allocate(100); assertEquals(0, buffer.readableBytes()); assertEquals(4096, buffer.writableBytes()); }
@Test public void testCapacityIsExactAboveMinimum() { WritableBuffer buffer = allocator().allocate(9000); assertEquals(0, buffer.readableBytes()); assertEquals(9000, buffer.writableBytes()); }
@Test public void testCapacityIsCappedAtMaximum() { WritableBuffer buffer = allocator().allocate(1024 * 1025); assertEquals(0, buffer.readableBytes()); assertEquals(1024 * 1024, buffer.writableBytes()); }