From: <bo...@us...> - 2008-01-04 10:24:03
|
Revision: 236 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=236&view=rev Author: bodewig Date: 2008-01-04 02:24:02 -0800 (Fri, 04 Jan 2008) Log Message: ----------- add (disabled) test for bug 1860681 Modified Paths: -------------- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2008-01-04 09:45:17 UTC (rev 235) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2008-01-04 10:24:02 UTC (rev 236) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ import java.util.Iterator; import java.util.List; +import org.custommonkey.xmlunit.examples.MultiLevelElementNameAndTextQualifier; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -243,6 +244,59 @@ assertEquals(3, changes.size()); } + /** + * Bug 1860681 + * @see https://sourceforge.net/tracker/index.php?func=detail&aid=1860681&group_id=23187&atid=377768 + */ + public void XtestXpathOfMissingNode() throws Exception { + String control = + "<books>" + + " <book>" + + " <title>Kabale und Liebe</title>" + + " </book>" + + " <book>" + + " <title>Schuld und Suehne</title>" + + " </book>" + + "</books>"; + String test = + "<books>" + + " <book>" + + " <title>Schuld und Suehne</title>" + + " </book>" + + "</books>"; + XMLUnit.setIgnoreWhitespace(true); + try { + Diff diff = new Diff(control, test); + diff.overrideElementQualifier(new MultiLevelElementNameAndTextQualifier(2)); + DetailedDiff dd = new DetailedDiff(diff); + List l = dd.getAllDifferences(); + assertEquals(3, l.size()); + // (0) number of children, (1) node not found, (2) order different + Difference d = (Difference) l.get(1); + assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID, + d.getId()); + assertEquals("/books[1]/book[1]", + d.getControlNodeDetail().getXpathLocation()); + assertNull(d.getTestNodeDetail().getXpathLocation()); + + // and reverse + diff = new Diff(test, control); + diff.overrideElementQualifier(new MultiLevelElementNameAndTextQualifier(2)); + dd = new DetailedDiff(diff); + l = dd.getAllDifferences(); + assertEquals(3, l.size()); + // (0) number of children, (1) order different, (2) node not found + d = (Difference) l.get(2); + assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID, + d.getId()); + assertEquals("/books[1]/book[1]", + d.getTestNodeDetail().getXpathLocation()); + assertNull(d.getControlNodeDetail().getXpathLocation()); + } finally { + XMLUnit.setIgnoreWhitespace(false); + } + } + protected Diff buildDiff(Document control, Document test) { return new DetailedDiff(super.buildDiff(control, test)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |