@Test public void resourcePoolBlocking() throws InterruptedException { mThrown.expect(RuntimeException.class); final int POOL_SIZE = 2; @SuppressWarnings("unchecked") ConcurrentLinkedQueue<Integer> queue = mock(ConcurrentLinkedQueue.class); TestResourcePool testPool = new TestResourcePool(POOL_SIZE, queue); when(queue.isEmpty()).thenReturn(true); when(queue.poll()).thenThrow(new InterruptedException()); for (int i = 0; i < POOL_SIZE + 1; i++) { testPool.acquire(); } }
@Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); }
ResourcePool implements Pool<T> { @Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); } }
ResourcePool implements Pool<T> { @Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); } ResourcePool(int maxCapacity); protected  ResourcePool(int maxCapacity, ConcurrentLinkedQueue<T> resources); }
ResourcePool implements Pool<T> { @Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); } ResourcePool(int maxCapacity); protected  ResourcePool(int maxCapacity, ConcurrentLinkedQueue<T> resources); @Override T acquire(); @Override @Nullable T acquire(long time, TimeUnit unit); @Override abstract void close(); @Override void release(T resource); @Override int size(); }
ResourcePool implements Pool<T> { @Override public T acquire() { return acquire(WAIT_INDEFINITELY, null); } ResourcePool(int maxCapacity); protected  ResourcePool(int maxCapacity, ConcurrentLinkedQueue<T> resources); @Override T acquire(); @Override @Nullable T acquire(long time, TimeUnit unit); @Override abstract void close(); @Override void release(T resource); @Override int size();  }