### Question:
ReentrantDistributedLock implements Lock { @Override public boolean tryLock() { if (!lock.tryLock()) { return false; } try { if (acquire(false, false)) { return true; } lock.unlock(); return false; } catch (Exception e) { lock.unlock(); throw Throwables.propagate(e); } } ReentrantDistributedLock(ZKClient zkClient, String path); @Override void lock(); @Override void lockInterruptibly(); @Override boolean tryLock(); @Override boolean tryLock(long time, TimeUnit unit); @Override void unlock(); @Override Condition newCondition();  }### Answer:
@Test (timeout = 20000) public void testTryLock() throws InterruptedException { ZKClientService zkClient = createZKClient(); try { final ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "/trylock"); final CountDownLatch lockAcquired = new CountDownLatch(1); final CountDownLatch lockFailed = new CountDownLatch(2); Thread t = new Thread() { @Override public void run() { try { if (!lock.tryLock()) { lockFailed.countDown(); } if (!lock.tryLock(1, TimeUnit.SECONDS)) { lockFailed.countDown(); } if (lock.tryLock(5, TimeUnit.SECONDS)) { if (lock.tryLock(1, TimeUnit.SECONDS)) { if (lock.tryLock()) { lockAcquired.countDown(); lock.unlock(); } lock.unlock(); } lock.unlock(); } } catch (InterruptedException e) { LOG.error(e.getMessage(), e); } } }; lock.lock(); try { t.start(); Assert.assertTrue(lockFailed.await(5, TimeUnit.SECONDS)); } finally { lock.unlock(); } Assert.assertTrue(lockAcquired.await(2, TimeUnit.SECONDS)); t.join(); Assert.assertTrue(lock.tryLock()); lock.unlock(); } finally { zkClient.stopAndWait(); } }