Search in sources :

Example 86 with DefaultSerializationServiceBuilder

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);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) CustomSerializationTest(com.hazelcast.internal.serialization.impl.CustomSerializationTest) Test(org.junit.Test)

Example 87 with DefaultSerializationServiceBuilder

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"));
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) GenericRecordQueryReader(com.hazelcast.internal.serialization.impl.GenericRecordQueryReader) Data(com.hazelcast.internal.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) CustomSerializationTest(com.hazelcast.internal.serialization.impl.CustomSerializationTest) Test(org.junit.Test)

Example 88 with DefaultSerializationServiceBuilder

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();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) SerializationConfig(com.hazelcast.config.SerializationConfig) ClassDefinitionBuilder(com.hazelcast.nio.serialization.ClassDefinitionBuilder) QuickTest(com.hazelcast.test.annotation.QuickTest) CustomSerializationTest(com.hazelcast.internal.serialization.impl.CustomSerializationTest) Test(org.junit.Test)

Example 89 with DefaultSerializationServiceBuilder

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);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) PortableTest.createSerializationService(com.hazelcast.internal.serialization.impl.portable.PortableTest.createSerializationService) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.internal.serialization.SerializationService) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 90 with DefaultSerializationServiceBuilder

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);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) PortableTest.createSerializationService(com.hazelcast.internal.serialization.impl.portable.PortableTest.createSerializationService) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.internal.serialization.SerializationService) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)197 Test (org.junit.Test)146 QuickTest (com.hazelcast.test.annotation.QuickTest)119 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)91 Data (com.hazelcast.internal.serialization.Data)56 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)56 SerializationService (com.hazelcast.internal.serialization.SerializationService)50 SerializationService (com.hazelcast.spi.serialization.SerializationService)40 SerializationConfig (com.hazelcast.config.SerializationConfig)36 Before (org.junit.Before)22 ClassDefinitionBuilder (com.hazelcast.nio.serialization.ClassDefinitionBuilder)20 HeapData (com.hazelcast.internal.serialization.impl.HeapData)18 ClassDefinition (com.hazelcast.nio.serialization.ClassDefinition)16 CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)15 CustomSerializationTest (com.hazelcast.internal.serialization.impl.CustomSerializationTest)14 ParallelTest (com.hazelcast.test.annotation.ParallelTest)13 Parameters (junitparams.Parameters)13 ArrayList (java.util.ArrayList)12 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)10 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)9