Search in sources :

Example 81 with MultiMap

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

the class ClientMultiMapLockTest method testLock_whenAlreadyLockedBySelf.

@Test
public void testLock_whenAlreadyLockedBySelf() {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "Key";
    mm.lock(key);
    mm.lock(key);
    assertTrue(mm.isLocked(key));
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 82 with MultiMap

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

the class ClientMultiMapTest method testSizeCount.

@Test
public void testSizeCount() {
    final Object key1 = "key1";
    final Object key2 = "key2";
    final MultiMap mm = client.getMultiMap(randomString());
    mm.put(key1, 1);
    mm.put(key1, 2);
    mm.put(key2, 1);
    mm.put(key2, 2);
    mm.put(key2, 2);
    assertEquals(4, mm.size());
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 83 with MultiMap

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

the class ClientMultiMapTest method testEmptySizeCount.

@Test
public void testEmptySizeCount() {
    final MultiMap mm = client.getMultiMap(randomString());
    assertEquals(0, mm.size());
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 84 with MultiMap

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

Example 85 with MultiMap

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

the class ClientMultiMapTest method testRemoveKeyValue.

@Test
public void testRemoveKeyValue() {
    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);
    }
    for (int i = 0; i < maxItemsPerKey; i++) {
        boolean result = mm.remove(key, i);
        assertTrue(result);
    }
}
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