Search in sources :

Example 6 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class WanReplicationConfigTest method testSerialization.

@Test
public void testSerialization() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("key", "value");
    WanConsumerConfig wanConsumerConfig = new WanConsumerConfig();
    wanConsumerConfig.setProperties(properties);
    wanConsumerConfig.setClassName("className");
    wanConsumerConfig.setImplementation("implementation");
    WanPublisherConfig wanPublisherConfig1 = new WanPublisherConfig();
    WanPublisherConfig wanPublisherConfig2 = new WanPublisherConfig();
    List<WanPublisherConfig> publisherConfigs = new LinkedList<WanPublisherConfig>();
    publisherConfigs.add(wanPublisherConfig1);
    config.setName("name");
    config.setWanConsumerConfig(wanConsumerConfig);
    config.setWanPublisherConfigs(publisherConfigs);
    config.addWanPublisherConfig(wanPublisherConfig2);
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    Data serialized = serializationService.toData(config);
    WanReplicationConfig deserialized = serializationService.toObject(serialized);
    assertWanReplicationConfig(config, deserialized);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) HashMap(java.util.HashMap) WanConsumerConfigTest.assertWanConsumerConfig(com.hazelcast.config.WanConsumerConfigTest.assertWanConsumerConfig) SerializationService(com.hazelcast.spi.serialization.SerializationService) WanPublisherConfigTest.assertWanPublisherConfig(com.hazelcast.config.WanPublisherConfigTest.assertWanPublisherConfig) Data(com.hazelcast.nio.serialization.Data) LinkedList(java.util.LinkedList) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class PartitionRuntimeStateTest method serializeAndDeserialize.

private PartitionRuntimeState serializeAndDeserialize(PartitionRuntimeState state) {
    InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    try {
        Data data = serializationService.toData(state);
        state = serializationService.toObject(data);
    } finally {
        serializationService.dispose();
    }
    return state;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) Data(com.hazelcast.nio.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 8 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class TcpIpConnection_AbstractTest method setup.

@Before
public void setup() throws Exception {
    addressA = new Address("127.0.0.1", 5701);
    addressB = new Address("127.0.0.1", 5702);
    addressC = new Address("127.0.0.1", 5703);
    loggingService = new LoggingServiceImpl("somegroup", "log4j2", BuildInfoProvider.BUILD_INFO);
    logger = loggingService.getLogger(TcpIpConnection_AbstractTest.class);
    metricsRegistryA = newMetricsRegistry();
    connManagerA = newConnectionManager(addressA.getPort(), metricsRegistryA);
    ioServiceA = (MockIOService) connManagerA.getIoService();
    metricsRegistryB = newMetricsRegistry();
    connManagerB = newConnectionManager(addressB.getPort(), metricsRegistryB);
    ioServiceB = (MockIOService) connManagerB.getIoService();
    metricsRegistryC = newMetricsRegistry();
    connManagerC = newConnectionManager(addressC.getPort(), metricsRegistryC);
    ioServiceC = (MockIOService) connManagerB.getIoService();
    serializationService = (InternalSerializationService) new DefaultSerializationServiceBuilder().addDataSerializableFactory(TestDataFactory.FACTORY_ID, new TestDataFactory()).build();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SocketAddress(java.net.SocketAddress) Address(com.hazelcast.nio.Address) LoggingServiceImpl(com.hazelcast.logging.LoggingServiceImpl) Before(org.junit.Before)

Example 9 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class EntryViewTest method testEntryViewSerialization.

@Test
public void testEntryViewSerialization() throws Exception {
    ReplicatedMapEntryView entryView = createEntryView();
    SerializationServiceBuilder serializationServiceBuilder = new DefaultSerializationServiceBuilder();
    SerializationService serializationService = serializationServiceBuilder.build();
    Data data = serializationService.toData(entryView);
    ReplicatedMapEntryView deserialized = serializationService.toObject(data);
    verifyFields(deserialized);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.

the class MemberVersionTest method testSerialization.

@Test
public void testSerialization() {
    MemberVersion given = MemberVersion.of(3, 9, 1);
    SerializationServiceV1 ss = new DefaultSerializationServiceBuilder().setVersion(SerializationServiceV1.VERSION_1).build();
    MemberVersion deserialized = ss.toObject(ss.toData(given));
    assertEquals(deserialized, given);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceV1(com.hazelcast.internal.serialization.impl.SerializationServiceV1) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)70 Test (org.junit.Test)56 QuickTest (com.hazelcast.test.annotation.QuickTest)55 SerializationService (com.hazelcast.spi.serialization.SerializationService)46 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)22 ParallelTest (com.hazelcast.test.annotation.ParallelTest)18 HeapData (com.hazelcast.internal.serialization.impl.HeapData)16 Data (com.hazelcast.nio.serialization.Data)15 SerializationConfig (com.hazelcast.config.SerializationConfig)11 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)6 ArrayList (java.util.ArrayList)6 SerializerConfig (com.hazelcast.config.SerializerConfig)5 Before (org.junit.Before)5 PartitioningStrategy (com.hazelcast.core.PartitioningStrategy)4 Config (com.hazelcast.config.Config)3 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)3 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)3 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)3 HashMap (java.util.HashMap)3 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)2