public void testMarshalling() throws Exception
{
log.debug("<test-mapping-marshalling>");
final Person person = Person.newInstance();
StringWriter xmlOutput = new StringWriter();
InputStream is = getResource("xml/person.dtd");
Reader dtdReader = new InputStreamReader(is);
// create an instance of DTD marshaller
Marshaller marshaller = new DtdMarshaller();
// map publicId to systemId as it should appear in the resulting XML file
marshaller.mapPublicIdToSystemId("-//DTD Person//EN", "resources/xml/person.dtd");
// create an instance of ObjectModelProvider with the book instance to be marshalled
MappingObjectModelProvider provider = new MappingObjectModelProvider();
provider.mapFieldToElement(Person.class, "dateOfBirth", "", "date-of-birth", SimpleTypeBindings.JAVA_UTIL_DATE);
// marshal the book
marshaller.marshal(dtdReader, provider, person, xmlOutput);
// close DTD reader
dtdReader.close();
final String xml = xmlOutput.getBuffer().toString();
log.debug("marshalled: " + xml);
// check unmarshalled person
Person unmarshalled = unmarshalPerson(new StringReader(xml));
assertEquals(person, unmarshalled);
log.debug("</test-mapping-marshalling>");
}