Search in sources :

Example 21 with MultiMap

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

Example 22 with MultiMap

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

the class ClientMultiMapTest method testContainsValue_whenNotExists.

@Test
public void testContainsValue_whenNotExists() {
    final MultiMap mm = client.getMultiMap(randomString());
    assertFalse(mm.containsValue("NOT_THERE"));
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with MultiMap

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

the class ClientMultiMapLockTest method testForceUnlock_whenKeyLockedTwice.

@Test
public void testForceUnlock_whenKeyLockedTwice() {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "Key";
    mm.lock(key);
    mm.lock(key);
    mm.forceUnlock(key);
    assertFalse(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 24 with MultiMap

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

the class ClientMultiMapLockTest method testTryLockWaitingOnLockedKey_thenKeyUnlockedByOtherThread.

@Test
public void testTryLockWaitingOnLockedKey_thenKeyUnlockedByOtherThread() {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "keyZ";
    mm.lock(key);
    final CountDownLatch tryLockReturnsTrue = new CountDownLatch(1);
    new Thread() {

        public void run() {
            try {
                if (mm.tryLock(key, 10, TimeUnit.SECONDS)) {
                    tryLockReturnsTrue.countDown();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }.start();
    mm.unlock(key);
    assertOpenEventually(tryLockReturnsTrue);
    assertTrue(mm.isLocked(key));
}
Also used : MultiMap(com.hazelcast.multimap.MultiMap) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 25 with MultiMap

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

the class ClientMultiMapLockTest method testLockTTLExpired_whenLockedBySelf.

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

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