Search in sources :

Example 81 with MultiMap

use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.

the class ClientMultiMapListenersTest method testListenerOnKeyEntryRemoveEvent.

@Test
public void testListenerOnKeyEntryRemoveEvent() throws InterruptedException {
    final Object key = "key";
    final int maxItems = 88;
    final MultiMap mm = client.getMultiMap(randomString());
    MyEntryListener listener = new CountDownValueNotNullListener(maxItems);
    mm.addEntryListener(listener, key, true);
    for (int i = 0; i < maxItems; i++) {
        mm.put(key, i);
        mm.remove(key, i);
    }
    assertOpenEventually(listener.removeLatch);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 82 with MultiMap

use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.

the class ClientMultiMapListenersTest method testListenerEntryAddEvent.

@Test
public void testListenerEntryAddEvent() throws InterruptedException {
    final int maxKeys = 12;
    final int maxItems = 3;
    final MultiMap mm = client.getMultiMap(randomString());
    MyEntryListener listener = new CountDownValueNotNullListener(maxKeys * maxItems);
    mm.addEntryListener(listener, true);
    for (int i = 0; i < maxKeys; i++) {
        for (int j = 0; j < maxKeys; j++) {
            mm.put(i, j);
        }
    }
    assertOpenEventually(listener.addLatch);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 83 with MultiMap

use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.

the class ClientMultiMapListenersTest method testRemoveListener.

@Test
public void testRemoveListener() throws InterruptedException {
    final MultiMap mm = client.getMultiMap(randomString());
    MyEntryListener listener = new CountDownValueNotNullListener(1);
    final String id = mm.addEntryListener(listener, true);
    assertTrue(mm.removeEntryListener(id));
}
Also used : MultiMap(com.hazelcast.core.MultiMap) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 84 with MultiMap

use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.

the class ClientMultiMapListenersTest method testListenerEntryAddEvent_whenValueNotIncluded.

@Test
public void testListenerEntryAddEvent_whenValueNotIncluded() throws InterruptedException {
    final int maxKeys = 21;
    final int maxItems = 3;
    final MultiMap mm = client.getMultiMap(randomString());
    MyEntryListener listener = new CountDownValueNullListener(maxKeys * maxItems);
    mm.addEntryListener(listener, false);
    for (int i = 0; i < maxKeys; i++) {
        for (int j = 0; j < maxKeys; j++) {
            mm.put(i, j);
        }
    }
    assertOpenEventually(listener.addLatch);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 85 with MultiMap

use of com.hazelcast.core.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);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MultiMap (com.hazelcast.core.MultiMap)118 Test (org.junit.Test)117 QuickTest (com.hazelcast.test.annotation.QuickTest)107 ParallelTest (com.hazelcast.test.annotation.ParallelTest)106 HazelcastInstance (com.hazelcast.core.HazelcastInstance)16 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)12 Map (java.util.Map)11 Config (com.hazelcast.config.Config)9 TransactionalMultiMap (com.hazelcast.core.TransactionalMultiMap)9 JobTracker (com.hazelcast.mapreduce.JobTracker)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9 HashMap (java.util.HashMap)9 TransactionContext (com.hazelcast.transaction.TransactionContext)8 SlowTest (com.hazelcast.test.annotation.SlowTest)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 AssertTask (com.hazelcast.test.AssertTask)5 Collection (java.util.Collection)5 List (java.util.List)5 Set (java.util.Set)4 TreeSet (java.util.TreeSet)4