@Test
public void testSerializationRoundTrip() throws Exception {
IdGenerator idGenerator = new IdGeneratorImpl();
RecordIdWritable writable1 = new RecordIdWritable(idGenerator.newRecordId("foo"));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(bos);
writable1.write(out);
System.out.println(Bytes.toStringBinary(bos.toByteArray()));
// Verify the binary length
assertEquals(1 /* vint length */ + 1 /* record id type byte */ + "foo".length(), bos.toByteArray().length);
RecordIdWritable writable2 = new RecordIdWritable();
writable2.readFields(new DataInputStream(new ByteArrayInputStream(bos.toByteArray())));
assertEquals(idGenerator.newRecordId("foo"), writable2.getRecordId());
}