use of org.custommonkey.xmlunit.DetailedDiff in project camunda-dmn-model by camunda.
the class DmnModelTest method assertModelEqualsFile.
protected void assertModelEqualsFile(String expectedPath) throws Exception {
File actualFile = tmpFolder.newFile();
Dmn.writeModelToFile(actualFile, modelInstance);
File expectedFile = ReflectUtil.getResourceAsFile(expectedPath);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document actualDocument = docBuilder.parse(actualFile);
Document expectedDocument = docBuilder.parse(expectedFile);
Diff diff = new Diff(expectedDocument, actualDocument);
if (!diff.similar()) {
diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
DetailedDiff detailedDiff = new DetailedDiff(diff);
String failMsg = "XML differs:\n" + detailedDiff.getAllDifferences() + "\n\nActual XML:\n" + Dmn.convertToString(modelInstance);
fail(failMsg);
}
}
use of org.custommonkey.xmlunit.DetailedDiff in project cerberus-source by cerberustesting.
the class XmlUtilTest method testFromURL.
@Test
public void testFromURL() throws XmlUtilException {
Document expected = XmlUtil.newDocument();
Element element = expected.createElement("root");
expected.appendChild(element);
Element child = expected.createElement("child");
child.appendChild(expected.createTextNode("a"));
element.appendChild(child);
Document actual = XmlUtil.fromURL(getClass().getResource("input.xml"));
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
Assert.assertTrue(diff.toString(), diff.similar());
}
use of org.custommonkey.xmlunit.DetailedDiff in project cerberus-source by cerberustesting.
the class DifferencesTest method testToDocumentWhenExistingDifference.
@Test
public void testToDocumentWhenExistingDifference() throws DifferencesException, XmlUtilException {
Document actual = differences.toDocument();
Document expected = XmlUtil.newDocument();
Element root = expected.createElement(Differences.DIFFERENCES_NODE);
expected.appendChild(root);
DetailedDiff result = new DetailedDiff(XMLUnit.compareXML(expected, actual));
Assert.assertTrue("Differences can be correctly transforms as Document when there is no differences", result.similar());
}
use of org.custommonkey.xmlunit.DetailedDiff in project cerberus-source by cerberustesting.
the class XmlUnitServiceTest method testRemoveDifferenceWhenNoDifferenceMatch.
@Test
public void testRemoveDifferenceWhenNoDifferenceMatch() throws XmlUtilException, SAXException, IOException {
differences.addDifference(new Difference("/root[1]/a[1]"));
differences.addDifference(new Difference("/root[1]/b[1]"));
String actual = xmlUnitService.removeDifference("toto", differences.mkString());
String expected = "<differences><difference>/root[1]/a[1]</difference><difference>/root[1]/b[1]</difference></differences>";
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
Assert.assertTrue(diff.toString(), diff.similar());
}
use of org.custommonkey.xmlunit.DetailedDiff in project cerberus-source by cerberustesting.
the class XmlUnitServiceTest method testRemoveDifferenceWhenDifferenceMatch.
@Test
public void testRemoveDifferenceWhenDifferenceMatch() throws XmlUtilException, SAXException, IOException {
differences.addDifference(new Difference("/root[1]/a[1]"));
differences.addDifference(new Difference("/root[1]/a[2]"));
differences.addDifference(new Difference("/root[1]/b[1]"));
String actual = xmlUnitService.removeDifference("/root\\[1\\]/a\\[[1-2]\\]", differences.mkString());
String expected = "<differences><difference>/root[1]/b[1]</difference></differences>";
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
Assert.assertTrue(diff.toString(), diff.similar());
}
Aggregations