use of org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener in project tomee by apache.
the class EjbJarXmlTest method testEjbJar.
/**
* TODO Doesn't seem there are any asserts here
*
* @throws Exception
*/
public void testEjbJar() throws Exception {
final String fileName = "ejb-jar-example1.xml";
final Event test = Event.start("Test");
final URL resource = this.getClass().getClassLoader().getResource(fileName);
final String expected = IO.slurp(resource);
final Event ejbJarJAXBCreate = Event.start("EjbJarJAXBCreate");
ejbJarJAXBCreate.stop();
final Event unmarshalEvent = Event.start("unmarshal");
final Object value;
final EjbJar$JAXB jaxbType = new EjbJar$JAXB();
value = Sxc.unmarshalJavaee(resource, jaxbType);
unmarshalEvent.stop();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final Event marshall = Event.start("marshall");
Sxc.marshall(jaxbType, value, baos);
marshall.stop();
final String result = new String(baos.toByteArray(), "UTF-8");
XMLUnit.setIgnoreComments(Boolean.TRUE);
XMLUnit.setIgnoreWhitespace(Boolean.TRUE);
XMLUnit.setIgnoreAttributeOrder(Boolean.TRUE);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(Boolean.TRUE);
final Diff diff = new Diff(expected.trim(), result.trim());
final Diff myDiff = new DetailedDiff(diff);
// just to get an int wrapper for the test
final AtomicInteger differenceNumber = new AtomicInteger(0);
myDiff.overrideDifferenceListener(new IgnoreTextAndAttributeValuesDifferenceListener() {
@Override
public int differenceFound(final Difference difference) {
if (!difference.isRecoverable()) {
differenceNumber.incrementAndGet();
System.err.println(">>> " + difference.toString());
}
return 0;
}
});
assertTrue("Files are not identical", myDiff.identical());
test.stop();
}
Aggregations