Search in sources :

Example 96 with DefaultSerializationServiceBuilder

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

the class TcpServerConnection_AbstractTest method setup.

@Before
public void setup() throws Exception {
    loggingService = new LoggingServiceImpl("somegroup", "log4j2", BuildInfoProvider.getBuildInfo(), true, null);
    logger = loggingService.getLogger(TcpServerConnection_AbstractTest.class);
    metricsRegistryA = newMetricsRegistry();
    tcpServerA = newMockTcpServer(metricsRegistryA);
    serverContextA = (MockServerContext) tcpServerA.getContext();
    addressA = serverContextA.getThisAddress();
    metricsRegistryB = newMetricsRegistry();
    tcpServerB = newMockTcpServer(metricsRegistryB);
    serverContextB = (MockServerContext) tcpServerB.getContext();
    addressB = serverContextB.getThisAddress();
    metricsRegistryC = newMetricsRegistry();
    tcpServerC = newMockTcpServer(metricsRegistryC);
    serverContextC = (MockServerContext) tcpServerC.getContext();
    addressC = serverContextC.getThisAddress();
    serializationService = new DefaultSerializationServiceBuilder().addDataSerializableFactory(TestDataFactory.FACTORY_ID, new TestDataFactory()).build();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) LoggingServiceImpl(com.hazelcast.logging.impl.LoggingServiceImpl) TestDataFactory(com.hazelcast.internal.server.TestDataFactory) Before(org.junit.Before)

Example 97 with DefaultSerializationServiceBuilder

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

the class CollectionUtilTest method testObjectToDataCollection_size.

@Test
public void testObjectToDataCollection_size() {
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    Collection<Object> list = new ArrayList<Object>();
    list.add(1);
    list.add("foo");
    Collection<Data> dataCollection = objectToDataCollection(list, serializationService);
    assertEquals(list.size(), dataCollection.size());
}
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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 98 with DefaultSerializationServiceBuilder

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

the class ClientDelegatingFuture_SerializationExceptionTest method setup.

@Before
public void setup() {
    serializationService = new DefaultSerializationServiceBuilder().build();
    key = serializationService.toData("key");
    value = invalidData;
    logger = mock(ILogger.class);
    request = MapGetCodec.encodeRequest("test", key, 1L);
    response = MapGetCodec.encodeResponse(value);
    callIdSequence = mock(CallIdSequence.class);
    invocationFuture = new ClientInvocationFuture(mock(ClientInvocation.class), request, logger, callIdSequence);
    invocationFuture.complete(response);
    delegatingFuture = new ClientDelegatingFuture<>(invocationFuture, serializationService, MapGetCodec::decodeResponse, true);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ILogger(com.hazelcast.logging.ILogger) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) Before(org.junit.Before)

Example 99 with DefaultSerializationServiceBuilder

use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder 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)

Example 100 with DefaultSerializationServiceBuilder

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

the class PortableTest method testClassDefinition_getNestedField.

@Test
public void testClassDefinition_getNestedField() throws IOException {
    InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    PortableContext portableContext = serializationService.getPortableContext();
    ChildPortableObject child = new ChildPortableObject(System.nanoTime());
    ParentPortableObject parent = new ParentPortableObject(System.currentTimeMillis(), child);
    GrandParentPortableObject grandParent = new GrandParentPortableObject(System.nanoTime(), parent);
    Data data = serializationService.toData(grandParent);
    ClassDefinition classDefinition = portableContext.lookupClassDefinition(data);
    FieldDefinition fd = portableContext.getFieldDefinition(classDefinition, "child");
    assertNotNull(fd);
    assertEquals(FieldType.PORTABLE, fd.getType());
    fd = portableContext.getFieldDefinition(classDefinition, "child.child");
    assertNotNull(fd);
    assertEquals(FieldType.PORTABLE, fd.getType());
    fd = portableContext.getFieldDefinition(classDefinition, "child.child.timestamp");
    assertNotNull(fd);
    assertEquals(FieldType.LONG, fd.getType());
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) PortableContext(com.hazelcast.internal.serialization.PortableContext) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) 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