/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
// test a default instance
DialCap c1 = new DialCap();
DialCap c2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(c1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
c2 = (DialCap) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(c1, c2);
// check that the listener lists are independent
MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
c1.addChangeListener(l1);
assertTrue(c1.hasListener(l1));
assertFalse(c2.hasListener(l1));
}