public void testLeak() throws InterruptedException { SemaphoreBoundedBuffer<Big> bb = new SemaphoreBoundedBuffer<Big>(CAPACITY); long heapSize1 = snapshotHeap(); for (int i = 0; i < CAPACITY; i++) bb.put(new Big()); for (int i = 0; i < CAPACITY; i++) bb.take(); long heapSize2 = snapshotHeap(); assertTrue(Math.abs(heapSize1 - heapSize2) < THRESHOLD); }
public void testIsFullAfterPuts() throws InterruptedException { SemaphoreBoundedBuffer<Integer> bb = new SemaphoreBoundedBuffer<Integer>(10); for (int i = 0; i < 10; i++) bb.put(i); assertTrue(bb.isFull()); assertFalse(bb.isEmpty()); }