Search in sources :

Example 16 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class ConfigFactoryTest method should_create_compact_serialization_config_with_reflective_serializer.

@Test
public void should_create_compact_serialization_config_with_reflective_serializer() {
    Map<String, TriTuple<String, String, String>> registrations = new HashMap<>();
    TriTuple<String, String, String> registration = TriTuple.of("a", "a", null);
    registrations.put("a", registration);
    CompactSerializationConfig config = ConfigFactory.newCompactSerializationConfig(true, registrations);
    assertThat(config.isEnabled()).isTrue();
    assertThat(CompactSerializationConfigAccessor.getNamedRegistrations(config)).isEqualTo(registrations);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 17 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testCompactSerializationConfig.

@Test
public void testCompactSerializationConfig() {
    CompactSerializationConfig compactSerializationConfig = config.getSerializationConfig().getCompactSerializationConfig();
    assertTrue(compactSerializationConfig.isEnabled());
    Map<String, TriTuple<String, String, String>> namedRegistrations = CompactSerializationConfigAccessor.getNamedRegistrations(compactSerializationConfig);
    assertEquals(2, namedRegistrations.size());
    String reflectivelySerializableClassName = DummyReflectiveSerializable.class.getName();
    TriTuple<String, String, String> reflectiveClassRegistration = TriTuple.of(reflectivelySerializableClassName, reflectivelySerializableClassName, null);
    TriTuple<String, String, String> actualReflectiveRegistration = namedRegistrations.get(reflectivelySerializableClassName);
    assertEquals(reflectiveClassRegistration, actualReflectiveRegistration);
    String compactSerializableClassName = DummyCompactSerializable.class.getName();
    String compactSerializerClassName = DummyCompactSerializer.class.getName();
    String typeName = "dummy";
    TriTuple<String, String, String> explicitClassRegistration = TriTuple.of(compactSerializableClassName, typeName, compactSerializerClassName);
    TriTuple<String, String, String> actualExplicitRegistration = namedRegistrations.get(typeName);
    assertEquals(explicitClassRegistration, actualExplicitRegistration);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 18 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class TestClientApplicationContext method tesCompactSerializationConfig.

@Test
public void tesCompactSerializationConfig() {
    CompactSerializationConfig compactSerializationConfig = clientWithCompactSerialization.getClientConfig().getSerializationConfig().getCompactSerializationConfig();
    assertTrue(compactSerializationConfig.isEnabled());
    Map<String, TriTuple<String, String, String>> namedRegistrations = CompactSerializationConfigAccessor.getNamedRegistrations(compactSerializationConfig);
    assertEquals(2, namedRegistrations.size());
    String reflectivelySerializableClassName = DummyReflectiveSerializable.class.getName();
    TriTuple<String, String, String> reflectiveClassRegistration = TriTuple.of(reflectivelySerializableClassName, reflectivelySerializableClassName, null);
    TriTuple<String, String, String> actualReflectiveRegistration = namedRegistrations.get(reflectivelySerializableClassName);
    assertEquals(reflectiveClassRegistration, actualReflectiveRegistration);
    String compactSerializableClassName = DummyCompactSerializable.class.getName();
    String compactSerializerClassName = DummyCompactSerializer.class.getName();
    String typeName = "dummy";
    TriTuple<String, String, String> explicitClassRegistration = TriTuple.of(compactSerializableClassName, typeName, compactSerializerClassName);
    TriTuple<String, String, String> actualExplicitRegistration = namedRegistrations.get(typeName);
    assertEquals(explicitClassRegistration, actualExplicitRegistration);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class RecordSerializationIntegrationTest method shouldSerializeAndDeserializeRecordWhenRegisteredExplicitly.

@Test
public void shouldSerializeAndDeserializeRecordWhenRegisteredExplicitly() {
    CompactSerializationConfig compactSerializationConfig = new CompactSerializationConfig();
    compactSerializationConfig.setEnabled(true).register(AllTypesRecord.class);
    HazelcastInstance instance = getDriverWithConfig(compactSerializationConfig);
    AllTypesRecord allTypesRecord = AllTypesRecord.create();
    IMap<Integer, AllTypesRecord> map = instance.getMap(randomMapName());
    map.put(1, allTypesRecord);
    AllTypesRecord loaded = map.get(1);
    assertThat(loaded).isEqualTo(allTypesRecord);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class QueryTest method tesObjectInMemoryFormatSupported_withoutClassConfig.

@Test
public void tesObjectInMemoryFormatSupported_withoutClassConfig() {
    Config config = new Config();
    MapConfig mapConfig = new MapConfig();
    mapConfig.setName("map");
    mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
    config.addMapConfig(mapConfig);
    config.getSerializationConfig().setCompactSerializationConfig(new CompactSerializationConfig().setEnabled(true));
    HazelcastInstance instance = createHazelcastInstance(config);
    IMap map = instance.getMap("map");
    map.put(1, BOND);
    map.values(sql("name == Bond"));
}
Also used : IMap(com.hazelcast.map.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) MapConfig(com.hazelcast.config.MapConfig) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) MapConfig(com.hazelcast.config.MapConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)30 Test (org.junit.Test)12 SerializationConfig (com.hazelcast.config.SerializationConfig)10 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)10 QuickTest (com.hazelcast.test.annotation.QuickTest)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)8 Config (com.hazelcast.config.Config)7 TriTuple (com.hazelcast.internal.util.TriTuple)6 MapConfig (com.hazelcast.config.MapConfig)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 IndexConfig (com.hazelcast.config.IndexConfig)4 Data (com.hazelcast.internal.serialization.Data)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 IMap (com.hazelcast.map.IMap)3 Before (org.junit.Before)3 Node (org.w3c.dom.Node)3 GenericRecordQueryReader (com.hazelcast.internal.serialization.impl.GenericRecordQueryReader)2 SchemaService (com.hazelcast.internal.serialization.impl.compact.SchemaService)2 CompactReader (com.hazelcast.nio.serialization.compact.CompactReader)2