@Test
public void testSimple2() throws Exception
{

    final int MAX_LEASES = 3;
    Timing timing = new Timing();
    List<Lease> leases = Lists.newArrayList();
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
    client.start();
    try
    {
        for ( int i = 0; i < MAX_LEASES; ++i )
        {
            InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX_LEASES);
            Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
            Assert.assertNotNull(lease);
            leases.add(lease);
        }
        InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", MAX_LEASES);
        Lease lease = semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
        Assert.assertNull(lease);
        leases.remove(0).close();
        Assert.assertNotNull(semaphore.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
    }
    finally
    {
        for ( Lease l : leases )
        {
            CloseableUtils.closeQuietly(l);
        }
        TestCleanState.closeAndTestClean(client);
    }
}