use of io.atomix.core.lock.AsyncDistributedLock in project atomix by atomix.
the class DistributedLockTest method testTryLockFailWithTimeout.
/**
* Tests attempting to acquire a lock with a timeout.
*/
@Test
public void testTryLockFailWithTimeout() throws Throwable {
AsyncDistributedLock lock1 = atomix().lockBuilder("test-try-lock-fail-with-timeout", protocol()).build().async();
AsyncDistributedLock lock2 = atomix().lockBuilder("test-try-lock-fail-with-timeout", protocol()).build().async();
lock1.lock().join();
assertFalse(lock2.tryLock(Duration.ofSeconds(1)).join().isPresent());
}
use of io.atomix.core.lock.AsyncDistributedLock in project atomix by atomix.
the class DistributedLockTest method testTryLockSucceed.
/**
* Tests attempting to acquire a lock.
*/
@Test
public void testTryLockSucceed() throws Throwable {
AsyncDistributedLock lock = atomix().lockBuilder("test-try-lock-succeed", protocol()).build().async();
assertTrue(lock.tryLock().join().isPresent());
}
Aggregations