new ObjectOutputStream(new NullOutputStream()).writeObject(metadata);
}
public void testSerializeAndRestore() throws Exception
{
Metadata metadataWrite = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/test/withIptcExifGps.jpg"));
Metadata metadataRead;
File ser = File.createTempFile("test", "ser");
try {
// write the ser object
new ObjectOutputStream(new FileOutputStream(ser)).writeObject(metadataWrite);
// read the ser object
metadataRead = (Metadata)new ObjectInputStream(new FileInputStream(ser)).readObject();
// make sure they're equivalent
// TODO should compare the two objects via iteration of directories and tags
assertTrue(metadataRead.containsDirectory(ExifDirectory.class));
assertTrue(metadataRead.containsDirectory(IptcDirectory.class));
} finally {
ser.delete();
}
}