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");
}
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");
}
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");
}
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));
}
}
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();
}
Aggregations