From: Stefan B. <bo...@us...> - 2017-12-02 13:49:59
|
Harikesh, please don't comment on unrelated closed issues but create a new one if you think you've found a bug. In your case the `NullPointerException` probably stems from your comparator. Most likely there is a difference about an unmatched node (there is a text child node of `secondChild` in the control document but none in the test document). In the case of "missing nodes" one detail side of the `Difference` is null - which is the intended and documented behavior and so `getTestNodeDetail()` may be null and `getTestNodeDetail().getNode()` throws an exception. --- ** [bugs:#46] 1.2 bug comparing missing attributes** **Status:** closed-fixed **Group:** Java_1.2 **Created:** Thu Dec 04, 2008 05:30 AM UTC by Matthew Watson **Last Updated:** Sat Dec 02, 2017 06:19 AM UTC **Owner:** Stefan Bodewig There is a bug when comparing 2 xml fragments where one has a missing attribute, the error is reported correctly, but the xpath for the attribute being compared is incorrect. The test below produces: Expected number of element attributes '2' but was '1' - comparing <bar...> at /foo\[1\]/bar\[1\] to <bar...> at /foo\[1\]/bar\[1\] Expected attribute name 'y' but was 'null' - comparing <bar...> at /foo\[1\]/bar\[1\]/@a to <bar...> at /foo\[1\]/bar\[1\]/@a The second diff says it is comparing attribute "y", but the xpath indicates attribute "a". Either the attribute in the xpath should be "y", or the xpath should only indicate /foo\[1\]/bar\[1\] Matt import java.util.List; import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLTestCase; public class XmlUnitBug extends XMLTestCase \{ public void testBug\(\) throws Exception \{ Diff myDiff = new Diff\("<foo><bar a=\"x\" y=\"z\"/></foo>", "<foo><bar a=\"x\"/></foo>"\); DetailedDiff myDDiff = new DetailedDiff\(myDiff\); List allDifferences = myDDiff.getAllDifferences\(\); for \(Object diff : allDifferences\) \{ System.err.println\(diff\); \} assertTrue\(myDDiff.similar\(\)\); \} \} --- Sent from sourceforge.net because xml...@li... is subscribed to https://sourceforge.net/p/xmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/xmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |