### Question:
ResourceSemaphore extends Semaphore { @Override public void release() { release(1); } ResourceSemaphore(int limit); @Override void release(); @Override void release(int permits); int used(); void close(); boolean isClosed(); @Override String toString();  }### Answer:
@Test(timeout = 1000) public void testGroup() { final ResourceSemaphore.Group g = new ResourceSemaphore.Group(3, 1); assertUsed(g, 0, 0); assertAcquire(g, true, 1, 1); assertUsed(g, 1, 1); assertAcquire(g, false, 1, 1); assertUsed(g, 1, 1); assertAcquire(g, false, 0, 1); assertUsed(g, 1, 1); assertAcquire(g, true, 1, 0); assertUsed(g, 2, 1); assertAcquire(g, true, 1, 0); assertUsed(g, 3, 1); assertAcquire(g, false, 1, 0); assertUsed(g, 3, 1); g.release(1, 1); assertUsed(g, 2, 0); g.release(2, 0); assertUsed(g, 0, 0); g.release(0, 0); assertUsed(g, 0, 0); try { g.release(1, 0); Assert.fail("Should have failed."); } catch (IllegalStateException e){ } try { g.release(0, 1); Assert.fail("Should have failed."); } catch (IllegalStateException e){ } }