@Test
  public void testDataSerializable() throws Exception {
    DataSerializable ds = new DataSerializableImpl(getRandom());

    DataOutputStream out = getDataOutput();
    ds.toData(out);
    out.flush();

    DataSerializable ds2 = new DataSerializableImpl();
    ds2.fromData(getDataInput());

    assertEquals(ds, ds2);
  }
Tests serializing an object that implements {@link DataSerializable}
geode-core/src/test/java/org/apache/geode/internal/DataSerializableJUnitTest.java