Search in sources :

Example 96 with MultiMap

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

the class ClientMultiMapLockTest method testLockTTL_whenNegativeTimeout.

@Test(expected = IllegalArgumentException.class)
public void testLockTTL_whenNegativeTimeout() throws Exception {
    final MultiMap mm = client.getMultiMap(randomString());
    final Object key = "Key";
    mm.lock(key, -1, TimeUnit.MILLISECONDS);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 97 with MultiMap

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

the class ClientMultiMapLockTest method testTryLockLeaseTime_lockIsReleasedEventually.

@Test
public void testTryLockLeaseTime_lockIsReleasedEventually() throws InterruptedException {
    final MultiMap multiMap = getMultiMapForLock();
    final String key = randomString();
    multiMap.tryLock(key, 1000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            Assert.assertFalse(multiMap.isLocked(key));
        }
    }, 30);
}
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)

Example 98 with MultiMap

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

the class ClientMultiMapTest method testGet.

@Test
public void testGet() {
    final Object key = "key";
    final int maxItemsPerKey = 33;
    final MultiMap mm = client.getMultiMap(randomString());
    Set expected = new TreeSet();
    for (int i = 0; i < maxItemsPerKey; i++) {
        mm.put(key, i);
        expected.add(i);
    }
    Collection resultSet = new TreeSet(mm.get(key));
    assertEquals(expected, resultSet);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) Set(java.util.Set) TreeSet(java.util.TreeSet) TreeSet(java.util.TreeSet) Collection(java.util.Collection) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 99 with MultiMap

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

Example 100 with MultiMap

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

the class ClientMultiMapTest method testKeyValues.

@Test
public void testKeyValues() {
    final int maxKeys = 31;
    final int maxValues = 3;
    final MultiMap mm = client.getMultiMap(randomString());
    Set expected = new TreeSet();
    for (int key = 0; key < maxKeys; key++) {
        for (int val = 0; val < maxValues; val++) {
            mm.put(key, val);
            expected.add(val);
        }
    }
    Set resultSet = new TreeSet(mm.values());
    assertEquals(expected, resultSet);
}
Also used : MultiMap(com.hazelcast.core.MultiMap) Set(java.util.Set) TreeSet(java.util.TreeSet) TreeSet(java.util.TreeSet) 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