}
@Test
public void testTryLockTimeout_whenLockedByOtherAndEventuallyAvailable() throws InterruptedException {
HazelcastInstance instance = createHazelcastInstance();
final ILock lock = instance.getLock(randomString());
final CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
lock.lock();
latch.countDown();
sleepSeconds(1);
lock.unlock();
}
}).start();
latch.await();
assertTrue(lock.tryLock(3, TimeUnit.SECONDS));
assertTrue(lock.isLocked());
assertTrue(lock.isLockedByCurrentThread());
}