InputStream in = getFileAsStream();
try {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(),
StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, in);
try {
OMContainer container = containerFactory.getContainer(builder);
// We need to clone the InputSource objects so that we can dump their contents
// if the test fails
InputSource control[] = duplicateInputSource(containerFactory.getControl(getFileAsStream()));
InputSource actual[] = duplicateInputSource(serializationMethod.serialize(container));
try {
assertXMLIdentical(compareXML(control[0], actual[0]), true);
} catch (AssertionFailedError ex) {
System.out.println("Control:");
dumpInputSource(control[1]);
System.out.println("Actual:");
dumpInputSource(actual[1]);
throw ex;
}
if (serializationMethod.isCaching()) {
assertTrue(container.isComplete());
} else {
// TODO: need to investigate why assertConsumed is not working here
assertFalse(container.isComplete());
// assertConsumed(element);
}
} finally {
builder.close();
}