public void testSerialization() {
final StrokeTable t1 = new StrokeTable();
t1.setStroke(0, 0, new BasicStroke(1.0f));
t1.setStroke(0, 1, new BasicStroke(2.0f));
t1.setStroke(1, 0, new BasicStroke(3.0f));
t1.setStroke(1, 1, new BasicStroke(4.0f));
StrokeTable t2 = null;
try {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
final ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
t2 = (StrokeTable) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(t1, t2);
}
Serialize an instance, restore it, and check for equality. |