/**
* 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);
// test a custom instance
c1 = new DialCap();
c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue,
3.0f, 4.0f, Color.green));
c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white,
3.0f, 4.0f, Color.gray));
c1.setOutlineStroke(new BasicStroke(2.0f));