use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLockTTL_whenNegativeTimeout.
@Test(expected = IllegalArgumentException.class)
public void testLockTTL_whenNegativeTimeout() {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key, -1, TimeUnit.MILLISECONDS);
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testForceUnlock_whenKeyLocked.
@Test
public void testForceUnlock_whenKeyLocked() {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key);
mm.forceUnlock(key);
assertFalse(mm.isLocked(key));
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testTryLock_whenLockedByOther.
@Test
public void testTryLock_whenLockedByOther() {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key1";
mm.lock(key);
final CountDownLatch tryLockFailed = new CountDownLatch(1);
new Thread() {
public void run() {
if (!mm.tryLock(key)) {
tryLockFailed.countDown();
}
}
}.start();
assertOpenEventually(tryLockFailed);
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testTryLockLeaseTime_whenLockFree.
@Test(timeout = 60000)
public void testTryLockLeaseTime_whenLockFree() throws InterruptedException {
MultiMap multiMap = getMultiMapForLock();
String key = randomString();
boolean isLocked = multiMap.tryLock(key, 1000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
assertTrue(isLocked);
}
use of com.hazelcast.multimap.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLock_whenKeyNull.
@Test(expected = NullPointerException.class)
public void testLock_whenKeyNull() {
final MultiMap mm = client.getMultiMap(randomString());
mm.lock(null);
}
Aggregations