use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class AbstractSerializationServiceTest method testToObject_ServiceInactive.
@Test
public void testToObject_ServiceInactive() throws Exception {
expectedException.expect(HazelcastSerializationException.class);
expectedException.expectCause(Is.is(IsInstanceOf.<Throwable>instanceOf(HazelcastInstanceNotActiveException.class)));
abstractSerializationService.register(StringBuffer.class, new StringBufferSerializer(false));
Data data = abstractSerializationService.toData(new StringBuffer());
abstractSerializationService.dispose();
abstractSerializationService.toObject(data);
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class AbstractSerializationServiceTest method testDeserializationForSpecificType.
@Test
public void testDeserializationForSpecificType() {
BaseClass baseObject = new BaseClass(5, "abc");
ExtendedClass extendedObject = new ExtendedClass(baseObject, 378);
Data extendedData = abstractSerializationService.toData(extendedObject);
Object deserializedObject = abstractSerializationService.toObject(extendedData);
assertEquals(extendedObject, deserializedObject);
deserializedObject = abstractSerializationService.toObject(extendedObject, BaseClass.class);
assertEquals(baseObject, deserializedObject);
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class ByteArrayObjectDataInputTest method testReadData.
@Test
public void testReadData() throws Exception {
byte[] bytesBE = { 0, 0, 0, 0, 0, 0, 0, 8, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, -1, -1, -1, -1 };
byte[] bytesLE = { 0, 0, 0, 0, 8, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, -1, -1, -1, -1 };
in.init((byteOrder == BIG_ENDIAN ? bytesBE : bytesLE), 0);
in.position(bytesLE.length - 4);
Data nullData = in.readData();
in.position(0);
Data theZeroLenghtArray = in.readData();
in.position(4);
Data data = in.readData();
assertNull(nullData);
assertEquals(0, theZeroLenghtArray.getType());
assertArrayEquals(new byte[0], theZeroLenghtArray.toByteArray());
assertArrayEquals(new byte[] { -1, -1, -1, -1, 0, 0, 0, 0 }, data.toByteArray());
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class AbstractSerializationServiceTest method testExternalizable.
@Test
public void testExternalizable() {
ExternalizableValue original = new ExternalizableValue(100);
Data data = abstractSerializationService.toData(original);
ExternalizableValue found = abstractSerializationService.toObject(data);
assertNotNull(found);
assertEquals(original.value, found.value);
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class LiteMemberMapNearCacheBasicTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(createConfig(nearCacheConfig, false));
HazelcastInstance liteMember = hazelcastFactory.newHazelcastInstance(createConfig(nearCacheConfig, true));
IMap<K, V> memberMap = member.getMap(DEFAULT_NEAR_CACHE_NAME);
IMap<K, V> liteMemberMap = liteMember.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = getMapNearCacheManager(liteMember);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContext<K, V, Data, String>(getSerializationService(member), liteMember, member, new IMapDataStructureAdapter<K, V>(liteMemberMap), new IMapDataStructureAdapter<K, V>(memberMap), true, nearCache, nearCacheManager);
}
Aggregations