@Override
  protected void write(Object datum, Encoder out) throws IOException {
    final Timestamp timestamp = (Timestamp) datum;
    if (timestamp == null) {
      out.writeLong(-1L);
      out.writeInt(-1);
    } else {
      out.writeLong(timestamp.getSeconds());
      out.writeInt(timestamp.getNanos());
    }
  }
@Test(expected = ClassCastException.class)
  public void testThrowsExceptionWhenWritingNonTimestamp() throws IOException {
    encoding.write(1L, null);
  }