use of com.hazelcast.nio.serialization.GenericRecordBuilder in project hazelcast by hazelcast.
the class CompactStreamSerializerTest method testSchemaEvolution_GenericRecord.
@Test
public void testSchemaEvolution_GenericRecord() {
SerializationService serializationService = createSerializationService();
GenericRecordBuilder builder = compact("fooBarTypeName");
builder.setInt32("foo", 1);
builder.setInt64("bar", 1231L);
GenericRecord expectedGenericRecord = builder.build();
Data data = serializationService.toData(expectedGenericRecord);
SerializationService serializationService2 = createSerializationService();
GenericRecordBuilder builder2 = compact("fooBarTypeName");
builder2.setInt32("foo", 1);
builder2.setInt64("bar", 1231L);
builder2.setString("foobar", "new field");
serializationService2.toData(builder2.build());
Object object = serializationService2.toObject(data);
GenericRecord genericRecord = (GenericRecord) object;
assertFalse(genericRecord.hasField("foobar"));
assertEquals(1, genericRecord.getInt32("foo"));
assertEquals(1231L, genericRecord.getInt64("bar"));
}
Aggregations