Search in sources :

Example 51 with Config

use of com.hazelcast.config.Config in project hazelcast by hazelcast.

the class InMemoryFormatTest method testNativeNearCache_throwsException.

@Test(expected = IllegalArgumentException.class)
public void testNativeNearCache_throwsException() throws Exception {
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setInMemoryFormat(InMemoryFormat.NATIVE);
    Config config = getConfig();
    config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
    HazelcastInstance member = createHazelcastInstance(config);
    member.getMap("default");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 52 with Config

use of com.hazelcast.config.Config in project hazelcast by hazelcast.

the class InMemoryFormatTest method testNativeIMap_throwsException.

@Test(expected = IllegalArgumentException.class)
public void testNativeIMap_throwsException() throws Exception {
    Config config = getConfig();
    config.getMapConfig("default").setInMemoryFormat(InMemoryFormat.NATIVE);
    HazelcastInstance member = createHazelcastInstance(config);
    member.getMap("default");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 53 with Config

use of com.hazelcast.config.Config in project hazelcast by hazelcast.

the class InterceptorTest method testMapInterceptor.

@Test
public void testMapInterceptor() throws InterruptedException {
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
    Config config = getConfig();
    HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(config);
    HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(config);
    final IMap<Object, Object> map = instance1.getMap("testMapInterceptor");
    SimpleInterceptor interceptor = new SimpleInterceptor();
    String id = map.addInterceptor(interceptor);
    map.put(1, "New York");
    map.put(2, "Istanbul");
    map.put(3, "Tokyo");
    map.put(4, "London");
    map.put(5, "Paris");
    map.put(6, "Cairo");
    map.put(7, "Hong Kong");
    try {
        map.remove(1);
    } catch (Exception ignore) {
    }
    try {
        map.remove(2);
    } catch (Exception ignore) {
    }
    assertEquals(6, map.size());
    assertEquals(null, map.get(1));
    assertEquals(map.get(2), "ISTANBUL:");
    assertEquals(map.get(3), "TOKYO:");
    assertEquals(map.get(4), "LONDON:");
    assertEquals(map.get(5), "PARIS:");
    assertEquals(map.get(6), "CAIRO:");
    assertEquals(map.get(7), "HONG KONG:");
    map.removeInterceptor(id);
    map.put(8, "Moscow");
    assertEquals(map.get(8), "Moscow");
    assertEquals(map.get(1), null);
    assertEquals(map.get(2), "ISTANBUL");
    assertEquals(map.get(3), "TOKYO");
    assertEquals(map.get(4), "LONDON");
    assertEquals(map.get(5), "PARIS");
    assertEquals(map.get(6), "CAIRO");
    assertEquals(map.get(7), "HONG KONG");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 54 with Config

use of com.hazelcast.config.Config in project hazelcast by hazelcast.

the class InterceptorTest method testMapInterceptorOnNewMember.

@Test
public void testMapInterceptorOnNewMember() throws InterruptedException {
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
    Config config = getConfig();
    HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(config);
    IMap<Integer, Object> map = instance1.getMap("map");
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
    }
    map.addInterceptor(new NegativeInterceptor());
    for (int i = 0; i < 100; i++) {
        assertEquals(i * -1, map.get(i));
    }
    HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(config);
    for (int i = 0; i < 100; i++) {
        assertEquals(i * -1, map.get(i));
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 55 with Config

use of com.hazelcast.config.Config in project hazelcast by hazelcast.

the class IssuesTest method testIssue174NearCacheContainsKeySingleNode.

@Test
public void testIssue174NearCacheContainsKeySingleNode() {
    int n = 1;
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(n);
    Config config = getConfig();
    config.getGroupConfig().setName("testIssue174NearCacheContainsKeySingleNode");
    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
    HazelcastInstance h = factory.newHazelcastInstance(config);
    IMap<String, String> map = h.getMap("testIssue174NearCacheContainsKeySingleNode");
    map.put("key", "value");
    assertTrue(map.containsKey("key"));
    h.shutdown();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Config (com.hazelcast.config.Config)1190 Test (org.junit.Test)838 HazelcastInstance (com.hazelcast.core.HazelcastInstance)815 QuickTest (com.hazelcast.test.annotation.QuickTest)718 ParallelTest (com.hazelcast.test.annotation.ParallelTest)648 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)361 MapConfig (com.hazelcast.config.MapConfig)341 MapStoreConfig (com.hazelcast.config.MapStoreConfig)211 CountDownLatch (java.util.concurrent.CountDownLatch)145 NightlyTest (com.hazelcast.test.annotation.NightlyTest)142 NearCacheConfig (com.hazelcast.config.NearCacheConfig)125 Before (org.junit.Before)115 AssertTask (com.hazelcast.test.AssertTask)113 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)93 MapIndexConfig (com.hazelcast.config.MapIndexConfig)91 ClientConfig (com.hazelcast.client.config.ClientConfig)83 IMap (com.hazelcast.core.IMap)81 GroupConfig (com.hazelcast.config.GroupConfig)69 ListenerConfig (com.hazelcast.config.ListenerConfig)60 JoinConfig (com.hazelcast.config.JoinConfig)59