use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testLockTTL_whenNegativeTimeout.
@Test(expected = IllegalArgumentException.class)
public void testLockTTL_whenNegativeTimeout() throws Exception {
final MultiMap mm = client.getMultiMap(randomString());
final Object key = "Key";
mm.lock(key, -1, TimeUnit.MILLISECONDS);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapLockTest method testTryLockLeaseTime_lockIsReleasedEventually.
@Test
public void testTryLockLeaseTime_lockIsReleasedEventually() throws InterruptedException {
final MultiMap multiMap = getMultiMapForLock();
final String key = randomString();
multiMap.tryLock(key, 1000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Assert.assertFalse(multiMap.isLocked(key));
}
}, 30);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapTest method testGet.
@Test
public void testGet() {
final Object key = "key";
final int maxItemsPerKey = 33;
final MultiMap mm = client.getMultiMap(randomString());
Set expected = new TreeSet();
for (int i = 0; i < maxItemsPerKey; i++) {
mm.put(key, i);
expected.add(i);
}
Collection resultSet = new TreeSet(mm.get(key));
assertEquals(expected, resultSet);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapTest method testRemoveValue_whenValueNotExists.
@Test
public void testRemoveValue_whenValueNotExists() {
final Object key = "key";
final int maxItemsPerKey = 4;
final MultiMap mm = client.getMultiMap(randomString());
for (int i = 0; i < maxItemsPerKey; i++) {
mm.put(key, i);
}
boolean result = mm.remove(key, "NOT_THERE");
assertFalse(result);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapTest method testKeyValues.
@Test
public void testKeyValues() {
final int maxKeys = 31;
final int maxValues = 3;
final MultiMap mm = client.getMultiMap(randomString());
Set expected = new TreeSet();
for (int key = 0; key < maxKeys; key++) {
for (int val = 0; val < maxValues; val++) {
mm.put(key, val);
expected.add(val);
}
}
Set resultSet = new TreeSet(mm.values());
assertEquals(expected, resultSet);
}
Aggregations