From: <bo...@us...> - 2011-04-20 12:31:17
|
Revision: 494 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=494&view=rev Author: bodewig Date: 2011-04-20 12:31:11 +0000 (Wed, 20 Apr 2011) Log Message: ----------- assertXPathEqual doesn't work if one XPath matches an Attr node, Issue 3290264 Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLAssert.java branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_XMLTestCase.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLAssert.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLAssert.java 2011-03-16 15:33:58 UTC (rev 493) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLAssert.java 2011-04-20 12:31:11 UTC (rev 494) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007,2011 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -46,8 +46,10 @@ import javax.xml.parsers.DocumentBuilder; import junit.framework.Assert; +import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -1114,7 +1116,12 @@ d.appendChild(root); final int length = nodes.getLength(); for (int i = 0; i < length; i++) { - root.appendChild(d.importNode(nodes.item(i), true)); + Node n = d.importNode(nodes.item(i), true); + if (n instanceof Attr) { + root.setAttributeNodeNS((Attr) n); + } else { + root.appendChild(n); + } } return d; } Modified: branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml =================================================================== --- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2011-03-16 15:33:58 UTC (rev 493) +++ branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2011-04-20 12:31:11 UTC (rev 494) @@ -3615,6 +3615,37 @@ </section> </section> + <section id="Changes 1.4"> + <title>Changes from XMLUnit 1.3 to 1.4</title> + + <section id="Breaking Changes 1.3"> + <title>Breaking Changes</title> + + <!--itemizedlist> + </itemizedlist--> + </section> + + <section id="New Features 1.4"> + <title>New Features</title> + + <!--itemizedlist> + </itemizedlist--> + </section> + + <section id="Bugfixes 1.4"> + <title>Important Bug Fixes</title> + + <itemizedlist> + <listitem> + <literal>XMLTestCase</literal>'s and <literal>XMLAssert</literal>'s + <literal>assertXpathsEqual</literal> methods threw an + exception at least one XPath matched an attribute. <ulink + url="https://sourceforge.net/tracker/?func=detail&aid=3290264&group_id=23187&atid=377768">Issue 377768</ulink>. + </listitem> + </itemizedlist> + </section> + </section> + </appendix> </article> Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_XMLTestCase.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_XMLTestCase.java 2011-03-16 15:33:58 UTC (rev 493) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_XMLTestCase.java 2011-04-20 12:31:11 UTC (rev 494) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 200, Jeff Martin, Tim Bacon +Copyright (c) 2001-2011, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -50,7 +50,7 @@ /** * Test case used to test the XMLTestCase */ -public class test_XMLTestCase extends XMLTestCase{ +public class test_XMLTestCase extends XMLTestCase { private static final String PREFIX = "foo"; private static final String TEST_NS = "urn:org.example"; private static final NamespaceContext NS_CONTEXT; @@ -572,6 +572,16 @@ assertXpathExists("/axrtable/schema", xmlDocument); } + // bug 3290264 + public void testAssertXpathEqualsAndAttributes() throws Exception { + assertXpathsNotEqual("/foo/Bar/@a", "/foo/Bar", + "<foo><Bar a=\"1\" /></foo>"); + assertXpathsNotEqual("/foo/Bar/@a", "/foo/Bar/@b", + "<foo><Bar a=\"1\" b=\"1\"/></foo>"); + assertXpathsEqual("/foo/Bar/@a", "/foo/Bar/@a", + "<foo><Bar a=\"1\" b=\"2\"/></foo>"); + } + public test_XMLTestCase(String name) { super(name); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |