Search in sources :

Example 6 with MultiMap

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

the class ClientMultiMapListenersTest method testListenerOnKeyEntryRemove_WithOneRemove.

@Test
public void testListenerOnKeyEntryRemove_WithOneRemove() throws InterruptedException {
    final Object key = "key";
    final int maxItems = 98;
    final MultiMap mm = client.getMultiMap(randomString());
    MyEntryListener listener = new CountDownValueNotNullListener(maxItems, 1);
    final String id = mm.addEntryListener(listener, key, true);
    for (int i = 0; i < maxItems; i++) {
        mm.put(key, i);
    }
    mm.remove(key);
    assertOpenEventually(listener.removeLatch);
}
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 7 with MultiMap

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

the class ClientMultiMapListenersTest method testListenerOnKeyEntryRemoveEvent_whenValueNotIncluded.

@Test
public void testListenerOnKeyEntryRemoveEvent_whenValueNotIncluded() throws InterruptedException {
    final Object key = "key";
    final int maxItems = 62;
    final MultiMap mm = client.getMultiMap(randomString());
    MyEntryListener listener = new CountDownValueNullListener(maxItems);
    mm.addEntryListener(listener, key, false);
    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 8 with MultiMap

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

the class ClientMultiMapListenersTest method testListenerOnKey_whenOtherKeysAdded.

@Test
public void testListenerOnKey_whenOtherKeysAdded() throws InterruptedException {
    final MultiMap mm = client.getMultiMap(randomString());
    final List<EntryEvent> events = new ArrayList<EntryEvent>();
    mm.addEntryListener(new EntryAdapter() {

        @Override
        public void entryAdded(EntryEvent event) {
            events.add(event);
        }
    }, "key", true);
    mm.put("key2", "value");
    mm.put("key", "value");
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(1, events.size());
            assertEquals("key", events.get(0).getKey());
        }
    });
}
Also used : MultiMap(com.hazelcast.core.MultiMap) EntryEvent(com.hazelcast.core.EntryEvent) EntryAdapter(com.hazelcast.core.EntryAdapter) ArrayList(java.util.ArrayList) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with MultiMap

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

the class ClientMultiMapListenersTest method testListenerEntryRemoveEvent.

@Test
public void testListenerEntryRemoveEvent() throws InterruptedException {
    final int maxKeys = 25;
    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);
            mm.remove(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 10 with MultiMap

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

the class ClientMultiMapListenersTest method testAddLocalEntryListener_whenNull.

@Test(expected = UnsupportedOperationException.class)
public void testAddLocalEntryListener_whenNull() {
    final MultiMap mm = client.getMultiMap(randomString());
    mm.addLocalEntryListener(null);
}
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)117 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