DatastreamXMLMetadata ds1 = createXDatastream("DS1");
ds1.DSCreateDT = new Date();
original.addDatastreamVersion(ds1, true);
// serialize the object as Atom
DOSerializer serA = new AtomDOSerializer();
File f = File.createTempFile("test", null);
OutputStream out = new FileOutputStream(f);
serA.serialize(original,
out,
"utf-8",
DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE);
// deserialize the object
DigitalObject candidate = new BasicDigitalObject();
DODeserializer deserA = new AtomDODeserializer();
InputStream in = new FileInputStream(f);
deserA.deserialize(in,
candidate,
"utf-8",
DOTranslationUtility.DESERIALIZE_INSTANCE);
// check the deserialization
assertEquals(original.getLastModDate(), candidate.getLastModDate());
DatastreamXMLMetadata candidateDS =
(DatastreamXMLMetadata) candidate.datastreams("DS1").iterator()
.next();
assertEquals(ds1.DatastreamID, candidateDS.DatastreamID);
assertEquals(ds1.DSCreateDT, candidateDS.DSCreateDT);
// FIXME dsSize tests omitted for now b/c of handling of closing tags
//assertEquals(ds1.DSSize, candidateDS.DSSize);
// also make sure we can serialize the object as foxml
DOSerializer serF = new FOXML1_1DOSerializer();
serF.serialize(candidate,
out,
"utf-8",
DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE);
}