OkHttpWritableBufferAllocator implements WritableBufferAllocator { @Override public WritableBuffer allocate(int capacityHint) { capacityHint = Math.min(MAX_BUFFER, Math.max(MIN_BUFFER, capacityHint)); return new OkHttpWritableBuffer(new Buffer(), capacityHint); } OkHttpWritableBufferAllocator(); @Override WritableBuffer allocate(int capacityHint);  }
@Test public void testCapacity() { WritableBuffer buffer = allocator().allocate(4096); assertEquals(0, buffer.readableBytes()); assertEquals(4096, buffer.writableBytes()); }
@Test public void testInitialCapacityHasMaximum() { WritableBuffer buffer = allocator().allocate(1024 * 1025); assertEquals(0, buffer.readableBytes()); assertEquals(1024 * 1024, buffer.writableBytes()); }
@Test public void testIsExactBelowMaxCapacity() { WritableBuffer buffer = allocator().allocate(4097); assertEquals(0, buffer.readableBytes()); assertEquals(4097, buffer.writableBytes()); }