@Test
  public void testCustomSerializer() throws Exception {
    Random random = new Random();

    Class<?> c = NonDataSerializable.NonDSSerializer.class;
    byte id = (byte) 100;
    DataSerializer.register(c);

    Object o = new NonDataSerializable(random);
    try {
      DataSerializer.writeObject(o, getDataOutput());
      Object o2 = DataSerializer.readObject(getDataInput());
      assertEquals(o, o2);

    } finally {
      InternalDataSerializer.unregister(id);
    }
  }
Tests that a custom serializer is consulted
geode-core/src/test/java/org/apache/geode/internal/DataSerializableJUnitTest.java