use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class SerializerHookLoaderTest method testLoad_withParametrizedConstructorAndCompatibilitySwitchOn.
@Test
public void testLoad_withParametrizedConstructorAndCompatibilitySwitchOn() {
String propName = "hazelcast.compat.serializers.use.default.constructor.only";
String origProperty = System.getProperty(propName);
try {
System.setProperty(propName, "true");
SerializerConfig serializerConfig = new SerializerConfig();
serializerConfig.setClassName("com.hazelcast.internal.serialization.impl.TestSerializerHook$TestSerializerWithTypeConstructor");
serializerConfig.setTypeClassName("com.hazelcast.internal.serialization.impl.SampleIdentifiedDataSerializable");
SerializationConfig serializationConfig = getConfig().getSerializationConfig();
serializationConfig.addSerializerConfig(serializerConfig);
SerializerHookLoader hook = new SerializerHookLoader(serializationConfig, classLoader);
Map<Class, Object> serializers = hook.getSerializers();
TestSerializerHook.TestSerializerWithTypeConstructor serializer = (TestSerializerHook.TestSerializerWithTypeConstructor) serializers.get(SampleIdentifiedDataSerializable.class);
assertNull(serializer.getClazz());
} finally {
if (origProperty != null) {
System.setProperty(propName, origProperty);
} else {
System.clearProperty(propName);
}
}
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class AbstractGenericRecordIntegrationTest method testPutWithoutFactory_readAsGenericRecord.
@Test
public void testPutWithoutFactory_readAsGenericRecord() {
MainPortable expectedPortable = createMainPortable();
GenericRecord expected = createGenericRecord(expectedPortable);
assertEquals(expectedPortable.c, expected.getChar("c"));
assertEquals(expectedPortable.f, expected.getFloat32("f"), 0.1);
HazelcastInstance[] instances = createCluster();
IMap<Object, Object> clusterMap = instances[0].getMap("test");
clusterMap.put(1, expected);
HazelcastInstance instance = createAccessorInstance(new SerializationConfig());
IMap<Object, Object> map = instance.getMap("test");
GenericRecord actual = (GenericRecord) map.get(1);
assertEquals(expected, actual);
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class AbstractGenericRecordIntegrationTest method testEntryProcessorReturnsGenericRecord.
@Test
public void testEntryProcessorReturnsGenericRecord() {
HazelcastInstance[] instances = createCluster();
HazelcastInstance instance = createAccessorInstance(serializationConfig);
IMap<Object, Object> map = instance.getMap("test");
NamedPortable expected = new NamedPortable("foo", 900);
String key = generateKeyOwnedBy(instances[0]);
map.put(key, expected);
Object returnValue = map.executeOnKey(key, (EntryProcessor<Object, Object, Object>) entry -> {
Object value = entry.getValue();
GenericRecord genericRecord = (GenericRecord) value;
GenericRecord modifiedGenericRecord = genericRecord.newBuilder().setString("name", "bar").setInt32("myint", 4).build();
entry.setValue(modifiedGenericRecord);
return genericRecord.getInt32("myint");
});
assertEquals(expected.myint, returnValue);
NamedPortable actualPortable = (NamedPortable) map.get(key);
assertEquals("bar", actualPortable.name);
assertEquals(4, actualPortable.myint);
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class AbstractGenericRecordIntegrationTest method testInconsistentClassDefinitionOfNestedPortableFields_whenCheckClassDefErrorsIsFalse.
@Test
public void testInconsistentClassDefinitionOfNestedPortableFields_whenCheckClassDefErrorsIsFalse() {
createCluster();
SerializationConfig serializationConfig = new SerializationConfig(this.serializationConfig);
serializationConfig.setCheckClassDefErrors(false);
HazelcastInstance instance = createAccessorInstance(serializationConfig);
IMap<Object, Object> map = instance.getMap("test");
BiTuple<GenericRecord, GenericRecord> records = getInconsistentNestedGenericRecords();
map.put(1, records.element1);
map.put(2, records.element2);
}
use of com.hazelcast.config.SerializationConfig in project hazelcast by hazelcast.
the class DefaultPortableReaderQuickTest method reader.
//
// Utilities
//
public GenericRecordQueryReader reader(Portable portable) throws IOException {
SerializationConfig serializationConfig = new SerializationConfig();
serializationConfig.addPortableFactory(TestPortableFactory.ID, new TestPortableFactory());
InternalSerializationService ss = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
ss.toData(NON_EMPTY_PORSCHE);
return new GenericRecordQueryReader(ss.readAsInternalGenericRecord(ss.toData(portable)));
}
Aggregations