/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
// test a default instance
DialBackground b1 = new DialBackground();
DialBackground b2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(b1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
b2 = (DialBackground) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(b1, b2);
// test a customised instance
b1 = new DialBackground();
b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
Color.green));
b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
b2 = null;