Hello
I tried to compare too node list, using the ElementNameAndAttributeQualifier to resolve the order problem. Then, the comparison of the two following XML fragments works well:
test:
<tag>
<child amount="100" />
<child amount="250" />
<child amount="100" />
<child amount="100" />
<child amount="100" />
</tag>
control:
<tag>
<child amount="100" />
<child amount="100" />
<child amount="250" />
<child amount="100" />
<child amount="100" />
</tag>
But now, when a tried to compare the two following ones:
test:
<tag>
<child amount="100" />
<child amount="100" />
<child amount="100" />
<child amount="250" />
<child amount="100" />
</tag>
control:
<tag>
<child amount="100" />
<child amount="100" />
<child amount="250" />
<child amount="100" />
<child amount="100" />
</tag>
It raises a difference, whereas I only move an element in the test fragment:
[different] Expected presence of child node 'null' but was 'child' - comparing at null to <child...> at /tag[1]/child[3]
Here is my whole java code:
public static void main(String[] args) throws SAXException, IOException {
String test = "<tag>" +
"<child amount=\"100\" />" +
"<child amount=\"100\" />" +
"<child amount=\"100\" />" +
"<child amount=\"250\" />" +
"<child amount=\"100\" />" +
"</tag>";
String control = "<tag>" +
"<child amount=\"100\" />" +
"<child amount=\"100\" />" +
"<child amount=\"250\" />" +
"<child amount=\"100\" />" +
"<child amount=\"100\" />" +
"</tag>";
Diff myDiff = new Diff(control, test);
myDiff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
XMLAssert.assertXMLEqual("", myDiff, true);
}
Thanks for your good job
Rémy
fixed with svn revision 346 by using a rather ugly hack instead of a real solution because the real solution would break backwards compatibility.
What happens is that control nodes four and five both got matched to test node five (neglecting the fact that it already had a matching control node in the case of control node five) leaving test node three in the list of unmatched test nodes.
The fixed code matches control node four to test node five and control node five to test node three an everything looks good to XMLUnit.
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
To not "random-match" unmatched control nodes with test nodes, set the option to false:
The option defaults to true in order to keep backward compatibility.
Last edit: Leo 2013-07-24