Sunday, April 21, 2013
Ignoring DTD in XMLUnit
@BeforeClass
public static void onlyOnce() {
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreAttributeOrder(true);
// don't validate dtd
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
try {
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature(
"http://apache.org/xml/features/nonvalidating/load-dtd-grammar",
false);
dbf.setFeature(
"http://apache.org/xml/features/nonvalidating/load-external-dtd",
false);
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
XMLUnit.setTestDocumentBuilderFactory(dbf);
XMLUnit.setControlDocumentBuilderFactory(dbf);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment