Search in sources :

Example 26 with SerializationService

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

the class JetInitDataSerializerHookTest method testSerializerHook.

@Test
public void testSerializerHook() throws Exception {
    assertFalse("Type implements java.io.Serializable", instance instanceof Serializable);
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    Data serialized = serializationService.toData(instance);
    Object deserialized = serializationService.toObject(serialized);
    assertNotSame("serialization/deserialization didn't take place", instance, deserialized);
    // compare all field using reflection
    compareFields(instance, deserialized, ignoredFields);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) Serializable(java.io.Serializable) SerializationService(com.hazelcast.internal.serialization.SerializationService) HeapData(com.hazelcast.internal.serialization.impl.HeapData) Data(com.hazelcast.internal.serialization.Data) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with SerializationService

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

the class OutboxImplTest method mockSerializationService.

private static SerializationService mockSerializationService() {
    SerializationService mock = mock(SerializationService.class);
    when(mock.toData(any())).thenReturn(mock(Data.class));
    return mock;
}
Also used : SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data)

Example 28 with SerializationService

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

the class QueryCacheIMapEventHandlingTest method executeMergeOperation.

private void executeMergeOperation(HazelcastInstance member, String mapName, int key, int mergedValue) throws Exception {
    Node node = getNode(member);
    NodeEngineImpl nodeEngine = node.nodeEngine;
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    SerializationService serializationService = getSerializationService(member);
    Data keyData = serializationService.toData(key);
    Data valueData = serializationService.toData(mergedValue);
    SplitBrainMergeTypes.MapMergeTypes mergingEntry = createMergingEntry(serializationService, keyData, valueData, Mockito.mock(Record.class), ExpiryMetadata.NULL);
    Operation mergeOperation = new MergeOperation(mapName, singletonList(mergingEntry), new PassThroughMergePolicy<>(), false);
    int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
    Future<Object> future = operationService.invokeOnPartition(SERVICE_NAME, mergeOperation, partitionId);
    future.get();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) SerializationService(com.hazelcast.internal.serialization.SerializationService) Accessors.getSerializationService(com.hazelcast.test.Accessors.getSerializationService) Data(com.hazelcast.internal.serialization.Data) Operation(com.hazelcast.spi.impl.operationservice.Operation) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) Record(com.hazelcast.map.impl.record.Record) SplitBrainMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 29 with SerializationService

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

the class WriteBehindQueueTest method createDelayedEntryList.

private List<DelayedEntry> createDelayedEntryList(int numberOfEntriesToCreate) {
    List<DelayedEntry> list = new ArrayList<DelayedEntry>(numberOfEntriesToCreate);
    SerializationService ss1 = new DefaultSerializationServiceBuilder().build();
    long storeTime = Clock.currentTimeMillis();
    for (int i = 0; i < numberOfEntriesToCreate; i++) {
        final DelayedEntry<Data, Object> e = DelayedEntries.newDeletedEntry(ss1.toData(i), storeTime, i, null);
        list.add(e);
    }
    return list;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)

Example 30 with SerializationService

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

the class EntryViewTest method testEntryViewSerialization.

@Test
public void testEntryViewSerialization() {
    ReplicatedMapEntryView entryView = createEntryView();
    SerializationServiceBuilder serializationServiceBuilder = new DefaultSerializationServiceBuilder();
    SerializationService serializationService = serializationServiceBuilder.build();
    Data data = serializationService.toData(entryView);
    ReplicatedMapEntryView deserialized = serializationService.toObject(data);
    verifyFields(deserialized);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

SerializationService (com.hazelcast.internal.serialization.SerializationService)170 Data (com.hazelcast.internal.serialization.Data)117 Test (org.junit.Test)100 QuickTest (com.hazelcast.test.annotation.QuickTest)99 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)50 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)43 ArrayList (java.util.ArrayList)15 SerializationConfig (com.hazelcast.config.SerializationConfig)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 Node (com.hazelcast.instance.impl.Node)12 CustomSerializationTest (com.hazelcast.internal.serialization.impl.CustomSerializationTest)12 Accessors.getNode (com.hazelcast.test.Accessors.getNode)12 GenericRecord (com.hazelcast.nio.serialization.GenericRecord)11 EmployeeDTO (example.serialization.EmployeeDTO)11 ExternalizableEmployeeDTO (example.serialization.ExternalizableEmployeeDTO)11 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)8 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8