I am using org.custommonkey.xmlunit; (version 1.2)
.
While building Diff
object:
Diff diff = new Diff(expected, generated);
I always have NullPointerException as it's failing on this.controlDoc = this.getManipulatedDocument(controlDoc);
.
While debugging I found that in first constructor:
public Diff(String control, String test) throws SAXException, IOException {
this((Reader)(new StringReader(control)), (Reader)(new StringReader(test)));
}
there are proper xmls however when:
public Diff(Reader control, Reader test) throws SAXException, IOException {
this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), XMLUnit.buildDocument(XMLUnit.newTestParser(), test));
}
is called I see in debugger [#document: null]
. Why is that so? I tried with many xmls, even really easy and small which I found in internet but nothing works.
Oh, I just have found that XMLUnit.setIgnoreWhitespace(true);
cause this problem because in project I am using Saxon library in ancient version and it was fixed in version 8.9 however this:
XMLUnit.setTransformerFactory("org.apache.xalan.processor.TransformerFactoryImpl");
helps a lot.