Search in sources :

Example 96 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class EntryOperation method innerBeforeRun.

@Override
public void innerBeforeRun() throws Exception {
    super.innerBeforeRun();
    final SerializationService serializationService = getNodeEngine().getSerializationService();
    final ManagedContext managedContext = serializationService.getManagedContext();
    managedContext.initialize(entryProcessor);
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) ManagedContext(com.hazelcast.core.ManagedContext)

Example 97 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class BinaryCompatibilityTest method readAndVerifyBinaries.

@Test
public void readAndVerifyBinaries() throws IOException {
    String key = createObjectKey();
    SerializationService serializationService = createSerializationService();
    Object readObject = serializationService.toObject(dataMap.get(key));
    boolean equals = equals(object, readObject);
    if (!equals) {
        System.out.println(object.getClass().getSimpleName() + " : " + object + " != " + readObject);
    }
    assertTrue(equals);
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Test(org.junit.Test)

Example 98 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class PortableTest method testWriteObjectWithPortable.

@Test
public void testWriteObjectWithPortable() {
    SerializationService serializationService = createSerializationService(1);
    NamedPortable namedPortable = new NamedPortable("name", 2);
    ObjectCarryingPortable objectCarryingPortable1 = new ObjectCarryingPortable(namedPortable);
    Data data = serializationService.toData(objectCarryingPortable1);
    ObjectCarryingPortable objectCarryingPortable2 = serializationService.toObject(data);
    assertEquals(objectCarryingPortable1, objectCarryingPortable2);
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 99 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class PortableTest method testBasics.

private void testBasics(ByteOrder order, boolean allowUnsafe) {
    final SerializationService serializationService = createSerializationService(1, order, allowUnsafe);
    final SerializationService serializationService2 = createSerializationService(2, order, allowUnsafe);
    Data data;
    NamedPortable[] nn = new NamedPortable[5];
    for (int i = 0; i < nn.length; i++) {
        nn[i] = new NamedPortable("named-portable-" + i, i);
    }
    NamedPortable np = nn[0];
    data = serializationService.toData(np);
    assertEquals(np, serializationService.toObject(data));
    assertEquals(np, serializationService2.toObject(data));
    InnerPortable inner = new InnerPortable(new byte[] { 0, 1, 2 }, new char[] { 'c', 'h', 'a', 'r' }, new short[] { 3, 4, 5 }, new int[] { 9, 8, 7, 6 }, new long[] { 0, 1, 5, 7, 9, 11 }, new float[] { 0.6543f, -3.56f, 45.67f }, new double[] { 456.456, 789.789, 321.321 }, nn);
    data = serializationService.toData(inner);
    assertEquals(inner, serializationService.toObject(data));
    assertEquals(inner, serializationService2.toObject(data));
    MainPortable main = new MainPortable((byte) 113, true, 'x', (short) -500, 56789, -50992225L, 900.5678f, -897543.3678909d, "this is main portable object created for testing!", inner);
    data = serializationService.toData(main);
    assertEquals(main, serializationService.toObject(data));
    assertEquals(main, serializationService2.toObject(data));
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService)

Example 100 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class PortableTest method test_issue2172_WritePortableArray.

//https://github.com/hazelcast/hazelcast/issues/2172
@Test
public void test_issue2172_WritePortableArray() {
    final SerializationService ss = new DefaultSerializationServiceBuilder().setInitialOutputBufferSize(16).build();
    final TestObject2[] testObject2s = new TestObject2[100];
    for (int i = 0; i < testObject2s.length; i++) {
        testObject2s[i] = new TestObject2();
    }
    final TestObject1 testObject1 = new TestObject1(testObject2s);
    ss.toData(testObject1);
}
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)

Aggregations

SerializationService (com.hazelcast.spi.serialization.SerializationService)120 Test (org.junit.Test)59 QuickTest (com.hazelcast.test.annotation.QuickTest)56 Data (com.hazelcast.nio.serialization.Data)54 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)46 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)28 ParallelTest (com.hazelcast.test.annotation.ParallelTest)22 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)18 HeapData (com.hazelcast.internal.serialization.impl.HeapData)17 Map (java.util.Map)15 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)10 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)9 ClientDelegatingFuture (com.hazelcast.client.util.ClientDelegatingFuture)8 Node (com.hazelcast.instance.Node)7 SerializationConfig (com.hazelcast.config.SerializationConfig)6 ICacheService (com.hazelcast.cache.impl.ICacheService)5 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)5 Record (com.hazelcast.map.impl.record.Record)5 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)3