use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class NearCachePreloaderConfigTest method testSerialization.
@Test
public void testSerialization() {
config.setEnabled(true);
config.setDirectory("myParentDirectory");
config.setStoreInitialDelaySeconds(23);
config.setStoreIntervalSeconds(42);
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Data serialized = serializationService.toData(config);
NearCachePreloaderConfig deserialized = serializationService.toObject(serialized);
assertEquals(config.isEnabled(), deserialized.isEnabled());
assertEquals(config.getDirectory(), deserialized.getDirectory());
assertEquals(config.getStoreInitialDelaySeconds(), deserialized.getStoreInitialDelaySeconds());
assertEquals(config.getStoreIntervalSeconds(), deserialized.getStoreIntervalSeconds());
assertEquals(config.toString(), deserialized.toString());
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CustomSerializationOverrideDefaultTest method testUsageOfEmbeddedSerializer.
private void testUsageOfEmbeddedSerializer(final boolean allowOverride) {
final SerializationConfig config = new SerializationConfig().setAllowOverrideDefaultSerializers(allowOverride);
final SerializationService ss = new DefaultSerializationServiceBuilder().setConfig(config).build();
final Optional<Integer> answer = Optional.of(42);
final Data d = ss.toData(answer);
assertEquals(OPTIONAL_INTEGER_SIZE, d.dataSize());
final Optional<Integer> deserializedAnswer = ss.toObject(d);
assertEquals(answer, deserializedAnswer);
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CustomSerializationOverrideDefaultTest method testUsageOfCustomSerializer.
private void testUsageOfCustomSerializer(final boolean allowOverrideDefaultSerializers) {
final SerializationConfig config = new SerializationConfig().setAllowOverrideDefaultSerializers(allowOverrideDefaultSerializers);
final SerializerConfig sc = new SerializerConfig().setImplementation(new TestOptionalSerializer()).setTypeClass(Optional.class);
config.addSerializerConfig(sc);
final SerializationService ss = new DefaultSerializationServiceBuilder().setConfig(config).build();
final Optional<Integer> answer = Optional.of(42);
final Data d = ss.toData(answer);
// string Optional[Integer.MAX_VALUE] from TestOptionalSerializer
assertNotEquals(OPTIONAL_INTEGER_SIZE, d.dataSize());
final Optional<Integer> deserializedAnswer = ss.toObject(d);
assertEquals(Optional.of(Integer.MAX_VALUE), deserializedAnswer);
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CompressionTest method testCompression_externalizable.
@Test
public void testCompression_externalizable() {
DefaultSerializationServiceBuilder defaultSerializationServiceBuilder = new DefaultSerializationServiceBuilder();
SerializationService ss = defaultSerializationServiceBuilder.setEnableCompression(true).build();
SampleExternalizable expected = new SampleExternalizable(5);
Data data = ss.toData(expected);
SampleExternalizable result = ss.toObject(data);
assertEquals(expected, result);
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CompressionTest method testCompression_serializable.
@Test
public void testCompression_serializable() {
DefaultSerializationServiceBuilder defaultSerializationServiceBuilder = new DefaultSerializationServiceBuilder();
SerializationService ss = defaultSerializationServiceBuilder.setEnableCompression(true).build();
SampleSerializable expected = new SampleSerializable(5);
Data data = ss.toData(expected);
SampleSerializable result = ss.toObject(data);
assertEquals(expected, result);
}
Aggregations