@Test
public void testRecordWithNull() throws IOException {
ReflectData reflectData = ReflectData.AllowNull.get();
Schema schm = reflectData.getSchema(AnotherSampleRecord.class);
String prefix = getPrefix(AnotherSampleRecord.class);
ReflectDatumWriter writer = new ReflectDatumWriter(schm);
ByteArrayOutputStream out = new ByteArrayOutputStream();
// keep record.a null and see if that works
AnotherSampleRecord a = new AnotherSampleRecord();
writer.write(a, new BinaryEncoder(out));
AnotherSampleRecord b = new AnotherSampleRecord(10);
writer.write(b, new BinaryEncoder(out));
ReflectDatumReader reader = new ReflectDatumReader(schm, prefix);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
Object decoded = reader.read(null, new BinaryDecoder(in));
assertEquals(a, decoded);
decoded = reader.read(null, new BinaryDecoder(in));