Search in sources :

Example 6 with MultiMap

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

the class MBeanDestroyTest method testMultiMap.

@Test
public void testMultiMap() throws Exception {
    MultiMap map = holder.getHz().getMultiMap("multimap");
    map.size();
    holder.assertMBeanExistEventually("MultiMap", map.getName());
    destroyObjectAndAssert(map, "MultiMap");
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with MultiMap

use of com.hazelcast.multimap.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.multimap.MultiMap) EntryEvent(com.hazelcast.core.EntryEvent) EntryAdapter(com.hazelcast.core.EntryAdapter) ArrayList(java.util.ArrayList) AssertTask(com.hazelcast.test.AssertTask) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with MultiMap

use of com.hazelcast.multimap.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.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with MultiMap

use of com.hazelcast.multimap.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 UUID 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.multimap.MultiMap) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with MultiMap

use of com.hazelcast.multimap.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.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MultiMap (com.hazelcast.multimap.MultiMap)93 Test (org.junit.Test)93 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)92 QuickTest (com.hazelcast.test.annotation.QuickTest)92 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)11 TransactionContext (com.hazelcast.transaction.TransactionContext)8 TransactionalMultiMap (com.hazelcast.transaction.TransactionalMultiMap)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 Collection (java.util.Collection)6 Set (java.util.Set)5 TreeSet (java.util.TreeSet)5 AssertTask (com.hazelcast.test.AssertTask)4 UUID (java.util.UUID)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 EntryAdapter (com.hazelcast.core.EntryAdapter)2 EntryEvent (com.hazelcast.core.EntryEvent)2 EntryListener (com.hazelcast.core.EntryListener)2 ArrayList (java.util.ArrayList)2 ClientConnectionRegistration (com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration)1 TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)1