CountTimestampWritable implements Writable { public CountTimestampWritable(long count, long epochMilliseconds) { this.count = count; this.epochMilliseconds = epochMilliseconds; } CountTimestampWritable(long count, long epochMilliseconds); @Override void write(DataOutput out); @Override void readFields(DataInput in); long getCount(); void setCount(long count); long getEpochMilliseconds(); void setEpochMilliseconds(long epochMilliseconds);  }
@Test public void testCountTimestampWritable() throws Exception { CountTimestampWritable orig = new CountTimestampWritable(7L, 123L); assertEquals(orig.getCount(), 7L); assertEquals(orig.getEpochMilliseconds(), 123L); ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(bytesOut); orig.write(dataOut); CountTimestampWritable deSerialized = new CountTimestampWritable(0L, 0L); deSerialized.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray()))); assertEquals(orig.getCount(), deSerialized.getCount()); assertEquals(orig.getEpochMilliseconds(), deSerialized.getEpochMilliseconds()); }