public void testSerialization() {
StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?");
StandardXYURLGenerator 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 = (StandardXYURLGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
Serialize an instance, restore it, and check for equality. |