@Test public void compareNodesDifferentNS() { DOMDifferenceEngine d = new DOMDifferenceEngine(); DiffExpecter ex = new DiffExpecter(ComparisonType.NAMESPACE_URI); d.addDifferenceListener(ex); d.setComparisonController(ComparisonControllers.StopWhenDifferent); assertEquals(wrapAndStop(ComparisonResult.DIFFERENT), d.compareNodes(doc.createElementNS("x", "y"), new XPathContext(), doc.createElementNS("z", "y"), new XPathContext())); assertEquals(1, ex.invoked); }
ComparisonState compareNodes(final Node control, final XPathContext controlContext, final Node test, final XPathContext testContext) { final Iterable<Node> allControlChildren = new IterableNodeList(control.getChildNodes()); final Iterable<Node> controlChildren = Linqy.filter(allControlChildren, getNodeFilter()); final Iterable<Node> allTestChildren = new IterableNodeList(test.getChildNodes()); final Iterable<Node> testChildren = Linqy.filter(allTestChildren, getNodeFilter()); return compare(new Comparison(ComparisonType.NODE_TYPE, control, getXPath(controlContext), control.getNodeType(), getParentXPath(controlContext), test, getXPath(testContext), test.getNodeType(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_URI, control, getXPath(controlContext), control.getNamespaceURI(), getParentXPath(controlContext), test, getXPath(testContext), test.getNamespaceURI(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, getXPath(controlContext), control.getPrefix(), getParentXPath(controlContext), test, getXPath(testContext), test.getPrefix(), getParentXPath(testContext))) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, control, getXPath(controlContext), Linqy.count(controlChildren), getParentXPath(controlContext), test, getXPath(testContext), Linqy.count(testChildren), getParentXPath(testContext))) .andThen(new DeferredComparison() { @Override public ComparisonState apply() { return nodeTypeSpecificComparison(control, controlContext, test, testContext); } }) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, compareChildren(controlContext, allControlChildren, controlChildren, testContext, allTestChildren, testChildren)); }
DOMDifferenceEngine extends AbstractDifferenceEngine { ComparisonState compareNodes(final Node control, final XPathContext controlContext, final Node test, final XPathContext testContext) { final Iterable<Node> allControlChildren = new IterableNodeList(control.getChildNodes()); final Iterable<Node> controlChildren = Linqy.filter(allControlChildren, getNodeFilter()); final Iterable<Node> allTestChildren = new IterableNodeList(test.getChildNodes()); final Iterable<Node> testChildren = Linqy.filter(allTestChildren, getNodeFilter()); return compare(new Comparison(ComparisonType.NODE_TYPE, control, getXPath(controlContext), control.getNodeType(), getParentXPath(controlContext), test, getXPath(testContext), test.getNodeType(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_URI, control, getXPath(controlContext), control.getNamespaceURI(), getParentXPath(controlContext), test, getXPath(testContext), test.getNamespaceURI(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, getXPath(controlContext), control.getPrefix(), getParentXPath(controlContext), test, getXPath(testContext), test.getPrefix(), getParentXPath(testContext))) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, control, getXPath(controlContext), Linqy.count(controlChildren), getParentXPath(controlContext), test, getXPath(testContext), Linqy.count(testChildren), getParentXPath(testContext))) .andThen(new DeferredComparison() { @Override public ComparisonState apply() { return nodeTypeSpecificComparison(control, controlContext, test, testContext); } }) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, compareChildren(controlContext, allControlChildren, controlChildren, testContext, allTestChildren, testChildren)); } }
DOMDifferenceEngine extends AbstractDifferenceEngine { ComparisonState compareNodes(final Node control, final XPathContext controlContext, final Node test, final XPathContext testContext) { final Iterable<Node> allControlChildren = new IterableNodeList(control.getChildNodes()); final Iterable<Node> controlChildren = Linqy.filter(allControlChildren, getNodeFilter()); final Iterable<Node> allTestChildren = new IterableNodeList(test.getChildNodes()); final Iterable<Node> testChildren = Linqy.filter(allTestChildren, getNodeFilter()); return compare(new Comparison(ComparisonType.NODE_TYPE, control, getXPath(controlContext), control.getNodeType(), getParentXPath(controlContext), test, getXPath(testContext), test.getNodeType(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_URI, control, getXPath(controlContext), control.getNamespaceURI(), getParentXPath(controlContext), test, getXPath(testContext), test.getNamespaceURI(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, getXPath(controlContext), control.getPrefix(), getParentXPath(controlContext), test, getXPath(testContext), test.getPrefix(), getParentXPath(testContext))) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, control, getXPath(controlContext), Linqy.count(controlChildren), getParentXPath(controlContext), test, getXPath(testContext), Linqy.count(testChildren), getParentXPath(testContext))) .andThen(new DeferredComparison() { @Override public ComparisonState apply() { return nodeTypeSpecificComparison(control, controlContext, test, testContext); } }) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, compareChildren(controlContext, allControlChildren, controlChildren, testContext, allTestChildren, testChildren)); } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); }
DOMDifferenceEngine extends AbstractDifferenceEngine { ComparisonState compareNodes(final Node control, final XPathContext controlContext, final Node test, final XPathContext testContext) { final Iterable<Node> allControlChildren = new IterableNodeList(control.getChildNodes()); final Iterable<Node> controlChildren = Linqy.filter(allControlChildren, getNodeFilter()); final Iterable<Node> allTestChildren = new IterableNodeList(test.getChildNodes()); final Iterable<Node> testChildren = Linqy.filter(allTestChildren, getNodeFilter()); return compare(new Comparison(ComparisonType.NODE_TYPE, control, getXPath(controlContext), control.getNodeType(), getParentXPath(controlContext), test, getXPath(testContext), test.getNodeType(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_URI, control, getXPath(controlContext), control.getNamespaceURI(), getParentXPath(controlContext), test, getXPath(testContext), test.getNamespaceURI(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, getXPath(controlContext), control.getPrefix(), getParentXPath(controlContext), test, getXPath(testContext), test.getPrefix(), getParentXPath(testContext))) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, control, getXPath(controlContext), Linqy.count(controlChildren), getParentXPath(controlContext), test, getXPath(testContext), Linqy.count(testChildren), getParentXPath(testContext))) .andThen(new DeferredComparison() { @Override public ComparisonState apply() { return nodeTypeSpecificComparison(control, controlContext, test, testContext); } }) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, compareChildren(controlContext, allControlChildren, controlChildren, testContext, allTestChildren, testChildren)); } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); void setDocumentBuilderFactory(DocumentBuilderFactory f); @Override void compare(Source control, Source test); }
DOMDifferenceEngine extends AbstractDifferenceEngine { ComparisonState compareNodes(final Node control, final XPathContext controlContext, final Node test, final XPathContext testContext) { final Iterable<Node> allControlChildren = new IterableNodeList(control.getChildNodes()); final Iterable<Node> controlChildren = Linqy.filter(allControlChildren, getNodeFilter()); final Iterable<Node> allTestChildren = new IterableNodeList(test.getChildNodes()); final Iterable<Node> testChildren = Linqy.filter(allTestChildren, getNodeFilter()); return compare(new Comparison(ComparisonType.NODE_TYPE, control, getXPath(controlContext), control.getNodeType(), getParentXPath(controlContext), test, getXPath(testContext), test.getNodeType(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_URI, control, getXPath(controlContext), control.getNamespaceURI(), getParentXPath(controlContext), test, getXPath(testContext), test.getNamespaceURI(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, getXPath(controlContext), control.getPrefix(), getParentXPath(controlContext), test, getXPath(testContext), test.getPrefix(), getParentXPath(testContext))) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, control, getXPath(controlContext), Linqy.count(controlChildren), getParentXPath(controlContext), test, getXPath(testContext), Linqy.count(testChildren), getParentXPath(testContext))) .andThen(new DeferredComparison() { @Override public ComparisonState apply() { return nodeTypeSpecificComparison(control, controlContext, test, testContext); } }) .andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE, compareChildren(controlContext, allControlChildren, controlChildren, testContext, allTestChildren, testChildren)); } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); void setDocumentBuilderFactory(DocumentBuilderFactory f); @Override void compare(Source control, Source test);  }