use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class SerializationTest method testPartitionHash.
@Test
public void testPartitionHash() {
PartitioningStrategy partitionStrategy = new PartitioningStrategy() {
@Override
public Object getPartitionKey(Object key) {
return key.hashCode();
}
};
SerializationService ss = new DefaultSerializationServiceBuilder().build();
String obj = String.valueOf(System.nanoTime());
Data dataWithPartitionHash = ss.toData(obj, partitionStrategy);
Data dataWithOutPartitionHash = ss.toData(obj);
assertTrue(dataWithPartitionHash.hasPartitionHash());
assertNotEquals(dataWithPartitionHash.hashCode(), dataWithPartitionHash.getPartitionHash());
assertFalse(dataWithOutPartitionHash.hasPartitionHash());
assertEquals(dataWithOutPartitionHash.hashCode(), dataWithOutPartitionHash.getPartitionHash());
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class SerializationTest method testInternallySupportedClassExtended.
@Test
public void testInternallySupportedClassExtended() {
SerializationService ss = new DefaultSerializationServiceBuilder().build();
TheClassThatExtendArrayList obj = new TheClassThatExtendArrayList();
Data data = ss.toData(obj);
Object obj2 = ss.toObject(data);
assertEquals(obj2.getClass(), TheClassThatExtendArrayList.class);
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class SerializationTest method testVersionedDataSerializable_inputHasUnknownVersion.
@Test
public void testVersionedDataSerializable_inputHasUnknownVersion() {
SerializationService ss = new DefaultSerializationServiceBuilder().build();
VersionedDataSerializable object = new VersionedDataSerializable();
VersionedDataSerializable otherObject = ss.toObject(ss.toData(object));
assertEquals("ObjectDataInput.getVersion should be UNKNOWN", Version.UNKNOWN, otherObject.getVersion());
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class SerializationTest method testUnsharedJavaSerialization.
/**
* issue #1265
*/
@Test
public void testUnsharedJavaSerialization() {
SerializationService ss = new DefaultSerializationServiceBuilder().setEnableSharedObject(false).build();
Data data = ss.toData(new Foo());
Foo foo = ss.toObject(data);
Assert.assertFalse("Objects should not be identical!", foo == foo.getBar().getFoo());
}
use of com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder in project hazelcast by hazelcast.
the class SerializationTest method testArraySerialization.
@Test
public void testArraySerialization() {
SerializationService ss = new DefaultSerializationServiceBuilder().build();
byte[] array = new byte[1024];
new Random().nextBytes(array);
Data data = ss.toData(array);
byte[] deserialized = ss.toObject(data);
assertArrayEquals(array, deserialized);
}
Aggregations