From: <bo...@us...> - 2013-04-14 16:00:02
|
Revision: 526 http://sourceforge.net/p/xmlunit/code/526 Author: bodewig Date: 2013-04-14 15:59:58 +0000 (Sun, 14 Apr 2013) Log Message: ----------- Issue 60: if elements without children can create 'CHILD_NODELIST_LENGTH' differences, they must also fire the corresponding MatchTracker events Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_IgnoreTextAndAttributeValuesDifferenceListener.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-04-14 15:00:45 UTC (rev 525) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-04-14 15:59:58 UTC (rev 526) @@ -320,20 +320,21 @@ protected void compareNodeChildren(Node control, Node test, DifferenceListener listener, ElementQualifier elementQualifier) throws DifferenceFoundException { + + List controlChildren = nodeList2List(control.getChildNodes()); + List testChildren = nodeList2List(test.getChildNodes()); + + Integer controlLength = new Integer(controlChildren.size()); + Integer testLength = new Integer(testChildren.size()); + compare(controlLength, testLength, control, test, listener, + CHILD_NODELIST_LENGTH); + if (control.hasChildNodes() || test.hasChildNodes()) { - List controlChildren = nodeList2List(control.getChildNodes()); - List testChildren = nodeList2List(test.getChildNodes()); - - Integer controlLength = new Integer(controlChildren.size()); - Integer testLength = new Integer(testChildren.size()); - compare(controlLength, testLength, control, test, listener, - CHILD_NODELIST_LENGTH); - - if (controlLength.intValue() == 0) { + if (!control.hasChildNodes()) { for (Iterator iter = testChildren.iterator(); iter.hasNext();) { missingNode(null, (Node) iter.next(), listener); } - } else if (testLength.intValue() == 0) { + } else if (!test.hasChildNodes()) { for (Iterator iter = controlChildren.iterator(); iter.hasNext();) { missingNode((Node) iter.next(), null, listener); } 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 2013-04-14 15:00:45 UTC (rev 525) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2013-04-14 15:59:58 UTC (rev 526) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2008,2010 Jeff Martin, Tim Bacon +Copyright (c) 2001-2008,2010,2013 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-04-14 15:00:45 UTC (rev 525) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-04-14 15:59:58 UTC (rev 526) @@ -786,8 +786,9 @@ // // NODE_TYPE(Element), NAMESPACE_URI(none), // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), - // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) - assertEquals(12, count[0]); + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false), + // CHILD_NODELIST_LENGTH(0) + assertEquals(13, count[0]); } public void testMatchTrackerSetViaEngine() throws Exception { @@ -812,8 +813,9 @@ // // NODE_TYPE(Element), NAMESPACE_URI(none), // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), - // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) - assertEquals(12, count[0]); + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false), + // CHILD_NODELIST_LENGTH(0) + assertEquals(13, count[0]); } public void testMatchTrackerSetViaOverrideOnEngine() throws Exception { @@ -840,7 +842,8 @@ // NODE_TYPE(Element), NAMESPACE_URI(none), // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) - assertEquals(12, count[0]); + // CHILD_NODELIST_LENGTH(0) + assertEquals(13, count[0]); } public void testCDATAAndIgnoreWhitespace() throws Exception { Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2013-04-14 15:00:45 UTC (rev 525) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2013-04-14 15:59:58 UTC (rev 526) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2008, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008,2013 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -857,8 +857,9 @@ d.compare(control, test, listener, null); // NODE_TYPE (not null), NODE_TYPE(Element), NAMESPACE_URI(none), // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), - // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) - assertEquals(7, count[0]); + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false), + // CHILD_NODELIST_LENGTH(0) + assertEquals(8, count[0]); } public void testMatchTrackerSetViaSetter() throws Exception { @@ -873,8 +874,9 @@ engine.compare(control, test, listener, null); // NODE_TYPE (not null), NODE_TYPE(Element), NAMESPACE_URI(none), // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), - // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) - assertEquals(7, count[0]); + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false), + // CHILD_NODELIST_LENGTH(0) + assertEquals(8, count[0]); } /** Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_IgnoreTextAndAttributeValuesDifferenceListener.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_IgnoreTextAndAttributeValuesDifferenceListener.java 2013-04-14 15:00:45 UTC (rev 525) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_IgnoreTextAndAttributeValuesDifferenceListener.java 2013-04-14 15:59:58 UTC (rev 526) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 200, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008,2013 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |