Search in sources :

Example 36 with MultiMap

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

the class ClientMultiMapTest method testClear.

@Test
public void testClear() {
    final MultiMap mm = client.getMultiMap(randomString());
    final int maxKeys = 9;
    final int maxValues = 3;
    for (int key = 0; key < maxKeys; key++) {
        for (int val = 0; val < maxValues; val++) {
            mm.put(key, val);
        }
    }
    mm.clear();
    assertEquals(0, mm.size());
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 37 with MultiMap

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

the class ClientMultiMapLockTest method testForceUnlock_whenKeyNull.

@Test(expected = NullPointerException.class)
public void testForceUnlock_whenKeyNull() throws Exception {
    final MultiMap mm = client.getMultiMap(randomString());
    mm.forceUnlock(null);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 38 with MultiMap

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

the class ClientMultiMapLockTest method testTryLock_whenLockedBySelf.

@Test
public void testTryLock_whenLockedBySelf() throws Exception {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "Key";
    mm.lock(key);
    assertTrue(mm.tryLock(key));
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 39 with MultiMap

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

the class ClientMultiMapLockTest method testLockTTL_whenLockedBySelf.

@Test
public void testLockTTL_whenLockedBySelf() throws Exception {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "Key";
    mm.lock(key);
    mm.lock(key, 30, TimeUnit.SECONDS);
    assertTrue(mm.isLocked(key));
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 40 with MultiMap

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

the class ClientMultiMapLockTest method testLockTTLExpired.

@Test
public void testLockTTLExpired() throws Exception {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "Key";
    mm.lock(key, 1, TimeUnit.SECONDS);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertFalse(mm.isLocked(key));
        }
    });
}
Also used : MultiMap(com.hazelcast.core.MultiMap) AssertTask(com.hazelcast.test.AssertTask) 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