You can subscribe to this list here.
2007 |
Jan
|
Feb
(3) |
Mar
(18) |
Apr
(39) |
May
(15) |
Jun
(12) |
Jul
(3) |
Aug
(23) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(21) |
Feb
(23) |
Mar
(33) |
Apr
(8) |
May
(1) |
Jun
(22) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(6) |
Nov
|
Dec
(11) |
2009 |
Jan
(5) |
Feb
|
Mar
(2) |
Apr
(24) |
May
(36) |
Jun
(18) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(3) |
Nov
(1) |
Dec
|
2010 |
Jan
(5) |
Feb
(3) |
Mar
|
Apr
(15) |
May
(24) |
Jun
(11) |
Jul
(8) |
Aug
(34) |
Sep
(42) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(13) |
Feb
(32) |
Mar
(35) |
Apr
(31) |
May
(33) |
Jun
(30) |
Jul
(32) |
Aug
(31) |
Sep
(30) |
Oct
(31) |
Nov
(32) |
Dec
(31) |
2012 |
Jan
(35) |
Feb
(31) |
Mar
(31) |
Apr
(30) |
May
(31) |
Jun
(34) |
Jul
(23) |
Aug
(30) |
Sep
(30) |
Oct
(29) |
Nov
(30) |
Dec
(32) |
2013 |
Jan
(25) |
Feb
(39) |
Mar
(1) |
Apr
(18) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(20) |
Sep
(41) |
Oct
(32) |
Nov
(9) |
Dec
(31) |
2014 |
Jan
(31) |
Feb
(30) |
Mar
(34) |
Apr
(60) |
May
(31) |
Jun
(28) |
Jul
(32) |
Aug
(28) |
Sep
(26) |
Oct
(32) |
Nov
(43) |
Dec
(115) |
2015 |
Jan
(106) |
Feb
(101) |
Mar
(51) |
Apr
(32) |
May
(63) |
Jun
(18) |
Jul
|
Aug
(18) |
Sep
|
Oct
(1) |
Nov
(84) |
Dec
(63) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(104) |
Apr
(30) |
May
(6) |
Jun
(30) |
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(48) |
Dec
(22) |
2017 |
Jan
(15) |
Feb
(29) |
Mar
(43) |
Apr
(29) |
May
(25) |
Jun
(28) |
Jul
(62) |
Aug
(35) |
Sep
(35) |
Oct
(72) |
Nov
(10) |
Dec
(4) |
2018 |
Jan
(7) |
Feb
(4) |
Mar
|
Apr
(46) |
May
(20) |
Jun
(12) |
Jul
(9) |
Aug
(42) |
Sep
(4) |
Oct
(17) |
Nov
(32) |
Dec
(31) |
2019 |
Jan
(21) |
Feb
(14) |
Mar
|
Apr
(74) |
May
(25) |
Jun
(43) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(10) |
2020 |
Jan
(1) |
Feb
|
Mar
(26) |
Apr
(8) |
May
(62) |
Jun
(4) |
Jul
(25) |
Aug
|
Sep
(21) |
Oct
(24) |
Nov
(26) |
Dec
(9) |
2021 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(11) |
Nov
(1) |
Dec
(12) |
2022 |
Jan
(47) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(14) |
2023 |
Jan
(3) |
Feb
|
Mar
(60) |
Apr
(9) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
(5) |
Feb
|
Mar
|
Apr
(10) |
May
(1) |
Jun
|
Jul
|
Aug
(17) |
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
|
Mar
(88) |
Apr
(64) |
May
(47) |
Jun
(20) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <bo...@us...> - 2009-09-21 19:37:49
|
Revision: 357 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=357&view=rev Author: bodewig Date: 2009-09-21 19:37:43 +0000 (Mon, 21 Sep 2009) Log Message: ----------- tag release 1.3 of XMLUnit for Java Modified Paths: -------------- tags/XMLUnit-Java-1.3/LICENSE.txt tags/XMLUnit-Java-1.3/build.xml Added Paths: ----------- tags/XMLUnit-Java-1.3/ Property changes on: tags/XMLUnit-Java-1.3 ___________________________________________________________________ Added: svn:mergeinfo + Modified: tags/XMLUnit-Java-1.3/LICENSE.txt =================================================================== --- branches/xmlunit-1.x/LICENSE.txt 2009-09-21 10:21:20 UTC (rev 356) +++ tags/XMLUnit-Java-1.3/LICENSE.txt 2009-09-21 19:37:43 UTC (rev 357) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2009, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: tags/XMLUnit-Java-1.3/build.xml =================================================================== --- branches/xmlunit-1.x/build.xml 2009-09-21 10:21:20 UTC (rev 356) +++ tags/XMLUnit-Java-1.3/build.xml 2009-09-21 19:37:43 UTC (rev 357) @@ -37,7 +37,7 @@ <property file="build.properties"/> <!-- Version --> - <property name="xmlunit.version" value="1.3alpha"/> + <property name="xmlunit.version" value="1.3"/> <!-- some locations --> <property name="src.dir" value="src"/> @@ -264,7 +264,7 @@ </target> <target name="dist" - depends="clean,bindist,srcdist,compile-userguide-examples" + depends="bindist,srcdist,compile-userguide-examples" description="creates the distribution files"> <checksum algorithm="md5"> <fileset dir="${dist.dir}"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-09-21 10:22:16
|
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: Pending >Resolution: Fixed 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-21 12:22 Message: documented with svn revision 355 (and 356 for trunk) ---------------------------------------------------------------------- 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 |
From: <bo...@us...> - 2009-09-21 10:21:27
|
Revision: 356 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=356&view=rev Author: bodewig Date: 2009-09-21 10:21:20 +0000 (Mon, 21 Sep 2009) Log Message: ----------- document compareUnmatched option Modified Paths: -------------- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Property Changed: ---------------- trunk/xmlunit/ trunk/xmlunit/src/user-guide/ Property changes on: trunk/xmlunit ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x:355 Property changes on: trunk/xmlunit/src/user-guide ___________________________________________________________________ Modified: svn:mergeinfo - /branches/xmlunit-1.x/src/user-guide:346 + /branches/xmlunit-1.x/src/user-guide:346,355 Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2009-09-21 10:17:59 UTC (rev 355) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2009-09-21 10:21:20 UTC (rev 356) @@ -39,6 +39,11 @@ <date>June 2008</date> <revremark>Documentation for XMLUnit Java 1.2</revremark> </revision> + <revision> + <revnumber>1.3</revnumber> + <date>September 2009</date> + <revremark>Documentation for XMLUnit Java 1.3</revremark> + </revision> </revhistory> </articleinfo> @@ -2229,7 +2234,7 @@ <literal>DOMSource</literal> overrides when specifying your pieces of XML, XMLUnit will use the configured XML parsers (see <xref linkend="JAXP"/>) and <literal>EntityResolver</literal>s - (see <xref linkend="EntityResolver"/>). There configuration + (see <xref linkend="EntityResolver"/>). There are configuration options to use different settings for the control and test pieces of XML.</para> @@ -2362,9 +2367,46 @@ definitions the parser may expand them or not. Using <literal>XMLUnit.setExpandEntityReferences</literal> you can control the parser's setting.</para> + </section> + + <section id="Comparison of Unmatched Elements"> + <title>Comparison of Unmatched Elements</title> + + <para>When XMLUnit cannot match a control Element to a test + Element (the configured ElementQualifier - see + <xref linkend="ElementQualifier"/> - doesn't return true for + any of the test Elements) it will try to compare it against + the first unmatched test Element (if there is one). + Starting with XMLUnit 1.3 one can + use <literal>XMLUnit.setCompareUnmatched</literal> to + disable this behavior and + generate <literal>CHILD_NODE_NOT_FOUND</literal> differences + instead.</para> + + <para>If the control document is + <programlisting language="XML"><![CDATA[ +<root> + <a/> +</root> +]]></programlisting> + and the test document is + <programlisting language="XML"><![CDATA[ +<root> + <b/> +</root> +]]></programlisting> + + the default setting will create a + single <literal>ELEMENT_TAG_NAME</literal> Difference + ("expected a but found b"). + Setting <literal>XMLUnit.setCompareUnmatched</literal> to + false will create two Differences of + type <literal>CHILD_NODE_NOT_FOUND</literal> (one for "a" and + one for "b") instead.</para> + </section> + </section> - </section> <section id="Validating XML Documents"> @@ -3519,21 +3561,39 @@ <section id="Changes 1.3"> <title>Changes from XMLUnit 1.2 to 1.3</title> - <section id="Breaking Changes 1.2"> + <section id="Breaking Changes 1.3"> <title>Breaking Changes</title> - <itemizedlist> - </itemizedlist> + <!--itemizedlist> + </itemizedlist--> </section> - <section id="New Features 1.2"> + <section id="New Features 1.3"> <title>New Features</title> <itemizedlist> + <listitem> + If XMLUnit doesn't find a matching Element for a control + Element, it will match it against the first unmatched test + Element (if there is one) instead of creating + a <literal>CHILD_NODE_NOT_FOUND</literal> Difference. + There now is a new configuration + option <literal>compareUnmatched</literal> in + the <literal>XMLUnit</literal> class that can be used to + turn off this behavior - as a result + two <literal>CHILD_NODE_NOT_FOUND</literal> Differences + (one for the unmatched control Element and one for an + unmatched test Element) will be created instead of a + single Difference comparing the two likely unrelated + nodes. See <xref linkend="Comparison of Unmatched + Elements"/>. + <ulink + url="https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768">Issue 2758280</ulink>. + </listitem> </itemizedlist> </section> - <section id="Bugfixes 1.2"> + <section id="Bugfixes 1.3"> <title>Important Bug Fixes</title> <itemizedlist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-09-21 10:18:06
|
Revision: 355 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=355&view=rev Author: bodewig Date: 2009-09-21 10:17:59 +0000 (Mon, 21 Sep 2009) Log Message: ----------- document compareUnmatched option Modified Paths: -------------- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml Modified: branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml =================================================================== --- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2009-09-18 15:32:26 UTC (rev 354) +++ branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2009-09-21 10:17:59 UTC (rev 355) @@ -39,6 +39,11 @@ <date>June 2008</date> <revremark>Documentation for XMLUnit Java 1.2</revremark> </revision> + <revision> + <revnumber>1.3</revnumber> + <date>September 2009</date> + <revremark>Documentation for XMLUnit Java 1.3</revremark> + </revision> </revhistory> </articleinfo> @@ -2229,7 +2234,7 @@ <literal>DOMSource</literal> overrides when specifying your pieces of XML, XMLUnit will use the configured XML parsers (see <xref linkend="JAXP"/>) and <literal>EntityResolver</literal>s - (see <xref linkend="EntityResolver"/>). There configuration + (see <xref linkend="EntityResolver"/>). There are configuration options to use different settings for the control and test pieces of XML.</para> @@ -2362,9 +2367,46 @@ definitions the parser may expand them or not. Using <literal>XMLUnit.setExpandEntityReferences</literal> you can control the parser's setting.</para> + </section> + + <section id="Comparison of Unmatched Elements"> + <title>Comparison of Unmatched Elements</title> + + <para>When XMLUnit cannot match a control Element to a test + Element (the configured ElementQualifier - see + <xref linkend="ElementQualifier"/> - doesn't return true for + any of the test Elements) it will try to compare it against + the first unmatched test Element (if there is one). + Starting with XMLUnit 1.3 one can + use <literal>XMLUnit.setCompareUnmatched</literal> to + disable this behavior and + generate <literal>CHILD_NODE_NOT_FOUND</literal> differences + instead.</para> + + <para>If the control document is + <programlisting language="XML"><![CDATA[ +<root> + <a/> +</root> +]]></programlisting> + and the test document is + <programlisting language="XML"><![CDATA[ +<root> + <b/> +</root> +]]></programlisting> + + the default setting will create a + single <literal>ELEMENT_TAG_NAME</literal> Difference + ("expected a but found b"). + Setting <literal>XMLUnit.setCompareUnmatched</literal> to + false will create two Differences of + type <literal>CHILD_NODE_NOT_FOUND</literal> (one for "a" and + one for "b") instead.</para> + </section> + </section> - </section> <section id="Validating XML Documents"> @@ -3519,21 +3561,39 @@ <section id="Changes 1.3"> <title>Changes from XMLUnit 1.2 to 1.3</title> - <section id="Breaking Changes 1.2"> + <section id="Breaking Changes 1.3"> <title>Breaking Changes</title> - <itemizedlist> - </itemizedlist> + <!--itemizedlist> + </itemizedlist--> </section> - <section id="New Features 1.2"> + <section id="New Features 1.3"> <title>New Features</title> <itemizedlist> + <listitem> + If XMLUnit doesn't find a matching Element for a control + Element, it will match it against the first unmatched test + Element (if there is one) instead of creating + a <literal>CHILD_NODE_NOT_FOUND</literal> Difference. + There now is a new configuration + option <literal>compareUnmatched</literal> in + the <literal>XMLUnit</literal> class that can be used to + turn off this behavior - as a result + two <literal>CHILD_NODE_NOT_FOUND</literal> Differences + (one for the unmatched control Element and one for an + unmatched test Element) will be created instead of a + single Difference comparing the two likely unrelated + nodes. See <xref linkend="Comparison of Unmatched + Elements"/>. + <ulink + url="https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768">Issue 2758280</ulink>. + </listitem> </itemizedlist> </section> - <section id="Bugfixes 1.2"> + <section id="Bugfixes 1.3"> <title>Important Bug Fixes</title> <itemizedlist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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 |
From: <bo...@us...> - 2009-09-18 15:32:35
|
Revision: 354 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=354&view=rev Author: bodewig Date: 2009-09-18 15:32:26 +0000 (Fri, 18 Sep 2009) Log Message: ----------- merge fix for issue 2758280 from 1.x branch Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_DetailedDiff.java Property Changed: ---------------- trunk/xmlunit/src/main/java-legacy/ trunk/xmlunit/src/tests/java-legacy/ Property changes on: trunk/xmlunit/src/main/java-legacy ___________________________________________________________________ Modified: svn:mergeinfo - /branches/xmlunit-1.x/src/java:346 + /branches/xmlunit-1.x/src/java:346,353 Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java 2009-09-18 15:29:36 UTC (rev 353) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java 2009-09-18 15:32:26 UTC (rev 354) @@ -454,7 +454,8 @@ } } } - if (!matchFound && fallbackMatch >= 0) { + if (!matchFound && XMLUnit.getCompareUnmatched() + && fallbackMatch >= 0) { matchFound = true; j = fallbackMatch; } @@ -472,7 +473,8 @@ Node nextControl = (Node) controlChildren.get(i); Node nextTest = (Node) matchingNodes.get(nextControl); Integer testIndex = (Integer) matchingNodeIndexes.get(nextControl); - if (nextTest == null && !unmatchedTestNodes.isEmpty()) { + if (nextTest == null && XMLUnit.getCompareUnmatched() + && !unmatchedTestNodes.isEmpty()) { nextTest = (Node) unmatchedTestNodes.get(0); testIndex = new Integer(testChildren.indexOf(nextTest)); unmatchedTestNodes.remove(0); Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java 2009-09-18 15:29:36 UTC (rev 353) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java 2009-09-18 15:32:26 UTC (rev 354) @@ -83,6 +83,7 @@ private static String xsltVersion = "1.0"; private static String xpathFactoryName = null; private static boolean expandEntities = false; + private static boolean compareUnmatched = true; private static final String XSLT_VERSION_START = " version=\""; private static final String XSLT_VERSION_END = "\">"; @@ -881,5 +882,22 @@ public static boolean getExpandEntityReferences() { return expandEntities; } + + /** + * Whether to compare unmatched control nodes to unmatched test nodes. + * + * <p>Defaults to true.</p> + */ + public static void setCompareUnmatched(boolean b) { + compareUnmatched = b; + } + + /** + * Whether unmatched control nodes should be compared to unmatched + * test nodes. + */ + public static boolean getCompareUnmatched() { + return compareUnmatched; + } } Property changes on: trunk/xmlunit/src/tests/java-legacy ___________________________________________________________________ Modified: svn:mergeinfo - /branches/xmlunit-1.x/tests:346 /branches/xmlunit-1.x/tests/java:337,346 + /branches/xmlunit-1.x/tests:346 /branches/xmlunit-1.x/tests/java:337,346,353 Modified: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_DetailedDiff.java =================================================================== --- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_DetailedDiff.java 2009-09-18 15:29:36 UTC (rev 353) +++ trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_DetailedDiff.java 2009-09-18 15:32:26 UTC (rev 354) @@ -323,4 +323,58 @@ secondForecast = "<weather><today temp=\"20\"/></weather>"; } + /** + * https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768 + */ + public void testCompareUnmatched() throws Exception { + String control = "<root><a>1</a>" + + "<b>1</b>" + + "<c>1</c>" + + "<d>1</d>" + + "<e>1</e></root>"; + String test = "<root><a>1</a>" + + "<b>1</b>" + + "<z>1</z>" + + "<d>1</d>" + + "<e>1</e></root>"; + DetailedDiff d = (DetailedDiff) buildDiff(control, test); + List l = d.getAllDifferences(); + assertEquals(1, l.size()); + Difference diff = (Difference) l.get(0); + assertEquals(DifferenceConstants.ELEMENT_TAG_NAME_ID, diff.getId()); + } + + /** + * https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768 + */ + public void testDontCompareUnmatched() throws Exception { + String control = "<root><a>1</a>" + + "<b>1</b>" + + "<c>1</c>" + + "<d>1</d>" + + "<e>1</e></root>"; + String test = "<root><a>1</a>" + + "<b>1</b>" + + "<z>1</z>" + + "<d>1</d>" + + "<e>1</e></root>"; + try { + XMLUnit.setCompareUnmatched(false); + DetailedDiff d = (DetailedDiff) buildDiff(control, test); + List l = d.getAllDifferences(); + assertEquals(2, l.size()); + Difference diff = (Difference) l.get(0); + assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID, + diff.getId()); + assertNotNull(diff.getControlNodeDetail().getNode()); + assertNull(diff.getTestNodeDetail().getNode()); + diff = (Difference) l.get(1); + assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID, + diff.getId()); + assertNull(diff.getControlNodeDetail().getNode()); + assertNotNull(diff.getTestNodeDetail().getNode()); + } finally { + XMLUnit.setCompareUnmatched(true); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-09-18 15:29:43
|
Revision: 353 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=353&view=rev Author: bodewig Date: 2009-09-18 15:29:36 +0000 (Fri, 18 Sep 2009) Log Message: ----------- disable XMLUnit's behavior where it matches unmatched nodes against each other even if they don't qualify for comparision. Issue 2758280 Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLUnit.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2009-08-17 07:38:21 UTC (rev 352) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2009-09-18 15:29:36 UTC (rev 353) @@ -454,7 +454,8 @@ } } } - if (!matchFound && fallbackMatch >= 0) { + if (!matchFound && XMLUnit.getCompareUnmatched() + && fallbackMatch >= 0) { matchFound = true; j = fallbackMatch; } @@ -472,7 +473,8 @@ Node nextControl = (Node) controlChildren.get(i); Node nextTest = (Node) matchingNodes.get(nextControl); Integer testIndex = (Integer) matchingNodeIndexes.get(nextControl); - if (nextTest == null && !unmatchedTestNodes.isEmpty()) { + if (nextTest == null && XMLUnit.getCompareUnmatched() + && !unmatchedTestNodes.isEmpty()) { nextTest = (Node) unmatchedTestNodes.get(0); testIndex = new Integer(testChildren.indexOf(nextTest)); unmatchedTestNodes.remove(0); Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLUnit.java 2009-08-17 07:38:21 UTC (rev 352) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLUnit.java 2009-09-18 15:29:36 UTC (rev 353) @@ -83,6 +83,7 @@ private static String xsltVersion = "1.0"; private static String xpathFactoryName = null; private static boolean expandEntities = false; + private static boolean compareUnmatched = true; private static final String XSLT_VERSION_START = " version=\""; private static final String XSLT_VERSION_END = "\">"; @@ -881,5 +882,22 @@ public static boolean getExpandEntityReferences() { return expandEntities; } + + /** + * Whether to compare unmatched control nodes to unmatched test nodes. + * + * <p>Defaults to true.</p> + */ + public static void setCompareUnmatched(boolean b) { + compareUnmatched = b; + } + + /** + * Whether unmatched control nodes should be compared to unmatched + * test nodes. + */ + public static boolean getCompareUnmatched() { + return compareUnmatched; + } } 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 2009-08-17 07:38:21 UTC (rev 352) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2009-09-18 15:29:36 UTC (rev 353) @@ -323,4 +323,58 @@ secondForecast = "<weather><today temp=\"20\"/></weather>"; } + /** + * https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768 + */ + public void testCompareUnmatched() throws Exception { + String control = "<root><a>1</a>" + + "<b>1</b>" + + "<c>1</c>" + + "<d>1</d>" + + "<e>1</e></root>"; + String test = "<root><a>1</a>" + + "<b>1</b>" + + "<z>1</z>" + + "<d>1</d>" + + "<e>1</e></root>"; + DetailedDiff d = (DetailedDiff) buildDiff(control, test); + List l = d.getAllDifferences(); + assertEquals(1, l.size()); + Difference diff = (Difference) l.get(0); + assertEquals(DifferenceConstants.ELEMENT_TAG_NAME_ID, diff.getId()); + } + + /** + * https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768 + */ + public void testDontCompareUnmatched() throws Exception { + String control = "<root><a>1</a>" + + "<b>1</b>" + + "<c>1</c>" + + "<d>1</d>" + + "<e>1</e></root>"; + String test = "<root><a>1</a>" + + "<b>1</b>" + + "<z>1</z>" + + "<d>1</d>" + + "<e>1</e></root>"; + try { + XMLUnit.setCompareUnmatched(false); + DetailedDiff d = (DetailedDiff) buildDiff(control, test); + List l = d.getAllDifferences(); + assertEquals(2, l.size()); + Difference diff = (Difference) l.get(0); + assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID, + diff.getId()); + assertNotNull(diff.getControlNodeDetail().getNode()); + assertNull(diff.getTestNodeDetail().getNode()); + diff = (Difference) l.get(1); + assertEquals(DifferenceConstants.CHILD_NODE_NOT_FOUND_ID, + diff.getId()); + assertNull(diff.getControlNodeDetail().getNode()); + assertNotNull(diff.getTestNodeDetail().getNode()); + } finally { + XMLUnit.setCompareUnmatched(true); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-08-28 14:18:22
|
Bugs item #2836385, was opened at 2009-08-12 20:27 Message generated for change (Settings changed) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2836385&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: Java 1.2 >Status: Closed >Resolution: Duplicate Priority: 5 Private: No Submitted By: Sreekanth Kolluri (skolluri) Assigned to: Nobody/Anonymous (nobody) Summary: Similar XML comparison fails Initial Comment: Hi, I'm comparing 2 XML strings that are not identical but similar - both XML strings have the same nodes but in a different order. I used RecursiveElementNameAndTextQualifier but the similar comparison fails. I'm using version 1.2. Here is my java code. import org.custommonkey.xmlunit.XMLUnit; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; public class XMLUnitTest { public static void main(String... args) throws Exception { String s1 = "<main>" + " <inner>" + " <bar>50015</bar>" + " </inner>" + " <inner>" + " <bar>50003</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50020</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + "</main>"; String s2 = "<main>" + " <inner>" + " <bar>50003</bar>" + " </inner>" + " <inner>" + " <bar>50015</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50020</bar>" + " </inner>" + "</main>"; XMLUnit.setIgnoreWhitespace(true); Diff diff = new Diff(s1, s2); diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); boolean isSimilar = diff.similar(); if (!isSimilar) { System.out.println(diff); } } } I get the following error: org.custommonkey.xmlunit.Diff [not identical] Expected sequence of child nodes '0' but was '1' - comparing <inner...> at /main[1]/inner[1] to <inner...> at /main[1]/inner[2] [not identical] Expected sequence of child nodes '1' but was '0' - comparing <inner...> at /main[1]/inner[2] to <inner...> at /main[1]/inner[1] [not identical] Expected sequence of child nodes '3' but was '4' - comparing <inner...> at /main[1]/inner[4] to <inner...> at /main[1]/inner[5] [not identical] Expected sequence of child nodes '4' but was '2' - comparing <inner...> at /main[1]/inner[5] to <inner...> at /main[1]/inner[3] [different] Expected presence of child node 'null' but was 'inner' - comparing at null to <inner...> at /main[1]/inner[4] Thanks for looking into this. ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2009-08-28 16:18 Message: This is a duplicate of Bug #2807167 which is fixed in svn trunk but not released, yet. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2836385&group_id=23187 |
From: <bo...@us...> - 2009-08-17 07:38:28
|
Revision: 352 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=352&view=rev Author: bodewig Date: 2009-08-17 07:38:21 +0000 (Mon, 17 Aug 2009) Log Message: ----------- upgrade to NUnit 2.5.2 Modified Paths: -------------- trunk/xmlunit/lib/nunit.framework.dll Modified: trunk/xmlunit/lib/nunit.framework.dll =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-08-12 18:28:00
|
Bugs item #2836385, was opened at 2009-08-12 11:27 Message generated for change (Tracker Item Submitted) made by skolluri You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2836385&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: Java 1.2 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Sreekanth Kolluri (skolluri) Assigned to: Nobody/Anonymous (nobody) Summary: Similar XML comparison fails Initial Comment: Hi, I'm comparing 2 XML strings that are not identical but similar - both XML strings have the same nodes but in a different order. I used RecursiveElementNameAndTextQualifier but the similar comparison fails. I'm using version 1.2. Here is my java code. import org.custommonkey.xmlunit.XMLUnit; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; public class XMLUnitTest { public static void main(String... args) throws Exception { String s1 = "<main>" + " <inner>" + " <bar>50015</bar>" + " </inner>" + " <inner>" + " <bar>50003</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50020</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + "</main>"; String s2 = "<main>" + " <inner>" + " <bar>50003</bar>" + " </inner>" + " <inner>" + " <bar>50015</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50013</bar>" + " </inner>" + " <inner>" + " <bar>50020</bar>" + " </inner>" + "</main>"; XMLUnit.setIgnoreWhitespace(true); Diff diff = new Diff(s1, s2); diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); boolean isSimilar = diff.similar(); if (!isSimilar) { System.out.println(diff); } } } I get the following error: org.custommonkey.xmlunit.Diff [not identical] Expected sequence of child nodes '0' but was '1' - comparing <inner...> at /main[1]/inner[1] to <inner...> at /main[1]/inner[2] [not identical] Expected sequence of child nodes '1' but was '0' - comparing <inner...> at /main[1]/inner[2] to <inner...> at /main[1]/inner[1] [not identical] Expected sequence of child nodes '3' but was '4' - comparing <inner...> at /main[1]/inner[4] to <inner...> at /main[1]/inner[5] [not identical] Expected sequence of child nodes '4' but was '2' - comparing <inner...> at /main[1]/inner[5] to <inner...> at /main[1]/inner[3] [different] Expected presence of child node 'null' but was 'inner' - comparing at null to <inner...> at /main[1]/inner[4] Thanks for looking into this. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2836385&group_id=23187 |
From: <bo...@us...> - 2009-07-30 15:43:59
|
Revision: 351 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=351&view=rev Author: bodewig Date: 2009-07-30 15:43:52 +0000 (Thu, 30 Jul 2009) Log Message: ----------- Upgrade JUnit to 4.7 Added Paths: ----------- trunk/xmlunit/lib/junit-4.7.jar Removed Paths: ------------- trunk/xmlunit/lib/junit-4.6.jar Deleted: trunk/xmlunit/lib/junit-4.6.jar =================================================================== (Binary files differ) Added: trunk/xmlunit/lib/junit-4.7.jar =================================================================== (Binary files differ) Property changes on: trunk/xmlunit/lib/junit-4.7.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-07-04 02:20:33
|
Bugs item #2807167, was opened at 2009-06-16 13:37 Message generated for change (Comment added) made by sf-robot You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2807167&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: Java 1.2 >Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: LaTruffe (latruffe) Assigned to: Nobody/Anonymous (nobody) Summary: Comparison Error Initial Comment: 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 Rmy ---------------------------------------------------------------------- >Comment By: SourceForge Robot (sf-robot) Date: 2009-07-04 02:20 Message: 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). ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2009-06-19 09:29 Message: 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. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2807167&group_id=23187 |
From: <bo...@us...> - 2009-06-19 11:29:41
|
Revision: 350 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=350&view=rev Author: bodewig Date: 2009-06-19 11:29:39 +0000 (Fri, 19 Jun 2009) Log Message: ----------- turn message 4817456 into a unit test Modified Paths: -------------- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 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 2009-06-19 11:20:40 UTC (rev 349) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2009-06-19 11:29:39 UTC (rev 350) @@ -929,6 +929,41 @@ assertFalse(listener.different); } + + /** + * @see https://sourceforge.net/forum/message.php?msg_id=4817456 + */ + public void testForumMessage4817456() throws Exception { + String control = "<doc>" + + "<id>123</id>" + + "<remarks>a</remarks>" + + "<remarks>b</remarks>" + + "<remarks>c</remarks>" + + "<remarks>d</remarks>" + + "<others>1</others>" + + "<others>2</others>" + + "<others>3</others>" + + "</doc>"; + String test = "<doc>" + + "<id>123</id>" + + "<remarks>a</remarks>" + + "<remarks>b</remarks>" + + "<remarks>c</remarks>" + + "<remarks>d</remarks>" + + "<remarks>e</remarks>" + + "<others>2</others>" + + "<others>3</others>" + + "</doc>"; + + Document controlDoc = XMLUnit.buildControlDocument(control); + Document testDoc = XMLUnit.buildTestDocument(test); + engine.compare(controlDoc, testDoc, listener, + new ElementNameAndTextQualifier()); + assertTrue(listener.different); + assertEquals(DifferenceConstants.ELEMENT_TAG_NAME_ID, + listener.comparingWhat); + } + private void listenToDifferences(String control, String test) throws SAXException, IOException { Document controlDoc = XMLUnit.buildControlDocument(control); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-06-19 11:20:46
|
Revision: 349 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=349&view=rev Author: bodewig Date: 2009-06-19 11:20:40 +0000 (Fri, 19 Jun 2009) Log Message: ----------- whitespace Modified Paths: -------------- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 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 2009-06-19 11:14:53 UTC (rev 348) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2009-06-19 11:20:40 UTC (rev 349) @@ -908,6 +908,5 @@ ElementNameAndAttributeQualifier()); assertTrue(diff.toString(), diff.similar()); } - } 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 2009-06-19 11:14:53 UTC (rev 348) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2009-06-19 11:20:40 UTC (rev 349) @@ -65,7 +65,7 @@ private CollectingDifferenceListener listener; private DifferenceEngine engine; private Document document; - + private final ComparisonController PSEUDO_DIFF = new SimpleComparisonController(); private final ComparisonController PSEUDO_DETAILED_DIFF = new NeverHaltingComparisonController(); @@ -508,7 +508,7 @@ fail("Not expecting difference found exception"); } } - + public void testXpathLocation1() throws Exception { String control = "<dvorak><keyboard/><composer/></dvorak>"; String test = "<qwerty><keyboard/></qwerty>"; @@ -516,64 +516,64 @@ assertEquals("1st control xpath", "/dvorak[1]", listener.controlXpath); assertEquals("1st test xpath", "/qwerty[1]", listener.testXpath); } - - public void testXpathLocation2() throws Exception { + + public void testXpathLocation2() throws Exception { String control = "<dvorak><keyboard/><composer/></dvorak>"; String test = "<qwerty><keyboard/></qwerty>"; String start = "<a>", end = "</a>"; listenToDifferences(start + control + end, start + test + end); assertEquals("2nd control xpath", "/a[1]/dvorak[1]", listener.controlXpath); - assertEquals("2nd test xpath", "/a[1]/qwerty[1]", listener.testXpath); + assertEquals("2nd test xpath", "/a[1]/qwerty[1]", listener.testXpath); } - + public void testXpathLocation3() throws Exception { String control = "<stuff><wood type=\"rough\"/></stuff>"; String test = "<stuff><wood type=\"smooth\"/></stuff>"; listenToDifferences(control, test); assertEquals("3rd control xpath", "/stuff[1]/wood[1]/@type", listener.controlXpath); - assertEquals("3rd test xpath", "/stuff[1]/wood[1]/@type", listener.testXpath); + assertEquals("3rd test xpath", "/stuff[1]/wood[1]/@type", listener.testXpath); } - + public void testXpathLocation4() throws Exception { String control = "<stuff><glass colour=\"clear\"/><glass colour=\"green\"/></stuff>"; String test = "<stuff><glass colour=\"clear\"/><glass colour=\"blue\"/></stuff>";; listenToDifferences(control, test); assertEquals("4th control xpath", "/stuff[1]/glass[2]/@colour", listener.controlXpath); - assertEquals("4th test xpath", "/stuff[1]/glass[2]/@colour", listener.testXpath); + assertEquals("4th test xpath", "/stuff[1]/glass[2]/@colour", listener.testXpath); } - + public void testXpathLocation5() throws Exception { String control = "<stuff><wood>maple</wood><wood>oak</wood></stuff>"; String test = "<stuff><wood>maple</wood><wood>ash</wood></stuff>"; listenToDifferences(control, test); assertEquals("5th control xpath", "/stuff[1]/wood[2]/text()[1]", listener.controlXpath); - assertEquals("5th test xpath", "/stuff[1]/wood[2]/text()[1]", listener.testXpath); + assertEquals("5th test xpath", "/stuff[1]/wood[2]/text()[1]", listener.testXpath); } - + public void testXpathLocation6() throws Exception { String control = "<stuff><list><wood/><glass/></list><item/></stuff>"; String test = "<stuff><list><wood/><glass/></list><item>description</item></stuff>"; listenToDifferences(control, test); assertEquals("6th control xpath", "/stuff[1]/item[1]", listener.controlXpath); - assertEquals("6th test xpath", "/stuff[1]/item[1]", listener.testXpath); + assertEquals("6th test xpath", "/stuff[1]/item[1]", listener.testXpath); } - + public void testXpathLocation7() throws Exception { String control = "<stuff><list><wood/></list></stuff>"; String test = "<stuff><list><glass/></list></stuff>"; listenToDifferences(control, test); assertEquals("7th control xpath", "/stuff[1]/list[1]/wood[1]", listener.controlXpath); - assertEquals("7th test xpath", "/stuff[1]/list[1]/glass[1]", listener.testXpath); + assertEquals("7th test xpath", "/stuff[1]/list[1]/glass[1]", listener.testXpath); } - + public void testXpathLocation8() throws Exception { String control = "<stuff><list><!--wood--></list></stuff>"; String test = "<stuff><list><!--glass--></list></stuff>"; listenToDifferences(control, test); assertEquals("8th control xpath", "/stuff[1]/list[1]/comment()[1]", listener.controlXpath); - assertEquals("8th test xpath", "/stuff[1]/list[1]/comment()[1]", listener.testXpath); + assertEquals("8th test xpath", "/stuff[1]/list[1]/comment()[1]", listener.testXpath); } - + public void testXpathLocation9() throws Exception { String control = "<stuff><list/><?wood rough?><list/></stuff>"; String test = "<stuff><list/><?glass clear?><list/></stuff>"; @@ -581,9 +581,9 @@ assertEquals("9th control xpath", "/stuff[1]/processing-instruction()[1]", listener.controlXpath); assertEquals("9th test xpath", "/stuff[1]/processing-instruction()[1]", - listener.testXpath); + listener.testXpath); } - + public void testXpathLocation10() throws Exception { String control = "<stuff><list/>list<![CDATA[wood]]></stuff>"; String test = "<stuff><list/>list<![CDATA[glass]]></stuff>"; @@ -591,9 +591,9 @@ assertEquals("10th control xpath", "/stuff[1]/text()[2]", listener.controlXpath); assertEquals("10th test xpath", "/stuff[1]/text()[2]", - listener.testXpath); + listener.testXpath); } - + public void testXpathLocation11() throws Exception { String control = "<stuff><list><item/></list></stuff>"; String test = "<stuff><list>item text</list></stuff>"; @@ -601,7 +601,7 @@ assertEquals("11th control xpath", "/stuff[1]/list[1]/item[1]", listener.controlXpath); assertEquals("11th test xpath", "/stuff[1]/list[1]/text()[1]", - listener.testXpath); + listener.testXpath); } public void testXpathLocation12() throws Exception { @@ -612,7 +612,7 @@ assertEquals("12th control xpath", "/stuff[1]/item[2]", listener.controlXpath); assertEquals("12th test xpath", "/stuff[1]/item[1]", - listener.testXpath); + listener.testXpath); } public void testXpathLocation13() throws Exception { @@ -626,7 +626,7 @@ listener.comparingWhat); assertEquals("13th control xpath", "/stuff[1]/item[2]", listener.controlXpath); - assertNull("13th test xpath", listener.testXpath); + assertNull("13th test xpath", listener.testXpath); } public void testXpathLocation14() throws Exception { @@ -637,7 +637,7 @@ assertEquals("14th control xpath", "/stuff[1]/item[1]/@id", listener.controlXpath); assertEquals("14th test xpath", "/stuff[1]/item[2]/@id", - listener.testXpath); + listener.testXpath); } public void testIssue1027863() throws Exception { @@ -655,7 +655,7 @@ assertEquals("15th control xpath", "/stuff[1]/item[1]", listener.controlXpath); assertEquals("15th test xpath", "/stuff[1]/item[1]", - listener.testXpath); + listener.testXpath); } public void testNormalizeWhitespace() { @@ -935,8 +935,8 @@ Document testDoc = XMLUnit.buildTestDocument(test); engine.compare(controlDoc, testDoc, listener, DEFAULT_ELEMENT_QUALIFIER); } - + private void resetListener() { listener = new CollectingDifferenceListener(); } @@ -953,13 +953,13 @@ return !afterDifference.isRecoverable(); } } - + private class NeverHaltingComparisonController implements ComparisonController { public boolean haltComparison(Difference afterDifference) { return false; } } - + private class CollectingDifferenceListener implements DifferenceListener { public String expected; public String actual; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-06-19 11:14:55
|
Revision: 348 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=348&view=rev Author: bodewig Date: 2009-06-19 11:14:53 +0000 (Fri, 19 Jun 2009) Log Message: ----------- whitespace Modified Paths: -------------- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 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 2009-06-19 09:36:07 UTC (rev 347) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2009-06-19 11:14:53 UTC (rev 348) @@ -186,7 +186,7 @@ Diff diff = buildDiff("<same except=\"this\">pass</same>", "<same>pass</same>"); assertEquals("should not be identical", false, diff.identical()); assertEquals("and should not be similar", false, diff.similar()); - } + } public void testAttributesInReverseOrder() throws Exception { Diff diff = buildDiff("<same zzz=\"qwerty\" aaa=\"uiop\">pass</same>", @@ -198,7 +198,7 @@ assertEquals(diff.toString() + ": but should be similar", true, diff.similar()); } - + public void testDiffStringWithAttributes() throws Exception { final String fruitBat = "<bat type=\"fruit\"/>", longEaredBat = "<bat type=\"longeared\"/>"; @@ -209,7 +209,7 @@ + "<bat type=\"fruit\"...> at /bat[1]/@type to <bat type=\"longeared\"...> at /bat[1]/@type\n", diff.toString()); } - + public void testXMLWithDTD() throws Exception { String aDTDpart = "<!DOCTYPE test [" + "<!ELEMENT assertion EMPTY>" @@ -224,7 +224,7 @@ Diff diff = buildDiff(xmlWithDTD, xmlWithoutDTD); assertTrue("similar. " + diff.toString(), diff.similar()); assertTrue("not identical. " + diff.toString(), !diff.identical()); - + File tempDtdFile = File.createTempFile(getName(), "dtd"); tempDtdFile.deleteOnExit(); FileWriter dtdWriter = new FileWriter(tempDtdFile); @@ -235,17 +235,17 @@ + xmlWithoutDTD; diff = buildDiff(xmlWithDTD, xmlWithExternalDTD); assertTrue("similar again. " + diff.toString(), diff.similar()); - assertTrue("not identical again. " + diff.toString(), !diff.identical()); + assertTrue("not identical again. " + diff.toString(), !diff.identical()); } finally { tempDtdFile.delete(); } String anotherDTD = aDTDpart - + "<!ELEMENT comment (ANY)>" + "]>"; + + "<!ELEMENT comment (ANY)>" + "]>"; String xmlWithAnotherDTD = anotherDTD + xmlWithoutDTD; diff = buildDiff(xmlWithDTD, xmlWithAnotherDTD); assertTrue("similar. " + diff.toString(), diff.similar()); - assertTrue("amd identical as DTD content is not compared. " + diff.toString(), diff.identical()); + assertTrue("amd identical as DTD content is not compared. " + diff.toString(), diff.identical()); } /** @@ -349,7 +349,7 @@ assertTrue("c-"+reverseDiff.toString(), reverseDiff.similar()); assertTrue("d-"+reverseDiff.toString(), !reverseDiff.identical()); } - + public void testOverrideDifferenceListener() throws Exception { String control = "<vehicles><car colour=\"white\">ford fiesta</car>" +"<car colour=\"red\">citroen xsara</car></vehicles>"; @@ -358,7 +358,7 @@ Diff diff = buildDiff(control, test); assertTrue("initially " + diff.toString(), !diff.similar()); - + Diff diffWithIdenticalOverride = buildDiff(control, test); diffWithIdenticalOverride.overrideDifferenceListener( new OverrideDifferenceListener( @@ -366,7 +366,7 @@ assertTrue("now identical" + diffWithIdenticalOverride.toString(), diffWithIdenticalOverride.identical()); - + Diff diffWithSimilarOverride = buildDiff(control, test); diffWithSimilarOverride.overrideDifferenceListener( new OverrideDifferenceListener( @@ -377,7 +377,7 @@ assertTrue("but still similar" + diffWithSimilarOverride.toString(), diffWithSimilarOverride.similar()); - + Diff diffWithOverride = buildDiff(control, test); diffWithOverride.overrideDifferenceListener( new OverrideDifferenceListener( @@ -386,7 +386,7 @@ + diffWithOverride.toString(), !diffWithOverride.similar()); } - + public void testNamespacedAttributes() throws Exception { FileReader control = new FileReader(test_Constants.BASEDIR + "/tests/etc/controlNamespaces.xml"); @@ -466,7 +466,7 @@ assertFalse("should not be identical: " + diff.toString(), diff.identical()); assertTrue("should be similar: " + diff.toString(), diff.similar()); } - + // defect raised by Kevin Krouse Jan 2003 public void testXMLNSNumberOfAttributes() throws Exception { Diff diff = buildDiff("<root xmlns=\"qwerty\"><node/></root>", @@ -474,7 +474,7 @@ assertTrue(diff.toString(), diff.similar()); assertFalse(diff.toString(), diff.identical()); } - + protected Diff buildDiff(Document control, Document test) { return new Diff(control, test); } @@ -512,7 +512,7 @@ public void skippedComparison(Node control, Node test) { } } - + private class ExpectedDifferenceListener implements DifferenceListener { private final Set expectedIds; private ExpectedDifferenceListener(int expectedIdValue) { @@ -534,15 +534,15 @@ protected void examineDifferenceContents(Difference difference) { } } - + private abstract class ExaminingExpectedDifferenceListener extends ExpectedDifferenceListener { private ExaminingExpectedDifferenceListener(int expectedIdValue) { super(expectedIdValue); } protected abstract void examineDifferenceContents(Difference difference) ; } - + public void testIssue1189681() throws Exception { String left = "" + "<farm>\n" + @@ -717,21 +717,21 @@ * @see http://sourceforge.net/tracker/index.php?func=detail&aid=1779701&group_id=23187&atid=377768 */ public void testWhitespaceAndNamespaces() throws Exception { - String control = - "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" - + "\r\n <env:Header/>" - + "\r\n </env:Envelope>"; - String test = - "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" - + "<env:Header/>" - + "</env:Envelope>"; - XMLUnit.setIgnoreWhitespace(true); - try { - Diff diff = buildDiff(control, test); - assertTrue(diff.toString(), diff.identical()); - } finally { - XMLUnit.setIgnoreWhitespace(false); - } + String control = + "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + + "\r\n <env:Header/>" + + "\r\n </env:Envelope>"; + String test = + "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + + "<env:Header/>" + + "</env:Envelope>"; + XMLUnit.setIgnoreWhitespace(true); + try { + Diff diff = buildDiff(control, test); + assertTrue(diff.toString(), diff.identical()); + } finally { + XMLUnit.setIgnoreWhitespace(false); + } } /** @@ -739,15 +739,15 @@ * @see http://sourceforge.net/tracker/index.php?func=detail&aid=1863632&group_id=23187&atid=377768 */ public void testBasicWhitespaceHandling() throws Exception { - String control = "<a><b/></a>"; - String test = "<a>\r\n <b/>\r\n</a>"; - XMLUnit.setIgnoreWhitespace(true); - try { - Diff diff = buildDiff(control, test); - assertTrue(diff.toString(), diff.identical()); - } finally { - XMLUnit.setIgnoreWhitespace(false); - } + String control = "<a><b/></a>"; + String test = "<a>\r\n <b/>\r\n</a>"; + XMLUnit.setIgnoreWhitespace(true); + try { + Diff diff = buildDiff(control, test); + assertTrue(diff.toString(), diff.identical()); + } finally { + XMLUnit.setIgnoreWhitespace(false); + } } public void testUpgradingOfRecoverableDifference() throws Exception { @@ -855,7 +855,7 @@ +" </Name>" +" </Person>" +"</Data>"; - + XMLUnit.setIgnoreWhitespace(true); XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); try { @@ -908,5 +908,6 @@ ElementNameAndAttributeQualifier()); assertTrue(diff.toString(), diff.similar()); } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-06-19 09:36:09
|
Revision: 347 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=347&view=rev Author: bodewig Date: 2009-06-19 09:36:07 +0000 (Fri, 19 Jun 2009) Log Message: ----------- merge fix for issue 2807167 from 1.x branch Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Property Changed: ---------------- trunk/xmlunit/src/main/java-legacy/ trunk/xmlunit/src/tests/java-legacy/ trunk/xmlunit/src/user-guide/ Property changes on: trunk/xmlunit/src/main/java-legacy ___________________________________________________________________ Modified: svn:mergeinfo - + /branches/xmlunit-1.x/src/java:346 Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java 2009-06-19 09:26:16 UTC (rev 346) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java 2009-06-19 09:36:07 UTC (rev 347) @@ -397,6 +397,30 @@ boolean matchFound = false; + /* + * XMLUnit 1.2 and earlier don't check whether the + * "matched" test node has already been matched to a + * different control node and will happily match the same + * test node to each and every control node, if necessary. + * + * I (Stefan) feel this is wrong but can't change it + * without breaking backwards compatibility + * (testXpathLocation12 in test_DifferenceEngine which + * predates XMLUnit 1.0 fails, so at one point it has been + * the expected and intended behaviour). + * + * As a side effect it may leave test nodes inside the + * unmatched list, see + * https://sourceforge.net/tracker/?func=detail&aid=2807167&group_id=23187&atid=377768 + * + * To overcome the later problem the code will now prefer + * test nodes that haven't already been matched to any + * other node and falls back to the first + * (multiply-)matched node if none could be found. Yes, + * this is strange. + */ + int fallbackMatch = -1; + while (!matchFound) { Node t = (Node) testChildren.get(j); if (findNodeType == t.getNodeType() @@ -407,6 +431,18 @@ .qualifyForComparison((Element) nextControl, (Element) t); } + if (matchFound && !unmatchedTestNodes.contains(t)) { + /* + * test node already matched to a different + * control node, try the other test nodes first + * but keep this as "fallback" (unless there + * already is a fallback) + */ + if (fallbackMatch < 0) { + fallbackMatch = j; + } + matchFound = false; + } if (!matchFound) { ++j; if (j > lastTestNode) { @@ -418,6 +454,10 @@ } } } + if (!matchFound && fallbackMatch >= 0) { + matchFound = true; + j = fallbackMatch; + } if (matchFound) { matchingNodes.put(nextControl, testChildren.get(j)); matchingNodeIndexes.put(nextControl, new Integer(j)); Property changes on: trunk/xmlunit/src/tests/java-legacy ___________________________________________________________________ Modified: svn:mergeinfo - /branches/xmlunit-1.x/tests/java:337 + /branches/xmlunit-1.x/tests:346 /branches/xmlunit-1.x/tests/java:337,346 Modified: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2009-06-19 09:26:16 UTC (rev 346) +++ trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2009-06-19 09:36:07 UTC (rev 347) @@ -882,5 +882,31 @@ XMLUnit.setExpandEntityReferences(false); } } + + /** + * @see https://sourceforge.net/tracker/?func=detail&aid=2807167&group_id=23187&atid=377768 + */ + public void testIssue2807167() throws Exception { + 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 diff = new Diff(control, test); + diff.overrideElementQualifier(new + ElementNameAndAttributeQualifier()); + assertTrue(diff.toString(), diff.similar()); + } } Property changes on: trunk/xmlunit/src/user-guide ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x/src/user-guide:346 Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2009-06-19 09:26:16 UTC (rev 346) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2009-06-19 09:36:07 UTC (rev 347) @@ -3542,8 +3542,15 @@ a <literal>ATTR_NAME_NOT_FOUND_ID</literal> kind of difference), the XPath expressions of the node details have been random. <ulink - url="https://sourceforge.net/tracker/index.php?func=detail&aid=2386807&group_id=23187&atid=377768">Issue 2386807</ulink>. + url="https://sourceforge.net/tracker/index.php?func=detail&aid=2386807&group_id=23187&atid=377768">Issue 2386807</ulink>. </listitem> + <listitem> + In some cases XMLUnit matched test nodes to multiple + control nodes and then created a "missing child" + difference for remaining test nodes even though they would + have been valid targets for control node matches as well. + <ulink url="https://sourceforge.net/tracker/?func=detail&aid=2807167&group_id=23187&atid=377768">Issue 2807167</ulink>. + </listitem> </itemizedlist> </section> </section> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-06-19 09:29:42
|
Bugs item #2807167, was opened at 2009-06-16 15:37 Message generated for change (Settings changed) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2807167&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: Java 1.2 >Status: Pending >Resolution: Fixed Priority: 5 Private: No Submitted By: LaTruffe (latruffe) Assigned to: Nobody/Anonymous (nobody) Summary: Comparison Error Initial Comment: 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 ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2009-06-19 11:29 Message: 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. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2807167&group_id=23187 |
From: <bo...@us...> - 2009-06-19 09:26:22
|
Revision: 346 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=346&view=rev Author: bodewig Date: 2009-06-19 09:26:16 +0000 (Fri, 19 Jun 2009) Log Message: ----------- fix issue 2807167 Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2009-06-09 11:45:58 UTC (rev 345) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2009-06-19 09:26:16 UTC (rev 346) @@ -397,6 +397,30 @@ boolean matchFound = false; + /* + * XMLUnit 1.2 and earlier don't check whether the + * "matched" test node has already been matched to a + * different control node and will happily match the same + * test node to each and every control node, if necessary. + * + * I (Stefan) feel this is wrong but can't change it + * without breaking backwards compatibility + * (testXpathLocation12 in test_DifferenceEngine which + * predates XMLUnit 1.0 fails, so at one point it has been + * the expected and intended behaviour). + * + * As a side effect it may leave test nodes inside the + * unmatched list, see + * https://sourceforge.net/tracker/?func=detail&aid=2807167&group_id=23187&atid=377768 + * + * To overcome the later problem the code will now prefer + * test nodes that haven't already been matched to any + * other node and falls back to the first + * (multiply-)matched node if none could be found. Yes, + * this is strange. + */ + int fallbackMatch = -1; + while (!matchFound) { Node t = (Node) testChildren.get(j); if (findNodeType == t.getNodeType() @@ -407,6 +431,18 @@ .qualifyForComparison((Element) nextControl, (Element) t); } + if (matchFound && !unmatchedTestNodes.contains(t)) { + /* + * test node already matched to a different + * control node, try the other test nodes first + * but keep this as "fallback" (unless there + * already is a fallback) + */ + if (fallbackMatch < 0) { + fallbackMatch = j; + } + matchFound = false; + } if (!matchFound) { ++j; if (j > lastTestNode) { @@ -418,6 +454,10 @@ } } } + if (!matchFound && fallbackMatch >= 0) { + matchFound = true; + j = fallbackMatch; + } if (matchFound) { matchingNodes.put(nextControl, testChildren.get(j)); matchingNodeIndexes.put(nextControl, new Integer(j)); Modified: branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml =================================================================== --- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2009-06-09 11:45:58 UTC (rev 345) +++ branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2009-06-19 09:26:16 UTC (rev 346) @@ -3542,8 +3542,15 @@ a <literal>ATTR_NAME_NOT_FOUND_ID</literal> kind of difference), the XPath expressions of the node details have been random. <ulink - url="https://sourceforge.net/tracker/index.php?func=detail&aid=2386807&group_id=23187&atid=377768">Issue 2386807</ulink>. + url="https://sourceforge.net/tracker/index.php?func=detail&aid=2386807&group_id=23187&atid=377768">Issue 2386807</ulink>. </listitem> + <listitem> + In some cases XMLUnit matched test nodes to multiple + control nodes and then created a "missing child" + difference for remaining test nodes even though they would + have been valid targets for control node matches as well. + <ulink url="https://sourceforge.net/tracker/?func=detail&aid=2807167&group_id=23187&atid=377768">Issue 2807167</ulink>. + </listitem> </itemizedlist> </section> </section> 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 2009-06-09 11:45:58 UTC (rev 345) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2009-06-19 09:26:16 UTC (rev 346) @@ -882,5 +882,31 @@ XMLUnit.setExpandEntityReferences(false); } } + + /** + * @see https://sourceforge.net/tracker/?func=detail&aid=2807167&group_id=23187&atid=377768 + */ + public void testIssue2807167() throws Exception { + 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 diff = new Diff(control, test); + diff.overrideElementQualifier(new + ElementNameAndAttributeQualifier()); + assertTrue(diff.toString(), diff.similar()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-06-16 13:37:50
|
Bugs item #2807167, was opened at 2009-06-16 15:37 Message generated for change (Tracker Item Submitted) made by latruffe You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2807167&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: Java 1.2 Status: Open Resolution: None Priority: 5 Private: No Submitted By: LaTruffe (latruffe) Assigned to: Nobody/Anonymous (nobody) Summary: Comparison Error Initial Comment: 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 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2807167&group_id=23187 |
From: <bo...@us...> - 2009-06-09 11:46:02
|
Revision: 345 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=345&view=rev Author: bodewig Date: 2009-06-09 11:45:58 +0000 (Tue, 09 Jun 2009) Log Message: ----------- test for forum thread 3292605 Modified Paths: -------------- branches/xmlunit-1.x/tests/csharp/XmlDiffTests.cs branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java Modified: branches/xmlunit-1.x/tests/csharp/XmlDiffTests.cs =================================================================== --- branches/xmlunit-1.x/tests/csharp/XmlDiffTests.cs 2009-06-05 15:51:43 UTC (rev 344) +++ branches/xmlunit-1.x/tests/csharp/XmlDiffTests.cs 2009-06-09 11:45:58 UTC (rev 345) @@ -125,5 +125,53 @@ AssertExpectedResult(input1, input2, false); } + [Test] public void NamespaceAttributeDifferences() { + string control = "<?xml version = \"1.0\" encoding = \"UTF-8\"?>" + + "<ns0:Message xmlns:ns0 = \"http://mynamespace\">" + + "<ns0:EventHeader>" + + "<ns0:EventID>9999</ns0:EventID>" + + "<ns0:MessageID>1243409665297</ns0:MessageID>" + + "<ns0:MessageVersionID>1.0</ns0:MessageVersionID>" + + "<ns0:EventName>TEST-EVENT</ns0:EventName>" + + "<ns0:BWDomain>TEST</ns0:BWDomain>" + + "<ns0:DateTimeStamp>2009-01-01T12:00:00</ns0:DateTimeStamp>" + + "<ns0:SchemaPayloadRef>anything</ns0:SchemaPayloadRef>" + + "<ns0:MessageURI>anything</ns0:MessageURI>" + + "<ns0:ResendFlag>F</ns0:ResendFlag>" + + "</ns0:EventHeader>" + + "<ns0:EventBody>" + + "<ns0:XMLContent>" + + "<xyz:root xmlns:xyz=\"http://test.com/xyz\">" + + "<xyz:test1>A</xyz:test1>" + + "<xyz:test2>B</xyz:test2>" + + "</xyz:root>" + + "</ns0:XMLContent>" + + "</ns0:EventBody>" + + "</ns0:Message>"; + string test = + "<abc:Message xmlns:abc=\"http://mynamespace\" xmlns:xyz=\"http://test.com/xyz\">" + + "<abc:EventHeader>" + + "<abc:EventID>9999</abc:EventID>" + + "<abc:MessageID>1243409665297</abc:MessageID>" + + "<abc:MessageVersionID>1.0</abc:MessageVersionID>" + + "<abc:EventName>TEST-EVENT</abc:EventName>" + + "<abc:BWDomain>TEST</abc:BWDomain>" + + "<abc:DateTimeStamp>2009-01-01T12:00:00</abc:DateTimeStamp>" + + "<abc:SchemaPayloadRef>anything</abc:SchemaPayloadRef>" + + "<abc:MessageURI>anything</abc:MessageURI>" + + "<abc:ResendFlag>F</abc:ResendFlag>" + + "</abc:EventHeader>" + + "<abc:EventBody>" + + "<abc:XMLContent>" + + "<xyz:root>" + + "<xyz:test1>A</xyz:test1>" + + "<xyz:test2>B</xyz:test2>" + + "</xyz:root>" + + "</abc:XMLContent>" + + "</abc:EventBody>" + + "</abc:Message>"; + AssertExpectedResult(control, test, true); + } + } } Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java 2009-06-05 15:51:43 UTC (rev 344) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java 2009-06-09 11:45:58 UTC (rev 345) @@ -192,4 +192,20 @@ // acceptable in the JAXP 1.2 case } } + + // https://sourceforge.net/forum/forum.php?thread_id=3292605&forum_id=73274 + public void testDefaultNamespace() throws Exception { + String t = "<a xmlns=\"http://www.acme.com\"><b c='cv'>bv</b></a>"; + + Document d = XMLUnit.buildControlDocument(t); + HashMap m = new HashMap(); + m.put("", "http://www.acme.com"); + m.put("q", "http://www.acme.com"); + + NamespaceContext ctx = new SimpleNamespaceContext(m); + XpathEngine engine = newXpathEngine(); + engine.setNamespaceContext(ctx); + // fails assertEquals("bv", engine.evaluate("//b", d)); + assertEquals("bv", engine.evaluate("//q:b", d)); + } } 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 2009-06-05 15:51:43 UTC (rev 344) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2009-06-09 11:45:58 UTC (rev 345) @@ -925,7 +925,6 @@ + "</abc:XMLContent>" + "</abc:EventBody>" + "</abc:Message>"; - listener.tracing = true; listenToDifferences(control, test); assertFalse(listener.different); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2009-06-09 11:16:49
|
Bugs item #2770386, was opened at 2009-04-17 11:13 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2770386&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: Java 1.2 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Urs Reupke (urskr) Assigned to: Nobody/Anonymous (nobody) Summary: Respect comments in prelude when checking for identity Initial Comment: Trying to verify that a document is identical after being run through an XSL-sheet, I get a green test despite my removing the leading comment prior to the transformation. This is a problem, because I want to write a java wrapper for my xsl sheet that removes comments in front of the root and adds them afterwards without modifying. I'd appreciate if you could look into this. ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2009-06-09 13:16 Message: The current implementation of DifferenceEngine ignores everything between the DOCTYPE declaration (if any) and the document element, so the prelude is completely ignored. Just as is the case with bug 2758280 there may be code that relies on this behavior so we'd have to introduce yet another option if we wanted to change it. It is something I want to keep in mind for our ongoing (rather nascent) discussion of a new API for XMLUnit2 - it is unlikely to get fixed in the 1.x codebase. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2770386&group_id=23187 |
From: SourceForge.net <no...@so...> - 2009-06-09 11:12:18
|
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-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 |
From: <bo...@us...> - 2009-06-05 15:51:47
|
Revision: 344 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=344&view=rev Author: bodewig Date: 2009-06-05 15:51:43 +0000 (Fri, 05 Jun 2009) Log Message: ----------- implement validation for .NET - DTD validation not tested, yet (and probably not complete either) Modified Paths: -------------- trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs trunk/xmlunit/src/main/net-core/validation/Validator.cs Added Paths: ----------- trunk/xmlunit/src/tests/net-core/validation/ trunk/xmlunit/src/tests/net-core/validation/ValidatorTest.cs Modified: trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs =================================================================== --- trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs 2009-06-05 10:45:00 UTC (rev 343) +++ trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs 2009-06-05 15:51:43 UTC (rev 344) @@ -68,5 +68,13 @@ return message; } } + + internal static ValidationProblem FromEvent(ValidationEventArgs e) { + XmlSchemaException ex = e.Exception; + return new ValidationProblem(e.Message, + ex == null ? UNKNOWN : ex.LineNumber, + ex == null ? UNKNOWN : ex.LinePosition, + e.Severity); + } } } Modified: trunk/xmlunit/src/main/net-core/validation/Validator.cs =================================================================== --- trunk/xmlunit/src/main/net-core/validation/Validator.cs 2009-06-05 10:45:00 UTC (rev 343) +++ trunk/xmlunit/src/main/net-core/validation/Validator.cs 2009-06-05 15:51:43 UTC (rev 344) @@ -13,7 +13,10 @@ */ using System; using System.Collections.Generic; +using System.IO; using System.Xml; +using System.Xml.Schema; +using net.sf.xmlunit.exceptions; namespace net.sf.xmlunit.validation { @@ -73,6 +76,15 @@ /// Validates a schema. /// </summary> public virtual ValidationResult ValidateSchema() { + if (language == ValidationType.Schema && sourceLocations != null) { + List<ValidationProblem> problems = + new List<ValidationProblem>(); + foreach (ISource loc in sourceLocations) { + XmlSchema s = XmlSchema.Read(loc.Reader, + CollectProblems(problems)); + } + return new ValidationResult(problems.Count == 0, problems); + } throw new NotImplementedException(); } @@ -80,10 +92,31 @@ /// Validates an instance against the schema. /// </summary> public virtual ValidationResult ValidateInstance(ISource instance) { - throw new NotImplementedException(); + XmlReaderSettings settings = new XmlReaderSettings(); + settings.ValidationType = language; + settings.ValidationFlags = + XmlSchemaValidationFlags.ProcessIdentityConstraints + | XmlSchemaValidationFlags.ReportValidationWarnings; + if (language == ValidationType.Schema && sourceLocations != null) { + foreach (ISource loc in sourceLocations) { + try { + XmlSchema s = XmlSchema.Read(loc.Reader, ThrowOnError); + settings.Schemas.Add(s); + } catch (IOException ex) { + throw new XMLUnitException("Schema is not readable", + ex); + } + } + } + List<ValidationProblem> problems = new List<ValidationProblem>(); + settings.ValidationEventHandler += CollectProblems(problems); + using (XmlReader r = XmlReader.Create(instance.Reader, + settings)) { + while (r.Read()) ; + } + return new ValidationResult(problems.Count == 0, problems); } - private static readonly IDictionary<string, ValidationType> types; static Validator() { @@ -104,5 +137,16 @@ // TODO pick a better exception type throw new NotImplementedException(); } + + private static ValidationEventHandler CollectProblems(List<ValidationProblem> problems) { + return delegate(object sender, ValidationEventArgs e) { + problems.Add(ValidationProblem.FromEvent(e)); + }; + } + + private static void ThrowOnError(object sender, ValidationEventArgs e) { + throw new XMLUnitException("Schema is invalid", e.Exception); + } + } } Added: trunk/xmlunit/src/tests/net-core/validation/ValidatorTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/validation/ValidatorTest.cs (rev 0) +++ trunk/xmlunit/src/tests/net-core/validation/ValidatorTest.cs 2009-06-05 15:51:43 UTC (rev 344) @@ -0,0 +1,68 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System; +using NUnit.Framework; +using net.sf.xmlunit.exceptions; +using net.sf.xmlunit.input; + +namespace net.sf.xmlunit.validation { + [TestFixture] + public class ValidatorTest { + [Test] + public void ShouldSuccessfullyValidateSchema() { + Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI); + v.SchemaSource = new StreamSource("../../../src/tests/resources/Book.xsd"); + ValidationResult r = v.ValidateSchema(); + Assert.IsTrue(r.Valid); + Assert.IsFalse(r.Problems.GetEnumerator().MoveNext()); + } + + [Test] + public void ShouldSuccessfullyValidateInstance() { + Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI); + v.SchemaSource = new StreamSource("../../../src/tests/resources/Book.xsd"); + ValidationResult r = v.ValidateInstance(new StreamSource("../../../src/tests/resources/BookXsdGenerated.xml")); + Assert.IsTrue(r.Valid); + Assert.IsFalse(r.Problems.GetEnumerator().MoveNext()); + } + + [Test] + public void ShouldFailOnBrokenSchema() { + Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI); + v.SchemaSource = new StreamSource("../../../src/tests/resources/broken.xsd"); + ValidationResult r = v.ValidateSchema(); + Assert.IsFalse(r.Valid); + Assert.IsTrue(r.Problems.GetEnumerator().MoveNext()); + } + + [Test] + public void ShouldFailOnBrokenInstance() { + Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI); + v.SchemaSource = new StreamSource("../../../src/tests/resources/Book.xsd"); + ValidationResult r = v.ValidateInstance(new StreamSource("../../../src/tests/resources/invalidBook.xml")); + Assert.IsFalse(r.Valid); + Assert.IsTrue(r.Problems.GetEnumerator().MoveNext()); + } + + [Test] + public void ShouldThrowWhenValidatingInstanceAndSchemaIsInvalid() { + Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI); + v.SchemaSource = new StreamSource("../../../src/tests/resources/broken.xsd"); + Assert.Throws(typeof(XMLUnitException), delegate() { + v.ValidateInstance(new StreamSource("../../../src/tests/resources/BookXsdGenerated.xml")); + }); + } + + } +} Property changes on: trunk/xmlunit/src/tests/net-core/validation/ValidatorTest.cs ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-06-05 10:45:08
|
Revision: 343 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=343&view=rev Author: bodewig Date: 2009-06-05 10:45:00 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Use explicit instanceOf matchers Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2009-06-02 14:13:03 UTC (rev 342) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2009-06-05 10:45:00 UTC (rev 343) @@ -26,6 +26,7 @@ import javax.xml.transform.sax.SAXSource; import org.w3c.dom.Document; import static org.hamcrest.core.Is.*; +import static org.hamcrest.core.IsInstanceOf.*; import static org.hamcrest.core.IsNull.*; import static org.junit.Assert.*; import org.junit.Test; @@ -45,9 +46,9 @@ // it looks as if SAXSource.sourceToInputSource cannot deal // with a DOMSource, so we cannot use the parse method Source s = Input.fromDocument(d).build(); - assertThat(s, is(DOMSource.class)); + assertThat(s, instanceOf(DOMSource.class)); Object o = ((DOMSource) s).getNode(); - assertThat(o, is(Document.class)); + assertThat(o, instanceOf(Document.class)); Document d2 = (Document) o; assertThat(d2, notNullValue()); assertThat(d2.getDocumentElement().getTagName(), is("animal")); @@ -113,9 +114,9 @@ .build()) .build(); // again, transformed is a DOMSource, cannot use parse() - assertThat(s, is(DOMSource.class)); + assertThat(s, instanceOf(DOMSource.class)); Object o = ((DOMSource) s).getNode(); - assertThat(o, is(Document.class)); + assertThat(o, instanceOf(Document.class)); Document d2 = (Document) o; assertThat(d2, notNullValue()); assertThat(d2.getDocumentElement().getTagName(), is("furry")); Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java 2009-06-02 14:13:03 UTC (rev 342) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java 2009-06-05 10:45:00 UTC (rev 343) @@ -16,7 +16,7 @@ import java.io.File; import javax.xml.transform.stream.StreamSource; import net.sf.xmlunit.exceptions.XMLUnitException; -import static org.hamcrest.core.Is.*; +import static org.hamcrest.core.IsInstanceOf.*; import static org.junit.Assert.*; import org.junit.Test; @@ -61,7 +61,7 @@ v.validateInstance(new StreamSource(new File("src/tests/resources/BookXsdGenerated.xml"))); fail("should have thrown an exception"); } catch (Exception e) { - assertThat(e, is(XMLUnitException.class)); + assertThat(e, instanceOf(XMLUnitException.class)); } } @@ -72,7 +72,7 @@ v.validateInstance(new StreamSource(new File("src/tests/resources/BookXsdGenerated.xml"))); fail("should have thrown an exception"); } catch (Exception e) { - assertThat(e, is(XMLUnitException.class)); + assertThat(e, instanceOf(XMLUnitException.class)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Stefan B. <bo...@ap...> - 2009-06-04 08:09:49
|
To whom it may engage... This is an automated request, but not an unsolicited one. For more information please visit http://gump.apache.org/nagged.html, and/or contact the folk at ge...@gu.... Project xmlunit has an issue affecting its community integration. This issue affects 19 projects, and has been outstanding for 8 runs. The current state of this project is 'Failed', with reason 'Build Failed'. For reference only, the following projects are affected by this: - commons-jelly-tags-jaxme : Commons Jelly - commons-jelly-tags-jmx : Commons Jelly - commons-jelly-tags-ojb : Commons Jelly - commons-jelly-tags-xmlunit : Commons Jelly - db-ojb : ObjectRelationalBridge - db-ojb-from-packages : ObjectRelationalBridge - db-torque-runtime : Persistence Layer - db-torque-runtime-test : Persistence Layer - jakarta-turbine-jcs : Cache - jgroups : A Reliable Multicast Communication Toolkit for Java - mx4j : OpenSource implementation of a JMX agent - mx4j-remote : OpenSource implementation of a JMX agent - mx4j-tools : OpenSource implementation of a JMX agent - mx4j-tools-from-packaged-jetty : OpenSource implementation of a JMX agent - naming-management : Apache Directory Naming Component - test-ojb : ObjectRelationalBridge - ws-axis-test : Apache eXtensible Interaction System - xml-xindice : native XML database - xmlunit : JUnit extension for XML unit tests. Full details are available at: http://vmgump.apache.org/gump/public/xmlunit/xmlunit/index.html That said, some information snippets are provided here. The following annotations (debug/informational/warning/error messages) were provided: -INFO- Failed with reason build failed -INFO- Failed to extract fallback artifacts from Gump Repository The following work was performed: http://vmgump.apache.org/gump/public/xmlunit/xmlunit/gump_work/build_xmlunit_xmlunit.html Work Name: build_xmlunit_xmlunit (Type: Build) Work ended in a state of : Failed Elapsed: 3 secs Command Line: /usr/lib/jvm/java-6-sun/bin/java -Djava.awt.headless=true -Xbootclasspath/p:/srv/gump/public/workspace/xml-commons/java/external/build/xml-apis.jar:/srv/gump/public/workspace/xml-xerces2/build/xercesImpl.jar:/srv/gump/public/workspace/xml-xalan/build/serializer.jar:/srv/gump/public/workspace/xml-xalan/build/xalan-unbundled.jar org.apache.tools.ant.Main -Dgump.merge=/srv/gump/public/gump/work/merge.xml -Dbuild.sysclasspath=only -Dxmlunit.version=04062009 Gump [Working Directory: /srv/gump/public/workspace/xmlunit] CLASSPATH: /usr/lib/jvm/java-6-sun/lib/tools.jar:/srv/gump/public/workspace/xmlunit/build/java/core-classes:/srv/gump/public/workspace/xmlunit/build/java/core-test-classes:/srv/gump/public/workspace/xmlunit/build/java/legacy-classes:/srv/gump/public/workspace/xmlunit/build/java/legacy-test-classes:/srv/gump/public/workspace/ant/dist/lib/ant-jmf.jar:/srv/gump/public/workspace/ant/dist/lib/ant-swing.jar:/srv/gump/public/workspace/ant/dist/lib/ant-apache-resolver.jar:/srv/gump/public/workspace/ant/dist/lib/ant-apache-xalan2.jar:/srv/gump/public/workspace/ant/dist/lib/ant-trax.jar:/srv/gump/public/workspace/ant/dist/lib/ant-junit.jar:/srv/gump/public/workspace/ant/dist/lib/ant-launcher.jar:/srv/gump/public/workspace/ant/dist/lib/ant-nodeps.jar:/srv/gump/public/workspace/ant/dist/lib/ant.jar:/srv/gump/packages/junit3.8.1/junit.jar:/srv/gump/public/workspace/xml-commons/java/build/resolver.jar:/srv/gump/public/workspace/junit/dist/junit-04062009.jar:/srv/gump/public/workspace/xml-commons/java/external/build/xml-apis-ext.jar --------------------------------------------- [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/core-classes [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/legacy-classes [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/core-test-classes [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/legacy-test-classes [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/test-report [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/dist [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/doc [mkdir] Created dir: /srv/gump/public/workspace/xmlunit/build/java/doc/userguide compile-core: [javac] Compiling 10 source files to /srv/gump/public/workspace/xmlunit/build/java/core-classes compile-core-tests: [javac] Compiling 3 source files to /srv/gump/public/workspace/xmlunit/build/java/core-test-classes [javac] /srv/gump/public/workspace/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java:48: cannot find symbol [javac] symbol : method assertThat(javax.xml.transform.Source,org.hamcrest.Matcher<capture#65 of ? super javax.xml.transform.dom.DOMSource>) [javac] location: class net.sf.xmlunit.builder.InputTest [javac] assertThat(s, is(DOMSource.class)); [javac] ^ [javac] /srv/gump/public/workspace/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java:50: cannot find symbol [javac] symbol : method assertThat(java.lang.Object,org.hamcrest.Matcher<capture#736 of ? super org.w3c.dom.Document>) [javac] location: class net.sf.xmlunit.builder.InputTest [javac] assertThat(o, is(Document.class)); [javac] ^ [javac] /srv/gump/public/workspace/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java:116: cannot find symbol [javac] symbol : method assertThat(javax.xml.transform.Source,org.hamcrest.Matcher<capture#227 of ? super javax.xml.transform.dom.DOMSource>) [javac] location: class net.sf.xmlunit.builder.InputTest [javac] assertThat(s, is(DOMSource.class)); [javac] ^ [javac] /srv/gump/public/workspace/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java:118: cannot find symbol [javac] symbol : method assertThat(java.lang.Object,org.hamcrest.Matcher<capture#595 of ? super org.w3c.dom.Document>) [javac] location: class net.sf.xmlunit.builder.InputTest [javac] assertThat(o, is(Document.class)); [javac] ^ [javac] /srv/gump/public/workspace/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java:64: cannot find symbol [javac] symbol : method assertThat(java.lang.Exception,org.hamcrest.Matcher<capture#932 of ? super net.sf.xmlunit.exceptions.XMLUnitException>) [javac] location: class net.sf.xmlunit.validation.JAXPValidatorTest [javac] assertThat(e, is(XMLUnitException.class)); [javac] ^ [javac] /srv/gump/public/workspace/xmlunit/src/tests/java-core/net/sf/xmlunit/validation/JAXPValidatorTest.java:75: cannot find symbol [javac] symbol : method assertThat(java.lang.Exception,org.hamcrest.Matcher<capture#958 of ? super net.sf.xmlunit.exceptions.XMLUnitException>) [javac] location: class net.sf.xmlunit.validation.JAXPValidatorTest [javac] assertThat(e, is(XMLUnitException.class)); [javac] ^ [javac] 6 errors BUILD FAILED /srv/gump/public/workspace/xmlunit/build.xml:123: Compile failed; see the compiler error output for details. Total time: 2 seconds --------------------------------------------- To subscribe to this information via syndicated feeds: - RSS: http://vmgump.apache.org/gump/public/xmlunit/xmlunit/rss.xml - Atom: http://vmgump.apache.org/gump/public/xmlunit/xmlunit/atom.xml ============================== Gump Tracking Only === Produced by Gump version 2.3. Gump Run 11000004062009, vmgump:vmgump-public:11000004062009 Gump E-mail Identifier (unique within run) #5. -- Apache Gump http://gump.apache.org/ [Instance: vmgump] |