Search in sources :

Example 6 with DifferenceListener

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());
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Diff(org.custommonkey.xmlunit.Diff) KieBase(org.kie.api.KieBase) Node(org.w3c.dom.Node) DifferenceListener(org.custommonkey.xmlunit.DifferenceListener) Difference(org.custommonkey.xmlunit.Difference) Test(org.junit.Test)

Example 7 with DifferenceListener

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());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) Node(org.w3c.dom.Node) DifferenceListener(org.custommonkey.xmlunit.DifferenceListener) IOException(java.io.IOException) Difference(org.custommonkey.xmlunit.Difference) URL(java.net.URL) Attr(org.w3c.dom.Attr)

Aggregations

Diff (org.custommonkey.xmlunit.Diff)7 Difference (org.custommonkey.xmlunit.Difference)7 DifferenceListener (org.custommonkey.xmlunit.DifferenceListener)7 Node (org.w3c.dom.Node)7 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)2 ElementNameQualifier (org.custommonkey.xmlunit.ElementNameQualifier)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 DetailedDiff (org.custommonkey.xmlunit.DetailedDiff)1 ElementNameAndAttributeQualifier (org.custommonkey.xmlunit.ElementNameAndAttributeQualifier)1 SemanticModules (org.drools.core.xml.SemanticModules)1