Search in sources :

Example 21 with SerializationConfig

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));
        }
    });
}
Also used : PutOperation(com.hazelcast.replicatedmap.impl.operation.PutOperation) Config(com.hazelcast.config.Config) SerializationConfig(com.hazelcast.config.SerializationConfig) SerializerConfig(com.hazelcast.config.SerializerConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) IOException(java.io.IOException) SerializerConfig(com.hazelcast.config.SerializerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 22 with SerializationConfig

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);
}
Also used : Portable(com.hazelcast.nio.serialization.Portable) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SerializationConfig(com.hazelcast.config.SerializationConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 23 with SerializationConfig

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());
}
Also used : SerializationConfig(com.hazelcast.config.SerializationConfig) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) SerializerConfig(com.hazelcast.config.SerializerConfig) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) DataSerializableFactory(com.hazelcast.nio.serialization.DataSerializableFactory) DummyDataSerializableFactory(com.hazelcast.spring.serialization.DummyDataSerializableFactory) DummyPortableFactory(com.hazelcast.spring.serialization.DummyPortableFactory) DummyDataSerializableFactory(com.hazelcast.spring.serialization.DummyDataSerializableFactory) DummyPortableFactory(com.hazelcast.spring.serialization.DummyPortableFactory) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 24 with SerializationConfig

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);
}
Also used : SerializationConfig(com.hazelcast.config.SerializationConfig)

Aggregations

SerializationConfig (com.hazelcast.config.SerializationConfig)24 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Test (org.junit.Test)18 SerializerConfig (com.hazelcast.config.SerializerConfig)14 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)11 ParallelTest (com.hazelcast.test.annotation.ParallelTest)8 SerializationService (com.hazelcast.spi.serialization.SerializationService)6 ClientConfig (com.hazelcast.client.config.ClientConfig)5 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)4 HeapData (com.hazelcast.internal.serialization.impl.HeapData)3 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)3 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)3 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)3 Config (com.hazelcast.config.Config)2 PartitioningStrategy (com.hazelcast.core.PartitioningStrategy)2 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)2 ClassDefinition (com.hazelcast.nio.serialization.ClassDefinition)2 ClassDefinitionBuilder (com.hazelcast.nio.serialization.ClassDefinitionBuilder)2