From: SourceForge.net <no...@so...> - 2009-09-18 15:33:30
|
Bugs item #2758280, was opened at 2009-04-13 10:55 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2758280&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Virat Gohil (viratgohil) Assigned to: Nobody/Anonymous (nobody) Summary: Elements being compared even if they do not qualify. Initial Comment: Control XML <a>1</a> <b>1</b> <c>1</c> <d>1</d> <e>1</e> The test XML looks like this: <a>1</a> <b>1</b> <z>1</z> <c>1</c> <d>1</d> <e>1</e> I figured out that the DifferenceEngine.compareNodeList() does the following: 1. It compiles a list of objects that are comparable (qualifies for comparison). 2. Once this operation is complete, there will be 3 lists available: a. List of comparable objects b. list of objects present in control node but absent in test node. c. list of objects present in test node but absent in control node. 3. Compares the comparable objects. 4. compares the objects in list b against list c (above), even though they do not qualify for comparison. I think point 4 is a defect. I downloaded the source code and modified the following: Original: DifferenceEngine.java:435 if (nextTest == null && !unmatchedTestNodes.isEmpty()) { nextTest = (Node) unmatchedTestNodes.get(0); testIndex = new Integer(testChildren.indexOf(nextTest)); unmatchedTestNodes.remove(0); } Modify: if (nextTest == null && !unmatchedTestNodes.isEmpty()) { nextTest = (Node) unmatchedTestNodes.get(0); if(elementQualifier.qualifyForComparison((Element)nextControl, (Element)nextTest)) { testIndex = new Integer(testChildren.indexOf(nextTest)); unmatchedTestNodes.remove(0); } else nextTest=null; } ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2009-09-18 17:33 Message: A slightly different fix went into svn revision 353 of the 1.x branch and 354 of trunk. I'll mark this report fixed once I get around documenting the new flag in the user guide. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2009-06-09 13:12 Message: This has always been XMLUnit's behavior and there may be code that relies on the feature, so we'd need to introduce yet another configuration option. This is not too likely to happen in the 1.x codebase. We are currently redesigning the API for XMLUnit 2.x and this is something I intend to keep in mind. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2009-04-14 06:55 Message: A small change in the example XML that I submitted above: Control XML: <a>1</a> <b>1</b> <c>1</c> <d>1</d> <e>1</e> Test XML: <a>1</a> <b>1</b> <d>1</d> <e>1</e> <z>1</z> Here both the XML have same number of elements, but Test xml is missing element "c" and has an extra element "z", this will make the Difference Engine compare element "c" against element "z". Thanks, Virat ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2758280&group_id=23187 |