use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CompressionTest method testCompression_externalizable_withArrayList.
@Test
public void testCompression_externalizable_withArrayList() {
DefaultSerializationServiceBuilder defaultSerializationServiceBuilder = new DefaultSerializationServiceBuilder();
SerializationService ss = defaultSerializationServiceBuilder.setEnableCompression(true).build();
ArrayList<SampleExternalizable> expected = new ArrayList<SampleExternalizable>();
for (int i = 0; i < 10; i++) {
expected.add(new SampleExternalizable(i));
}
Data data = ss.toData(expected);
ArrayList<SampleExternalizable> result = ss.toObject(data);
assertEquals(expected, result);
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CustomSerializationTest method testSerializer.
private void testSerializer(ByteOrder order, boolean allowUnsafe) {
SerializationConfig config = new SerializationConfig();
config.setAllowUnsafe(allowUnsafe).setByteOrder(order).setUseNativeByteOrder(false);
SerializerConfig sc = new SerializerConfig().setImplementation(new FooXmlSerializer()).setTypeClass(Foo.class);
config.addSerializerConfig(sc);
SerializationService ss = new DefaultSerializationServiceBuilder().setConfig(config).build();
Foo foo = new Foo("f");
Data d = ss.toData(foo);
Foo newFoo = ss.toObject(d);
assertEquals(newFoo, foo);
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CollectionUtilTest method testObjectToDataCollection_deserializeBack.
@Test
public void testObjectToDataCollection_deserializeBack() {
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Collection<Object> list = new ArrayList<Object>();
list.add(1);
list.add("foo");
Collection<Data> dataCollection = objectToDataCollection(list, serializationService);
Iterator<Data> it1 = dataCollection.iterator();
Iterator it2 = list.iterator();
while (it1.hasNext() && it2.hasNext()) {
assertEquals(serializationService.toObject(it1.next()), it2.next());
}
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CollectionUtilTest method testObjectToDataCollection_withNullCollection.
@Test(expected = NullPointerException.class)
public void testObjectToDataCollection_withNullCollection() {
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
objectToDataCollection(null, serializationService);
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CollectionUtilTest method testObjectToDataCollection_withNullItem.
@Test(expected = NullPointerException.class)
public void testObjectToDataCollection_withNullItem() {
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Collection<Object> list = new ArrayList<Object>();
list.add(null);
objectToDataCollection(list, serializationService);
}
Aggregations