Search in sources :

Example 1 with SerializationServiceV1

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

the class DefaultPortableReaderSpecTest method reader.

//
// Hazelcast init Utilities
//
public PortableReader reader(Portable portable) throws IOException {
    Config config = new Config();
    config.getSerializationConfig().addPortableFactory(TestPortableFactory.ID, new TestPortableFactory());
    HazelcastInstanceProxy hz = (HazelcastInstanceProxy) createHazelcastInstance(config);
    IMap<String, Object> map = hz.getMap("stealingMap");
    // avoid the case where there's no class definition
    if (portable instanceof PrimitivePortable) {
        map.put(P_NON_EMPTY.toString(), P_NON_EMPTY);
    }
    if (portable instanceof GroupPortable) {
        map.put(G_NON_EMPTY.toString(), G_NON_EMPTY);
    }
    if (portable instanceof NestedGroupPortable) {
        map.put(N_NON_EMPTY.toString(), N_NON_EMPTY);
    }
    map.put(portable.toString(), portable);
    EntryStealingProcessor processor = new EntryStealingProcessor(portable.toString());
    map.executeOnEntries(processor);
    SerializationServiceV1 ss = (SerializationServiceV1) hz.getSerializationService();
    return ss.createPortableReader(processor.stolenEntryData);
}
Also used : TestPortableFactory(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.TestPortableFactory) Config(com.hazelcast.config.Config) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) SerializationServiceV1(com.hazelcast.internal.serialization.impl.SerializationServiceV1) HazelcastInstanceProxy(com.hazelcast.instance.HazelcastInstanceProxy) GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)

Example 2 with SerializationServiceV1

use of com.hazelcast.internal.serialization.impl.SerializationServiceV1 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with SerializationServiceV1

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

the class DefaultPortableReaderQuickTest method reader.

//
// Utilities
//
public PortableReader reader(Portable portable) throws IOException {
    Config config = new Config();
    config.getSerializationConfig().addPortableFactory(TestPortableFactory.ID, new TestPortableFactory());
    HazelcastInstanceProxy hz = (HazelcastInstanceProxy) createHazelcastInstance(config);
    IMap<String, Object> map = hz.getMap("stealingMap");
    if (portable instanceof CarPortable) {
        // makes sure that proper class definitions are registered
        map.put(NON_EMPTY_PORSCHE.toString(), NON_EMPTY_PORSCHE);
    }
    map.put(portable.toString(), portable);
    EntryStealingProcessor processor = new EntryStealingProcessor(portable.toString());
    map.executeOnEntries(processor);
    SerializationServiceV1 ss = (SerializationServiceV1) hz.getSerializationService();
    return ss.createPortableReader(processor.stolenEntryData);
}
Also used : Config(com.hazelcast.config.Config) SerializationServiceV1(com.hazelcast.internal.serialization.impl.SerializationServiceV1) HazelcastInstanceProxy(com.hazelcast.instance.HazelcastInstanceProxy)

Example 4 with SerializationServiceV1

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

the class ClusterVersionTest method testSerialization.

@Test
public void testSerialization() {
    Version given = Version.of(3, 9);
    SerializationServiceV1 ss = new DefaultSerializationServiceBuilder().setVersion(SerializationServiceV1.VERSION_1).build();
    Version 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

SerializationServiceV1 (com.hazelcast.internal.serialization.impl.SerializationServiceV1)4 Config (com.hazelcast.config.Config)2 HazelcastInstanceProxy (com.hazelcast.instance.HazelcastInstanceProxy)2 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 GroupPortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable)1 NestedGroupPortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)1 PrimitivePortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable)1 TestPortableFactory (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.TestPortableFactory)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1