@Test
public void testClientClose() throws Exception
{

    final Timing timing = new Timing();
    CuratorFramework client1 = null;
    CuratorFramework client2 = null;
    InterProcessSemaphoreV2 semaphore1;
    InterProcessSemaphoreV2 semaphore2;
    try
    {
        client1 = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
        client2 = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
        client1.start();
        client2.start();
        semaphore1 = new InterProcessSemaphoreV2(client1, "/test", 1);
        semaphore2 = new InterProcessSemaphoreV2(client2, "/test", 1);
        Lease lease = semaphore2.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS);
        Assert.assertNotNull(lease);
        lease.close();
        lease = semaphore1.acquire(10, TimeUnit.SECONDS);
        Assert.assertNotNull(lease);
        client1.close();    // should release any held leases
        client1 = null;
        Assert.assertNotNull(semaphore2.acquire(timing.forWaiting().seconds(), TimeUnit.SECONDS));
    }
    finally
    {
        TestCleanState.closeAndTestClean(client1);
        TestCleanState.closeAndTestClean(client2);
    }
}