### Question:
ByteBufferPool { public void free(ByteBuffer free) { final ReentrantLock myLock = lock; myLock.lock(); try { if (!pool.offer(free)) { discarded++; } else { free.clear(); pooled++; } } finally { myLock.unlock(); } } ByteBufferPool(String name, int limit); ByteBuffer allocate(int capacity); void free(ByteBuffer free); int getBytesAllocated(); int getCreated(); int getDiscarded(); String getName(); int getPooled(); int getReused(); int size(); @Override String toString();  }### Answer:
@Test public void testFree() { ByteBufferPool test = new ByteBufferPool("test", 100); for (int i = 0; i < 100; i++) { test.free(ByteBuffer.allocate(i)); } assertEquals(0, test.getCreated()); assertEquals(100, test.getPooled()); test.free(ByteBuffer.allocate(100)); assertEquals(100, test.getPooled()); assertEquals(100, test.size()); assertEquals(1, test.getDiscarded()); for (int i = 0; i < 100; i++) { assertEquals(i, test.allocate(i).capacity()); } assertEquals(0, test.size()); assertEquals(0, test.getCreated()); assertEquals(100, test.allocate(100).capacity()); assertEquals(1, test.getCreated()); assertEquals(0, test.size()); }