@Test public void xPathKnowsAboutNodeFiltersForUnmatchedControlNodes() { final Diff diff = DiffBuilder.compare("<Document><Section><Binding /><Binding /><Finding /><Finding /><Finding /><Finding /><Finding /><Finding /><Finding /></Section></Document>") .withTest("<Document><Section><Binding /><Binding /><Finding /><Finding /><Finding /><Finding /><Finding /><Finding /></Section></Document>") .ignoreWhitespace() .withNodeFilter(new Predicate<Node>() { @Override public boolean test(final Node node) { return Arrays.asList("Document", "Section", "Finding").contains(node.getNodeName()); } }) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build(); final List<Difference> differences = Linqy.asList(diff.getDifferences()); assertEquals(2, differences.size()); assertEquals(ComparisonType.CHILD_NODELIST_LENGTH, differences.get(0).getComparison().getType()); assertEquals("/Document[1]/Section[1]", differences.get(0).getComparison().getControlDetails().getXPath()); assertEquals("/Document[1]/Section[1]", differences.get(0).getComparison().getTestDetails().getXPath()); assertEquals(ComparisonType.CHILD_LOOKUP, differences.get(1).getComparison().getType()); assertEquals("/Document[1]/Section[1]/Finding[7]", differences.get(1).getComparison().getControlDetails().getXPath()); assertNull(differences.get(1).getComparison().getTestDetails().getXPath()); assertEquals("/Document[1]/Section[1]", differences.get(1).getComparison().getTestDetails().getParentXPath()); }
@Override public void compare(Source control, Source test) { if (control == null) { throw new IllegalArgumentException("control must not be null"); } if (test == null) { throw new IllegalArgumentException("test must not be null"); } try { Node controlNode = Convert.toNode(control, documentBuilderFactory); Node testNode = Convert.toNode(test, documentBuilderFactory); compareNodes(controlNode, xpathContextFor(controlNode), testNode, xpathContextFor(testNode)); } catch (Exception ex) { throw new XMLUnitException("Caught exception during comparison", ex); } }
DOMDifferenceEngine extends AbstractDifferenceEngine { @Override public void compare(Source control, Source test) { if (control == null) { throw new IllegalArgumentException("control must not be null"); } if (test == null) { throw new IllegalArgumentException("test must not be null"); } try { Node controlNode = Convert.toNode(control, documentBuilderFactory); Node testNode = Convert.toNode(test, documentBuilderFactory); compareNodes(controlNode, xpathContextFor(controlNode), testNode, xpathContextFor(testNode)); } catch (Exception ex) { throw new XMLUnitException("Caught exception during comparison", ex); } } }
DOMDifferenceEngine extends AbstractDifferenceEngine { @Override public void compare(Source control, Source test) { if (control == null) { throw new IllegalArgumentException("control must not be null"); } if (test == null) { throw new IllegalArgumentException("test must not be null"); } try { Node controlNode = Convert.toNode(control, documentBuilderFactory); Node testNode = Convert.toNode(test, documentBuilderFactory); compareNodes(controlNode, xpathContextFor(controlNode), testNode, xpathContextFor(testNode)); } catch (Exception ex) { throw new XMLUnitException("Caught exception during comparison", ex); } } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); }
DOMDifferenceEngine extends AbstractDifferenceEngine { @Override public void compare(Source control, Source test) { if (control == null) { throw new IllegalArgumentException("control must not be null"); } if (test == null) { throw new IllegalArgumentException("test must not be null"); } try { Node controlNode = Convert.toNode(control, documentBuilderFactory); Node testNode = Convert.toNode(test, documentBuilderFactory); compareNodes(controlNode, xpathContextFor(controlNode), testNode, xpathContextFor(testNode)); } catch (Exception ex) { throw new XMLUnitException("Caught exception during comparison", ex); } } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); void setDocumentBuilderFactory(DocumentBuilderFactory f); @Override void compare(Source control, Source test); }
DOMDifferenceEngine extends AbstractDifferenceEngine { @Override public void compare(Source control, Source test) { if (control == null) { throw new IllegalArgumentException("control must not be null"); } if (test == null) { throw new IllegalArgumentException("test must not be null"); } try { Node controlNode = Convert.toNode(control, documentBuilderFactory); Node testNode = Convert.toNode(test, documentBuilderFactory); compareNodes(controlNode, xpathContextFor(controlNode), testNode, xpathContextFor(testNode)); } catch (Exception ex) { throw new XMLUnitException("Caught exception during comparison", ex); } } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); void setDocumentBuilderFactory(DocumentBuilderFactory f); @Override void compare(Source control, Source test);  }