UniqueSerializable implements Serializable { @Override public boolean equals(Object obj) { if (obj == null) { return false; } return getClass() == obj.getClass(); }  @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testUniqueness() { UniqueSerializable o1 = new UniqueSerializable() { }; UniqueSerializable o2 = new UniqueSerializable() { }; Assert.assertFalse(o1 == o2); Assert.assertFalse(o1.equals(o2)); }
@Test public void testSerialization() { UniqueSerializable o1 = new UniqueSerializable() { }; UniqueSerializable d1 = (UniqueSerializable) SerializationUtils .deserialize(SerializationUtils.serialize(o1)); Assert.assertTrue(d1.equals(o1)); }