public void testSerialization() {
List t1 = new java.util.ArrayList();
t1.add("Tooltip A1");
t1.add("Tooltip A2");
t1.add("Tooltip A3");
List t2 = new java.util.ArrayList();
t2.add("Tooltip B1");
t2.add("Tooltip B2");
t2.add("Tooltip B3");
CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator();
g1.addToolTipSeries(t1);
g1.addToolTipSeries(t2);
CustomXYToolTipGenerator g2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
g2 = (CustomXYToolTipGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
Serialize an instance, restore it, and check for equality. |