Search in sources :

Example 6 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class MBeanDestroyTest method testReplicatedMap.

@Test
public void testReplicatedMap() throws Exception {
    String replicatedMapName = randomString();
    ReplicatedMap replicatedMap = holder.getHz().getReplicatedMap(replicatedMapName);
    replicatedMap.size();
    holder.assertMBeanExistEventually("ReplicatedMap", replicatedMap.getName());
    destroyObjectAndAssert(replicatedMap, "ReplicatedMap");
}
Also used : ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class MBeanTest method testReplicatedMap.

@Test
public void testReplicatedMap() throws Exception {
    String replicatedMapName = randomString();
    ReplicatedMap replicatedMap = holder.getHz().getReplicatedMap(replicatedMapName);
    replicatedMap.size();
    holder.assertMBeanExistEventually("ReplicatedMap", replicatedMap.getName());
}
Also used : ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class ClientReplicatedMapTest method testClear.

@Test
public void testClear() {
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastClient();
    final ReplicatedMap<String, String> map1 = instance1.getReplicatedMap("default");
    final ReplicatedMap<String, String> map2 = instance2.getReplicatedMap("default");
    for (int i = 0; i < OPERATION_COUNT; i++) {
        map1.put("foo-" + i, "bar");
    }
    for (Map.Entry<String, String> entry : map2.entrySet()) {
        assertStartsWith("foo-", entry.getKey());
        assertEquals("bar", entry.getValue());
    }
    for (Map.Entry<String, String> entry : map1.entrySet()) {
        assertStartsWith("foo-", entry.getKey());
        assertEquals("bar", entry.getValue());
    }
    map1.clear();
    assertEquals(0, map1.size());
    assertEquals(0, map2.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Map(java.util.Map) ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) HashMap(java.util.HashMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class ClientReplicatedMapTest method testUpdate.

@Test
public void testUpdate() {
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastClient();
    final ReplicatedMap<String, String> map1 = instance1.getReplicatedMap("default");
    final ReplicatedMap<String, String> map2 = instance2.getReplicatedMap("default");
    for (int i = 0; i < OPERATION_COUNT; i++) {
        map1.put("foo-" + i, "bar");
    }
    for (Map.Entry<String, String> entry : map2.entrySet()) {
        assertStartsWith("foo-", entry.getKey());
        assertEquals("bar", entry.getValue());
    }
    for (Map.Entry<String, String> entry : map1.entrySet()) {
        assertStartsWith("foo-", entry.getKey());
        assertEquals("bar", entry.getValue());
    }
    for (int i = 0; i < OPERATION_COUNT; i++) {
        map2.put("foo-" + i, "bar2");
    }
    for (Map.Entry<String, String> entry : map2.entrySet()) {
        assertEquals("bar2", entry.getValue());
    }
    for (Map.Entry<String, String> entry : map1.entrySet()) {
        assertEquals("bar2", entry.getValue());
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Map(java.util.Map) ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) HashMap(java.util.HashMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class ClientReplicatedMapTest method testRemove.

@Test
public void testRemove() {
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastClient();
    final ReplicatedMap<String, String> map1 = instance1.getReplicatedMap("default");
    final ReplicatedMap<String, String> map2 = instance2.getReplicatedMap("default");
    for (int i = 0; i < OPERATION_COUNT; i++) {
        map1.put("foo-" + i, "bar");
    }
    for (Map.Entry<String, String> entry : map2.entrySet()) {
        assertStartsWith("foo-", entry.getKey());
        assertEquals("bar", entry.getValue());
    }
    for (Map.Entry<String, String> entry : map1.entrySet()) {
        assertStartsWith("foo-", entry.getKey());
        assertEquals("bar", entry.getValue());
    }
    for (int i = 0; i < OPERATION_COUNT; i++) {
        map2.remove("foo-" + i);
    }
    for (int i = 0; i < OPERATION_COUNT; i++) {
        assertNull(map2.get("foo-" + i));
    }
    for (int i = 0; i < OPERATION_COUNT; i++) {
        assertNull(map1.get("foo-" + i));
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Map(java.util.Map) ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) HashMap(java.util.HashMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ReplicatedMap (com.hazelcast.replicatedmap.ReplicatedMap)13 Test (org.junit.Test)13 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 Map (java.util.Map)6 HashMap (java.util.HashMap)5 AssertTask (com.hazelcast.test.AssertTask)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)1 Hz3Enrichment.mapUsingIMap (com.hazelcast.connector.Hz3Enrichment.mapUsingIMap)1 AsyncMap (com.hazelcast.connector.map.AsyncMap)1 Hz3MapAdapter (com.hazelcast.connector.map.Hz3MapAdapter)1 BiFunctionEx (com.hazelcast.function.BiFunctionEx)1 FunctionEx (com.hazelcast.function.FunctionEx)1 Functions.wholeItem (com.hazelcast.function.Functions.wholeItem)1 PredicateEx (com.hazelcast.function.PredicateEx)1 Job (com.hazelcast.jet.Job)1 Traversers.traverseItems (com.hazelcast.jet.Traversers.traverseItems)1 Util (com.hazelcast.jet.Util)1