Search in sources :

Example 16 with DefaultSerializationServiceBuilder

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

the class PortableTest method testWriteObjectWithCustomSerializable.

@Test
public void testWriteObjectWithCustomSerializable() {
    SerializationConfig config = new SerializationConfig();
    SerializerConfig sc = new SerializerConfig().setImplementation(new CustomSerializationTest.FooXmlSerializer()).setTypeClass(CustomSerializationTest.Foo.class);
    config.addSerializerConfig(sc);
    SerializationService serializationService = new DefaultSerializationServiceBuilder().setPortableVersion(1).addPortableFactory(PORTABLE_FACTORY_ID, new TestPortableFactory()).setConfig(config).build();
    CustomSerializationTest.Foo foo = new CustomSerializationTest.Foo("f");
    ObjectCarryingPortable objectCarryingPortable1 = new ObjectCarryingPortable(foo);
    Data data = serializationService.toData(objectCarryingPortable1);
    ObjectCarryingPortable objectCarryingPortable2 = serializationService.toObject(data);
    assertEquals(objectCarryingPortable1, objectCarryingPortable2);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializerConfig(com.hazelcast.config.SerializerConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 17 with DefaultSerializationServiceBuilder

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

the class PortableTest method testClassDefinitionLookupLittleEndianHeapData.

@Test
public void testClassDefinitionLookupLittleEndianHeapData() throws IOException {
    InternalSerializationService ss = new DefaultSerializationServiceBuilder().setByteOrder(ByteOrder.LITTLE_ENDIAN).build();
    testClassDefinitionLookup(ss);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with DefaultSerializationServiceBuilder

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

the class PortableTest method test_1096_ByteArrayContentSame.

//https://github.com/hazelcast/hazelcast/issues/1096
@Test
public void test_1096_ByteArrayContentSame() {
    SerializationService ss = new DefaultSerializationServiceBuilder().addPortableFactory(PORTABLE_FACTORY_ID, new TestPortableFactory()).build();
    assertRepeatedSerialisationGivesSameByteArrays(ss, new NamedPortable("issue-1096", 1096));
    assertRepeatedSerialisationGivesSameByteArrays(ss, new InnerPortable(new byte[3], new char[5], new short[2], new int[10], new long[7], new float[9], new double[1], new NamedPortable[] { new NamedPortable("issue-1096", 1096) }));
    assertRepeatedSerialisationGivesSameByteArrays(ss, new RawDataPortable(1096L, "issue-1096".toCharArray(), new NamedPortable("issue-1096", 1096), 1096, "issue-1096", new ByteArrayDataSerializable(new byte[1])));
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with DefaultSerializationServiceBuilder

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

the class SerializationTest method testVersionedDataSerializable_outputHasUnknownVersion.

@Test
public void testVersionedDataSerializable_outputHasUnknownVersion() {
    SerializationService ss = new DefaultSerializationServiceBuilder().build();
    VersionedDataSerializable object = new VersionedDataSerializable();
    ss.toData(object);
    assertEquals("ObjectDataOutput.getVersion should be UNKNOWN", Version.UNKNOWN, object.getVersion());
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationService(com.hazelcast.spi.serialization.SerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with DefaultSerializationServiceBuilder

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

the class CustomSerializationTest method testSerializer.

private void testSerializer(ByteOrder order, boolean allowUnsafe) throws Exception {
    SerializationConfig config = new SerializationConfig();
    config.setAllowUnsafe(allowUnsafe).setByteOrder(order).setUseNativeByteOrder(false);
    SerializerConfig sc = new SerializerConfig().setImplementation(new FooXmlSerializer()).setTypeClass(Foo.class);
    config.addSerializerConfig(sc);
    SerializationService ss = new DefaultSerializationServiceBuilder().setConfig(config).build();
    Foo foo = new Foo("f");
    Data d = ss.toData(foo);
    Foo newFoo = ss.toObject(d);
    assertEquals(newFoo, foo);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializerConfig(com.hazelcast.config.SerializerConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) SerializationService(com.hazelcast.spi.serialization.SerializationService)

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