@Test public void compareDocTypes() { DOMDifferenceEngine d = new DOMDifferenceEngine(); DiffExpecter ex = new DiffExpecter(ComparisonType.DOCTYPE_NAME); d.addDifferenceListener(ex); d.setComparisonController(ComparisonControllers.StopWhenDifferent); DocumentType dt1 = new DocType("name", "pub", "system"); DocumentType dt2 = new DocType("name2", "pub", "system"); assertEquals(wrapAndStop(ComparisonResult.DIFFERENT), d.compareNodes(dt1, new XPathContext(), dt2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); ex = new DiffExpecter(ComparisonType.DOCTYPE_PUBLIC_ID); d.addDifferenceListener(ex); d.setComparisonController(ComparisonControllers.StopWhenDifferent); dt2 = new DocType("name", "pub2", "system"); assertEquals(wrapAndStop(ComparisonResult.DIFFERENT), d.compareNodes(dt1, new XPathContext(), dt2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); ex = new DiffExpecter(ComparisonType.DOCTYPE_SYSTEM_ID); d.addDifferenceListener(ex); d.setDifferenceEvaluator(new DifferenceEvaluator() { public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) { if (comparison.getType() == ComparisonType.DOCTYPE_SYSTEM_ID) { assertEquals(ComparisonResult.DIFFERENT, outcome); return ComparisonResult.DIFFERENT; } assertEquals(ComparisonResult.EQUAL, outcome); return ComparisonResult.EQUAL; } }); d.setComparisonController(ComparisonControllers.StopWhenDifferent); dt2 = new DocType("name", "pub", "system2"); assertEquals(wrapAndStop(ComparisonResult.DIFFERENT), d.compareNodes(dt1, new XPathContext(), dt2, new XPathContext())); assertEquals(1, ex.invoked); }
private ComparisonState compareDocTypes(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) { return compare(new Comparison(ComparisonType.DOCTYPE_NAME, control, getXPath(controlContext), control.getName(), getParentXPath(controlContext), test, getXPath(testContext), test.getName(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, control, getXPath(controlContext), control.getPublicId(), getParentXPath(controlContext), test, getXPath(testContext), test.getPublicId(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, control, null, control.getSystemId(), null, test, null, test.getSystemId(), null)); }
DOMDifferenceEngine extends AbstractDifferenceEngine { private ComparisonState compareDocTypes(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) { return compare(new Comparison(ComparisonType.DOCTYPE_NAME, control, getXPath(controlContext), control.getName(), getParentXPath(controlContext), test, getXPath(testContext), test.getName(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, control, getXPath(controlContext), control.getPublicId(), getParentXPath(controlContext), test, getXPath(testContext), test.getPublicId(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, control, null, control.getSystemId(), null, test, null, test.getSystemId(), null)); } }
DOMDifferenceEngine extends AbstractDifferenceEngine { private ComparisonState compareDocTypes(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) { return compare(new Comparison(ComparisonType.DOCTYPE_NAME, control, getXPath(controlContext), control.getName(), getParentXPath(controlContext), test, getXPath(testContext), test.getName(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, control, getXPath(controlContext), control.getPublicId(), getParentXPath(controlContext), test, getXPath(testContext), test.getPublicId(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, control, null, control.getSystemId(), null, test, null, test.getSystemId(), null)); } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); }
DOMDifferenceEngine extends AbstractDifferenceEngine { private ComparisonState compareDocTypes(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) { return compare(new Comparison(ComparisonType.DOCTYPE_NAME, control, getXPath(controlContext), control.getName(), getParentXPath(controlContext), test, getXPath(testContext), test.getName(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, control, getXPath(controlContext), control.getPublicId(), getParentXPath(controlContext), test, getXPath(testContext), test.getPublicId(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, control, null, control.getSystemId(), null, test, null, test.getSystemId(), null)); } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); void setDocumentBuilderFactory(DocumentBuilderFactory f); @Override void compare(Source control, Source test); }
DOMDifferenceEngine extends AbstractDifferenceEngine { private ComparisonState compareDocTypes(DocumentType control, XPathContext controlContext, DocumentType test, XPathContext testContext) { return compare(new Comparison(ComparisonType.DOCTYPE_NAME, control, getXPath(controlContext), control.getName(), getParentXPath(controlContext), test, getXPath(testContext), test.getName(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, control, getXPath(controlContext), control.getPublicId(), getParentXPath(controlContext), test, getXPath(testContext), test.getPublicId(), getParentXPath(testContext))) .andThen(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, control, null, control.getSystemId(), null, test, null, test.getSystemId(), null)); } DOMDifferenceEngine();  DOMDifferenceEngine(final DocumentBuilderFactory f); void setDocumentBuilderFactory(DocumentBuilderFactory f); @Override void compare(Source control, Source test);  }