Revision: 459
http://xmlunit.svn.sourceforge.net/xmlunit/?rev=459&view=rev
Author: bodewig
Date: 2010-09-09 14:57:48 +0000 (Thu, 09 Sep 2010)
Log Message:
-----------
turn Bug 3062518 into a - passing - unit test
Modified Paths:
--------------
branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java
Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java
===================================================================
--- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2010-09-09 08:24:17 UTC (rev 458)
+++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2010-09-09 14:57:48 UTC (rev 459)
@@ -1,6 +1,6 @@
/*
******************************************************************
-Copyright (c) 2001-2008, Jeff Martin, Tim Bacon
+Copyright (c) 2001-2008,2010 Jeff Martin, Tim Bacon
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -377,4 +377,68 @@
XMLUnit.setCompareUnmatched(true);
}
}
+
+ /**
+ * @see https://sourceforge.net/tracker/index.php?func=detail&aid=3062518&group_id=23187&atid=377768
+ */
+ public void testIssue3062518() throws Exception {
+ String control = "<Fruits>"
+ + "<Apple size=\"11\" color=\"green\"/>"
+ + "<Apple size=\"15\" color=\"green\"/>"
+ + "<Banana size=\"10\"/>"
+ + "</Fruits>";
+ String test = "<Fruits>"
+ + "<Apple size=\"11\" color=\"green\"/>"
+ + "<Banana size=\"11\"/>"
+ + "</Fruits>";
+ try {
+ XMLUnit.setCompareUnmatched(false);
+ DetailedDiff d = (DetailedDiff) buildDiff(control, test);
+ List l = d.getAllDifferences();
+ assertEquals(4, l.size());
+ // expected 3 children is 2
+ Difference diff = (Difference) l.get(0);
+ assertEquals(DifferenceConstants.CHILD_NODELIST_LENGTH_ID,
+ diff.getId());
+ assertEquals("3", diff.getControlNodeDetail().getValue());
+ assertEquals("2", diff.getTestNodeDetail().getValue());
+ assertEquals("/Fruits[1]",
+ diff.getControlNodeDetail().getXpathLocation());
+ assertEquals("/Fruits[1]",
+ diff.getTestNodeDetail().getXpathLocation());
+
+ // didn't find the second Apple element
+ diff = (Difference) l.get(1);
+ assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID,
+ diff.getId());
+ assertEquals("Apple", diff.getControlNodeDetail().getValue());
+ assertEquals("null", diff.getTestNodeDetail().getValue());
+ assertEquals("/Fruits[1]/Apple[2]",
+ diff.getControlNodeDetail().getXpathLocation());
+ assertEquals(null,
+ diff.getTestNodeDetail().getXpathLocation());
+
+ // Banana's size attribute doesn't match
+ diff = (Difference) l.get(2);
+ assertEquals(DifferenceConstants.ATTR_VALUE_ID,
+ diff.getId());
+ assertEquals("10", diff.getControlNodeDetail().getValue());
+ assertEquals("11", diff.getTestNodeDetail().getValue());
+ assertEquals("/Fruits[1]/Banana[1]/@size",
+ diff.getControlNodeDetail().getXpathLocation());
+ assertEquals("/Fruits[1]/Banana[1]/@size",
+ diff.getTestNodeDetail().getXpathLocation());
+
+ // Banana is the third child in control but the second one in test
+ diff = (Difference) l.get(3);
+ assertEquals("2", diff.getControlNodeDetail().getValue());
+ assertEquals("1", diff.getTestNodeDetail().getValue());
+ assertEquals("/Fruits[1]/Banana[1]",
+ diff.getControlNodeDetail().getXpathLocation());
+ assertEquals("/Fruits[1]/Banana[1]",
+ diff.getTestNodeDetail().getXpathLocation());
+ } finally {
+ XMLUnit.setCompareUnmatched(true);
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|