use of com.hazelcast.nio.serialization.compact.CompactReader in project hazelcast by hazelcast.
the class CompactStreamSerializerTest method testSchemaEvolution_fieldRemoved.
@Test
public void testSchemaEvolution_fieldRemoved() {
SerializationConfig serializationConfig = new SerializationConfig();
// Using this registration to mimic schema evolution. This is usage is not advised.
serializationConfig.getCompactSerializationConfig().setEnabled(true).register(EmployeeDTO.class, EmployeeDTO.class.getName(), new CompactSerializer<EmployeeDTO>() {
@Nonnull
@Override
public EmployeeDTO read(@Nonnull CompactReader in) {
throw new UnsupportedOperationException("We will not read from here on this test");
}
@Override
public void write(@Nonnull CompactWriter out, @Nonnull EmployeeDTO object) {
out.writeInt32("age", object.getAge());
}
});
SerializationService serializationService = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).setSchemaService(schemaService).build();
EmployeeDTO expected = new EmployeeDTO(20, 102310312);
Data data = serializationService.toData(expected);
SerializationService serializationService2 = createSerializationService();
EmployeeDTO actual = serializationService2.toObject(data);
assertEquals(expected.getAge(), actual.getAge());
assertEquals(0, actual.getId());
}
Aggregations