use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class PortableTest method testClassDefinitionLookupBigEndianHeapData.
@Test
public void testClassDefinitionLookupBigEndianHeapData() throws IOException {
InternalSerializationService ss = new DefaultSerializationServiceBuilder().setByteOrder(ByteOrder.BIG_ENDIAN).build();
testClassDefinitionLookup(ss);
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class PortableTest method testSerializationService_createPortableReader.
@Test
public void testSerializationService_createPortableReader() throws IOException {
InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().build();
long timestamp1 = System.nanoTime();
ChildPortableObject child = new ChildPortableObject(timestamp1);
long timestamp2 = System.currentTimeMillis();
ParentPortableObject parent = new ParentPortableObject(timestamp2, child);
long timestamp3 = timestamp1 + timestamp2;
GrandParentPortableObject grandParent = new GrandParentPortableObject(timestamp3, parent);
Data data = serializationService.toData(grandParent);
GenericRecordQueryReader reader = new GenericRecordQueryReader(serializationService.readAsInternalGenericRecord(data));
assertEquals(grandParent.timestamp, reader.read("timestamp"));
assertEquals(parent.timestamp, reader.read("child.timestamp"));
assertEquals(child.timestamp, reader.read("child.child.timestamp"));
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class PortableTest method testClassDefinitionConfigWithErrors.
@Test
public void testClassDefinitionConfigWithErrors() throws Exception {
SerializationConfig serializationConfig = new SerializationConfig();
serializationConfig.addPortableFactory(PORTABLE_FACTORY_ID, new TestPortableFactory());
serializationConfig.setPortableVersion(1);
serializationConfig.addClassDefinition(new ClassDefinitionBuilder(PORTABLE_FACTORY_ID, TestSerializationConstants.RAW_DATA_PORTABLE, 1).addLongField("l").addCharArrayField("c").addPortableField("p", createNamedPortableClassDefinition(1)).build());
try {
new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
fail("Should throw HazelcastSerializationException!");
} catch (HazelcastSerializationException ignored) {
}
new DefaultSerializationServiceBuilder().setConfig(serializationConfig).setCheckClassDefErrors(false).build();
// -- OR --
serializationConfig.setCheckClassDefErrors(false);
new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class PortableClassVersionTest method testDifferentClassVersions.
@Test
public void testDifferentClassVersions() {
SerializationService serializationService = new DefaultSerializationServiceBuilder().addPortableFactory(FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortable();
}
}).build();
SerializationService serializationService2 = new DefaultSerializationServiceBuilder().addPortableFactory(FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortableV2();
}
}).build();
testDifferentClassVersions(serializationService, serializationService2);
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class PortableClassVersionTest method testDifferentClassAndServiceVersions.
@Test
public void testDifferentClassAndServiceVersions() {
SerializationService serializationService = new DefaultSerializationServiceBuilder().setPortableVersion(1).addPortableFactory(FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortable();
}
}).build();
SerializationService serializationService2 = new DefaultSerializationServiceBuilder().setPortableVersion(2).addPortableFactory(FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortableV2();
}
}).build();
testDifferentClassVersions(serializationService, serializationService2);
}
Aggregations