OffHeapByteBufferStore implements OffHeapStore { public void free() { for (int i = 0; i < bufferSize; i++) { free(i); } } OffHeapByteBufferStore(int capacity, int bufferSize);  OffHeapByteBufferStore(int capacity, int bufferSize, int concurrencyLevel); byte[] retrieve(Pointer pointer); byte[] remove(Pointer pointer); Pointer store(byte[] payload, long expiry); Pointer update(final Pointer pointer, final byte[] payload, final long expiry); long dirtyMemory(); long usedMemory(); long freeMemory(); void free(); void free(int bufferIndex);  }
@Test public void free() { bufferStore.free(); verify(bufferStore).free(anyInt()); assertEquals(1, bufferStore.availableBuffers.size()); }
@Test public void freeWithIndex() { bufferStore.buffers = new OffHeapByteBuffer[]{buffer}; bufferStore.availableBuffers = queue; doReturn(true).when(queue).add(anyInt()); doNothing().when(buffer).free(); bufferStore.free(0); verify(buffer).free(); verify(queue).add(anyInt()); }