use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class SerializationIssueTest method testNullData.
@Test
public void testNullData() {
Data data = new HeapData();
SerializationService ss = new DefaultSerializationServiceBuilder().build();
assertNull(ss.toObject(data));
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class SerializationIssueTest method testVersionedDataSerializable_inputHasMemberVersion.
@Test
public void testVersionedDataSerializable_inputHasMemberVersion() {
SerializationService ss = new DefaultSerializationServiceBuilder().build();
VersionedDataSerializable object = new VersionedDataSerializable();
VersionedDataSerializable otherObject = ss.toObject(ss.toData(object));
assertEquals("ObjectDataInput.getVersion should be equal to member version", Version.of(BuildInfoProvider.getBuildInfo().getVersion()), otherObject.getVersion());
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class SerializationIssueTest method testDynamicProxySerialization_withConfiguredClassLoader.
@Test
public void testDynamicProxySerialization_withConfiguredClassLoader() {
ClassLoader current = getClass().getClassLoader();
DynamicProxyTestClassLoader cl = new DynamicProxyTestClassLoader(current);
SerializationService ss = new DefaultSerializationServiceBuilder().setClassLoader(cl).build();
IObjectA oa = (IObjectA) Proxy.newProxyInstance(current, new Class[] { IObjectA.class }, DummyInvocationHandler.INSTANCE);
Data data = ss.toData(oa);
Object o = ss.toObject(data);
Assert.assertSame("configured classloader is not used", cl, o.getClass().getClassLoader());
try {
IObjectA.class.cast(o);
Assert.fail("the serialized object should not be castable");
} catch (ClassCastException expected) {
// expected
}
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class SerializationIssueTest method testDynamicProxySerialization_withContextClassLoader.
@Test
public void testDynamicProxySerialization_withContextClassLoader() {
ClassLoader oldContextLoader = Thread.currentThread().getContextClassLoader();
try {
ClassLoader current = getClass().getClassLoader();
DynamicProxyTestClassLoader cl = new DynamicProxyTestClassLoader(current);
Thread.currentThread().setContextClassLoader(cl);
SerializationService ss = new DefaultSerializationServiceBuilder().setClassLoader(cl).build();
IObjectA oa = (IObjectA) Proxy.newProxyInstance(current, new Class[] { IObjectA.class }, DummyInvocationHandler.INSTANCE);
Data data = ss.toData(oa);
Object o = ss.toObject(data);
Assert.assertSame("context classloader is not used", cl, o.getClass().getClassLoader());
try {
IObjectA.class.cast(o);
Assert.fail("the serialized object should not be castable");
} catch (ClassCastException expected) {
// expected
}
} finally {
Thread.currentThread().setContextClassLoader(oldContextLoader);
}
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class SerializationIssueTest method testSharedJavaSerialization.
/**
* issue #1265
*/
@Test
public void testSharedJavaSerialization() {
SerializationService ss = new DefaultSerializationServiceBuilder().setEnableSharedObject(true).build();
Data data = ss.toData(new Foo());
Foo foo = (Foo) ss.toObject(data);
assertTrue("Objects are not identical!", foo == foo.getBar().getFoo());
}
Aggregations