use of org.custommonkey.xmlunit.DifferenceListener in project jbpm by kiegroup.
the class XMLBPMNProcessDumperTest method testConditionExpression.
/**
* TESTS
*/
@Test
public void testConditionExpression() throws Exception {
// JBPM-4069 : XmlBPMNProcessDumper.dump() misses conditionExpression in sequenceFlow
String filename = "BPMN2-GatewaySplit-SequenceConditions.bpmn2";
String original = BPMN2XMLTest.slurp(XMLBPMNProcessDumperTest.class.getResourceAsStream("/" + filename));
KieBase kbase = createKnowledgeBase(filename);
RuleFlowProcess process = (RuleFlowProcess) kbase.getProcess("GatewayTest");
String result = XmlBPMNProcessDumper.INSTANCE.dump(process, XmlBPMNProcessDumper.META_DATA_USING_DI);
// Compare original with result using XMLUnit
Diff diff = new Diff(original, result);
diff.overrideDifferenceListener(new DifferenceListener() {
public int differenceFound(Difference diff) {
String nodeName = diff.getTestNodeDetail().getNode().getNodeName();
if (nodeName.equals("conditionExpression") || nodeName.equals("language")) {
logger.info(diff.toString());
return RETURN_ACCEPT_DIFFERENCE;
}
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
}
public void skippedComparison(Node one, Node two) {
logger.info("{} : {}", one.getLocalName(), two.getLocalName());
}
});
assertTrue("Original and generated output is not the same.", diff.identical());
}
use of org.custommonkey.xmlunit.DifferenceListener in project iaf by ibissource.
the class LdapSenderTest method compareXML.
private void compareXML(String expectedFile, String result) throws SAXException, IOException {
URL expectedUrl = ClassUtils.getResourceURL(expectedFile);
if (expectedUrl == null) {
throw new IOException("cannot find resource [" + expectedUrl + "]");
}
String expected = Misc.resourceToString(expectedUrl);
Diff diff = XMLUnit.compareXML(expected, result);
diff.overrideDifferenceListener(new DifferenceListener() {
@Override
public int differenceFound(Difference diff) {
if (diff.getId() == DifferenceConstants.ATTR_VALUE_ID) {
Attr attr = (Attr) diff.getControlNodeDetail().getNode();
if ("value".equals(attr.getName())) {
Node parentNode = attr.getOwnerElement();
if ("attribute".equals(parentNode.getNodeName())) {
Node nameAttribute = parentNode.getAttributes().getNamedItem("name");
if ("entryUUID".equals(nameAttribute.getTextContent()) || "modifyTimestamp".equals(nameAttribute.getTextContent()) || "createTimestamp".equals(nameAttribute.getTextContent()) || "userPassword".equals(nameAttribute.getTextContent())) {
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
}
}
}
}
return RETURN_ACCEPT_DIFFERENCE;
}
@Override
public void skippedComparison(Node arg0, Node arg1) {
// TODO Auto-generated method stub
}
});
assertTrue(diff.toString(), diff.identical());
}
Aggregations