use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.
the class MemberMapRecordStateStressTest method assertFinalRecordStateIsReadPermitted.
private void assertFinalRecordStateIsReadPermitted(HazelcastInstance member, NearCache nearCache) {
InternalSerializationService ss = getSerializationService(member);
DefaultNearCache unwrap = (DefaultNearCache) nearCache.unwrap(DefaultNearCache.class);
for (int i = 0; i < KEY_SPACE; i++) {
Data key = ss.toData(i);
AbstractNearCacheRecordStore nearCacheRecordStore = (AbstractNearCacheRecordStore) unwrap.getNearCacheRecordStore();
NearCacheRecord record = nearCacheRecordStore.getRecord(key);
if (record != null) {
assertEquals(record.toString(), READ_PERMITTED, record.getRecordState());
}
}
}
use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.
the class PortableClassVersionTest method testDifferentClassAndServiceVersionsUsingDataWriteAndRead.
@Test
public void testDifferentClassAndServiceVersionsUsingDataWriteAndRead() throws Exception {
InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().setPortableVersion(1).addPortableFactory(FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortable();
}
}).build();
InternalSerializationService serializationService2 = new DefaultSerializationServiceBuilder().setPortableVersion(2).addPortableFactory(FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new NamedPortableV2();
}
}).build();
testDifferentClassVersionsUsingDataWriteAndRead(serializationService, serializationService2);
}
use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.
the class PortableTest method testRawData.
@Test
public void testRawData() {
int portableVersion = 1;
final InternalSerializationService serializationService = createSerializationService(1);
RawDataPortable p = new RawDataPortable(System.currentTimeMillis(), "test chars".toCharArray(), new NamedPortable("named portable", 34567), 9876, "Testing raw portable", new ByteArrayDataSerializable("test bytes".getBytes()));
ClassDefinitionBuilder builder = new ClassDefinitionBuilder(p.getFactoryId(), p.getClassId(), portableVersion);
builder.addLongField("l").addCharArrayField("c").addPortableField("p", createNamedPortableClassDefinition(portableVersion));
serializationService.getPortableContext().registerClassDefinition(builder.build());
final Data data = serializationService.toData(p);
assertEquals(p, serializationService.toObject(data));
}
use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.
the class PortableTest method testRawDataInvalidWrite.
@Test(expected = HazelcastSerializationException.class)
public void testRawDataInvalidWrite() {
int portableVersion = 1;
final InternalSerializationService serializationService = createSerializationService(1);
RawDataPortable p = new InvalidRawDataPortable(System.currentTimeMillis(), "test chars".toCharArray(), new NamedPortable("named portable", 34567), 9876, "Testing raw portable", new ByteArrayDataSerializable("test bytes".getBytes()));
ClassDefinitionBuilder builder = new ClassDefinitionBuilder(p.getFactoryId(), p.getClassId(), portableVersion);
builder.addLongField("l").addCharArrayField("c").addPortableField("p", createNamedPortableClassDefinition(portableVersion));
serializationService.getPortableContext().registerClassDefinition(builder.build());
final Data data = serializationService.toData(p);
assertEquals(p, serializationService.toObject(data));
}
use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.
the class PortableTest method testClassDefinitionLookupBigEndianHeapData.
@Test
public void testClassDefinitionLookupBigEndianHeapData() throws IOException {
InternalSerializationService ss = new DefaultSerializationServiceBuilder().setByteOrder(ByteOrder.BIG_ENDIAN).build();
testClassDefinitionLookup(ss);
}
Aggregations