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