use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class ReplicatedMapAntiEntropyTest method testMapConvergesToSameValueWhenMissingReplicationUpdate.
@Test
public void testMapConvergesToSameValueWhenMissingReplicationUpdate() throws Exception {
Config config = new Config();
SerializationConfig serializationConfig = new SerializationConfig();
SerializerConfig serializerConfig = new SerializerConfig();
serializerConfig.setTypeClassName(PutOperation.class.getName());
serializerConfig.setImplementation(new PutOperationWithNoReplicationSerializer());
serializationConfig.addSerializerConfig(serializerConfig);
config.setSerializationConfig(serializationConfig);
System.setProperty("hazelcast.serialization.custom.override", "true");
String mapName = randomMapName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
HazelcastInstance instance3 = factory.newHazelcastInstance(config);
final ReplicatedMap<Object, Object> map1 = instance1.getReplicatedMap(mapName);
final ReplicatedMap<Object, Object> map2 = instance2.getReplicatedMap(mapName);
final ReplicatedMap<Object, Object> map3 = instance3.getReplicatedMap(mapName);
final String key = generateKeyOwnedBy(instance2);
final String value = randomString();
map1.put(key, value);
assertEquals(value, map1.get(key));
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(value, map2.get(key));
assertEquals(value, map3.get(key));
}
});
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testClientPortableWithoutRegisteringToNode.
@Test
public void testClientPortableWithoutRegisteringToNode() {
hazelcastFactory.newHazelcastInstance();
final SerializationConfig serializationConfig = new SerializationConfig();
serializationConfig.addPortableFactory(5, new PortableFactory() {
public Portable create(int classId) {
return new SamplePortable();
}
});
final ClientConfig clientConfig = new ClientConfig();
clientConfig.setSerializationConfig(serializationConfig);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final IMap<Integer, SamplePortable> sampleMap = client.getMap(randomString());
sampleMap.put(1, new SamplePortable(666));
final SamplePortable samplePortable = sampleMap.get(1);
assertEquals(666, samplePortable.a);
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testSerializationConfig.
@Test
public void testSerializationConfig() {
SerializationConfig serializationConfig = config.getSerializationConfig();
assertEquals(ByteOrder.BIG_ENDIAN, serializationConfig.getByteOrder());
assertEquals(false, serializationConfig.isCheckClassDefErrors());
assertEquals(13, serializationConfig.getPortableVersion());
Map<Integer, String> dataSerializableFactoryClasses = serializationConfig.getDataSerializableFactoryClasses();
assertFalse(dataSerializableFactoryClasses.isEmpty());
assertEquals(DummyDataSerializableFactory.class.getName(), dataSerializableFactoryClasses.get(1));
Map<Integer, DataSerializableFactory> dataSerializableFactories = serializationConfig.getDataSerializableFactories();
assertFalse(dataSerializableFactories.isEmpty());
assertEquals(DummyDataSerializableFactory.class, dataSerializableFactories.get(2).getClass());
Map<Integer, String> portableFactoryClasses = serializationConfig.getPortableFactoryClasses();
assertFalse(portableFactoryClasses.isEmpty());
assertEquals(DummyPortableFactory.class.getName(), portableFactoryClasses.get(1));
Map<Integer, PortableFactory> portableFactories = serializationConfig.getPortableFactories();
assertFalse(portableFactories.isEmpty());
assertEquals(DummyPortableFactory.class, portableFactories.get(2).getClass());
Collection<SerializerConfig> serializerConfigs = serializationConfig.getSerializerConfigs();
assertFalse(serializerConfigs.isEmpty());
GlobalSerializerConfig globalSerializerConfig = serializationConfig.getGlobalSerializerConfig();
assertNotNull(globalSerializerConfig);
assertEquals(dummySerializer, globalSerializerConfig.getImplementation());
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class XmlClientConfigBuilder method handleSerialization.
private void handleSerialization(Node node) {
SerializationConfig serializationConfig = parseSerialization(node);
clientConfig.setSerializationConfig(serializationConfig);
}
Aggregations