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...> - 2008-06-10 08:57:50
|
Revision: 269 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=269&view=rev Author: bodewig Date: 2008-06-10 01:57:47 -0700 (Tue, 10 Jun 2008) Log Message: ----------- spell check Modified Paths: -------------- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-06-06 14:16:39 UTC (rev 268) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-06-10 08:57:47 UTC (rev 269) @@ -69,7 +69,7 @@ element <literal><![CDATA[<foo>bar</foo>]]></literal>) and valid XML with incorrect content (e.g. element <literal><![CDATA[<foo>baz</foo>]]></literal>). What we really - wanted was an <literal>assertXMLEquals()</literal> method, so we + wanted was an <literal>assertXMLEqual()</literal> method, so we could compare the message that we expected the system to generate and the message that the system actually generated. And that was the beginning of XMLUnit.</para> @@ -135,7 +135,7 @@ should work with any JAXP compliant parser library, such as Xerces-J <footnote id="xerces-link"><para><ulink url="http://xerces.apache.org/">http://xerces.apache.org/</ulink></para></footnote> - from the Apache Software Foundation. To use the XSL and XPath + from the Apache Software Foundation. To use the XSLT and XPath features of XMLUnit a Trax (the XSLT portion of JAXP) compliant transformation engine is required, such as Xalan-J<footnote id="xalan-link"><para><ulink @@ -203,7 +203,7 @@ the control and test XML are either similar or identical. Obviously in this case the pieces of XML are different and the test will fail. The failure message indicates - both what the difference is and the Xpath locations of the nodes + both what the difference is and the XPath locations of the nodes that were being compared:</para> <programlisting><![CDATA[ @@ -217,7 +217,7 @@ class stores the result of an XML comparison and makes it available through the methods <literal>similar()</literal> and <literal>identical()</literal>. The - <literal>assertXMLEquals()</literal> method tests the value of + <literal>assertXMLEqual()</literal> method tests the value of <literal>Diff.similar()</literal> and the <literal>assertXMLIdentical()</literal> method tests the value of <literal>Diff.identical()</literal>.</para> @@ -383,7 +383,7 @@ <section id="Comparing XML Transformations"> <title>Comparing XML Transformations</title> - <para>XMLUnit can test XSL transformations at a high level using + <para>XMLUnit can test XSLT transformations at a high level using the <literal>Transform</literal> class that wraps an <literal>javax.xml.transform.Transformer</literal> instance. Knowing the input XML, input stylesheet and expected @@ -404,7 +404,7 @@ <para>The <literal>getResultString()</literal> and <literal>getResultDocument()</literal> methods of the <literal>Transform</literal> class can be used to access the - result of the XSL transformation programmatically if required, + result of the XSLT transformation programmatically if required, for example as below:</para> <example><title>Using <literal>Transform</literal> @@ -466,7 +466,7 @@ </section> - <section id="Xpath Tests"><title>Xpath Tests</title> + <section id="Xpath Tests"><title>XPath Tests</title> <para>One of the strengths of XML is the ability to programmatically extract specific parts of a document using @@ -474,7 +474,7 @@ offers a number of XPath related assertion methods, as demonstrated in this test:</para> - <example><title>Using Xpath Tests</title> + <example><title>Using XPath Tests</title> <programlisting language="Java"><![CDATA[ public void testXPaths() throws Exception { String mySolarSystemXML = "<solar-system>" @@ -493,10 +493,10 @@ <para>When an XPath expression is evaluated against a piece of XML a <literal>NodeList</literal> is created that contains the matching <literal>Node</literal>s. The methods in the previous - test <literal>assertXPathExists</literal>, - <literal>assertNotXPathExists</literal>, - <literal>assertXPathsEqual</literal>, and - <literal>assertXPathsNotEqual</literal> use these + test <literal>assertXpathExists</literal>, + <literal>assertXpathNotExists</literal>, + <literal>assertXpathsEqual</literal>, and + <literal>assertXpathsNotEqual</literal> use these <literal>NodeList</literal>s. However, the contents of a <literal>NodeList</literal> can be flattened (or <literal>String</literal>-ified) to a single value, and XMLUnit @@ -504,9 +504,9 @@ this test<footnote id="XpathEngine note"><para>Each of the <literal>assertXpath...()</literal> methods uses an implementation of the <literal>XpathEngine</literal> interface - to evaluate an Xpath expression.</para></footnote>:</para> + to evaluate an XPath expression.</para></footnote>:</para> - <example><title>Testing Xpath Values</title> + <example><title>Testing XPath Values</title> <programlisting language="Java"><![CDATA[ public void testXPathValues() throws Exception { String myJavaFlavours = "<java-flavours>" @@ -522,7 +522,7 @@ "//jvm[3]/@current", myJavaFlavours); }]]></programlisting></example> - <para>Xpaths are especially useful where a document is made up + <para>XPaths are especially useful where a document is made up largely of known, unchanging content with only a small amount of changing content created by the system. One of the main areas where constant "boilerplate" markup is combined with system @@ -558,7 +558,7 @@ wellFormedDocument); }]]></programlisting></example> - <para>One of the key points about using Xpaths with HTML content + <para>One of the key points about using XPaths with HTML content is that extracting values in tests requires the values to be identifiable. (This is just another way of saying that testing HTML is easier when it is written to be testable.) In the @@ -2104,7 +2104,7 @@ <para>The interface <literal>MatchTracker</literal> can be implemented to get notified on each and every successful match, - note that there may be a lot more comparisions going on than you + note that there may be a lot more comparisons going on than you might expect and that your callback gets notified a lot.</para> <example> @@ -2149,7 +2149,7 @@ receive any callbacks once the configured <literal>ComparisonController</literal> has decided that <literal>DifferenceEngine</literal> should halt the - comparision.</para> + comparison.</para> </section> @@ -2621,7 +2621,7 @@ package <ulink url="https://jaxp-sources.dev.java.net/nonav/docs/api/"><literal>javax.xml.validation</literal></ulink> designed for validations of snippets of XML against different schema languages. Any compliant implementation must support the - W3C XMl Schema language, but other languages + W3C XML Schema language, but other languages like <ulink url="http://www.relaxng.org/">RELAX NG</ulink> or <ulink url="http://www.schematron.com/">Schematron</ulink> may be supported as well.</para> @@ -2637,7 +2637,7 @@ Alternatively you can specify the schema factory itself.</para> <para>The schema definition itself can be given via - <literal>Source</literal> elements, just like the pices of XML + <literal>Source</literal> elements, just like the pieces of XML to validate are specified as <literal>Source</literal> as well.</para> @@ -2659,7 +2659,7 @@ example.</para> <example> - <title>Validating a XML Schema Defintion</title> + <title>Validating an XML Schema Definition</title> <programlisting language="Java"><![CDATA[ Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(myXmlSchemaFile))); @@ -2696,7 +2696,7 @@ throws XpathException; /** - * Evaluate the result of executing the specified xpath syntax + * Evaluate the result of executing the specified XPath syntax * <code>select</code> expression on the specified document * @param select * @param document @@ -3265,7 +3265,7 @@ <listitem> <para>When comparing two elements that differ on - attributes the comparision is now symmetric.</para> + attributes the comparison is now symmetric.</para> <para>In XMLUnit 1.0 if an attribute was present on the test but not the control element this wasn't flagged as a @@ -3277,7 +3277,7 @@ number of attributes or there are attributes in the control element that are missing in the test element - so the pieces of XML have been flagged as different before as - well. If you are using <literal>DetailiedDiff</literal> + well. If you are using <literal>DetailedDiff</literal> this change may lead to more detected <literal>Difference</literal>s, though.</para> </listitem> @@ -3494,7 +3494,7 @@ <listitem><literal>FloatingPointTolerantDifferenceListener</literal> a - <literal>DifferenceListener</literal> that tries - to parse texts as floting point numbers and compares + to parse texts as floating point numbers and compares them using a configurable tolerance.</listitem> </itemizedlist> </listitem> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-06-10 08:38:58
|
Bugs item #1985229, was opened at 2008-06-05 08:45 Message generated for change (Settings changed) made by kmatsuhashi You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&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.1 >Status: Open Resolution: Fixed Priority: 5 Private: No Submitted By: MATSUHASHI KAZUAKI (kmatsuhashi) Assigned to: Stefan Bodewig (bodewig) Summary: SimpleXpathEngine throws NPE for invalid xpath given Initial Comment: My environment: xmlunit-1.1, Windows 2000, JDK 1.5.0_7 with Xalan-j2.7.0, ant-1.7.0, junit3.8.1 <<What I noticed about xmlunit-1.1>> I modified the org.custommonkey.xmlunit.test_SimpleXpathEngine class: add a test method "testEvaluateInvalidXPath". ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open source])"; String result = newXpathEngine().evaluate(xpath, testDocument); } ------------------------------------------------------------------------------------- When I ran the junit, I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.032"> <error type="java.lang.NullPointerException">java.lang.NullPointerException at org.custommonkey.xmlunit.SimpleXpathEngine.performTransform(SimpleXpathEngine.java:136) at org.custommonkey.xmlunit.SimpleXpathEngine.evaluate(SimpleXpathEngine.java:202) at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPathWith(test_SimpleXpathEngine.java:85) </error> </testcase> ------------------------------------------------------------------------------------- The root cause was obvious: the XPath I gave was syntactically wrong. It had odd number of single quotation. It had to be 'open source' rather than 'open source. Also I noticed some lines of messages from the underlying XSLT processor (in my case, Xalan-j 2.7.0) were written into System.err. These messages were valuable. They told me what was the cause. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <system-err><![CDATA[SystemId は不明; 行 #1; 桁 #251; 引用符が誤っているリテラル... 単一引用符が必要でした! SystemId は不明; 行 #1; 桁 #251; ] が必要でしたが、source が見つかりました (エラーのロケーションは不明)java.lang.ClassCastException: org.apache.xpath.objects.XString ]]></system-err> ------------------------------------------------------------------------------------- <<Discussion>> Point.1: NullPointerException is terrible. Why I got a NullPointerException? The XMLunit document says the design idea is to throw org.custommonkey.xmlunit.exceptions.ConfiguratinException when a invalid XPath given rather than NPE. Point.2: Why the XSLT processor diagnostics goes to System.err? I want the message to be carried by the thrown ConfigurationException object rather than immediately swept away into System.err. Let me tell why. I've developed some custom Ant tasks (namely "AntUnit4XML") which drives the xmlunit's SimpleXpathEngine object under the AntUnit assertion mechanism. When I ran my assertion tasks, the messages from XSLT processor behind the SimpleXpathEngine vanished somehow (actually swept away into System.err of the forked process, which is invisible). I tried to figure out how to salvage the diagnostics but I couldn't. Eventually I misses the XSLT processor diagnostics. <<How I investigated>> I changed my testcase to make it more informative: ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open 'source'])"; try { String result = newXpathEngine().evaluate(xpath, testDocument); fail("expected Exception to be thrown but not"); } catch (NullPointerException npe) { String msg = "NullPointerException has been thrown." + ((npe.getMessage() != null) ? " with message \"" + npe.getMessage() + "\"" : ""); fail(msg); } catch (ConfigurationException ce) { String msg = ce.getClass().getName() + " has been thrown with message \"" + ce.getMessage() + "\""; //assertTrue(msg + "\", expected \"Error\" contained but not", // ce.getMessage().indexOf("Error")>=0); fail(msg); } catch (Exception e) { String msg = "unexpected " + e.getClass().getName() + ((e.getMessage() != null) ? " " + e.getMessage() : ""); fail(msg); } } ------------------------------------------------------------------------------------- Then I examined Saxon6.5.5 as alternative XSLT processor to see how it deals with my invalid XPath. I put the saxon.jar in the JRE/lib/endorsed dir, and slightly modified the build.xml' test target: ============================= build.xml ================================================= <target name="test" depends="compile" description="runs the tests"> <junit ... <sysproperty key="javax.xml.transform.TransformerFactory" value="com.icl.saxon.TransformerFactoryImpl"/> ... ----------------------------------------------------------------------------------------- When I run the test, I got the following report. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.25"> <failure message="expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...>" type="junit.framework.ComparisonFailure">junit.framework.ComparisonFailure: expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...> at org.custommonkey.xmlunit.test_SimpleXpathEngine.testGetXPathResultNode(test_SimpleXpathEngine.java:60) </failure> </testcase> ... <system-out><![CDATA[[testEvaluateInvalidXPath] org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown. message="Failed to compile stylesheet. 1 error detected." ]]></system-out> <system-err><![CDATA[Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Error in expression count(test//*[@attrOne='open source]): expected "]", found "<name>" ]]></system-err> ------------------------------------------------------------------------------------- Saxon did not throw NPE. Saxon threw TransformerConfigurationException, which was caught by try ... catch ... block in the test method, and wrapped by SimpleXpathEngine into a ConfigurationException. Goodness. This is the way we want it work. This examination proved that it was Xalan who actually threw the NPE. Then my next question I got was how can I make Xalan not to throw NPE? .. well, let me tell about it later. I wanted the ConfigurationException contain the diagnostics from SAXON rather than System.err. Why the diagnostics goes to System.err? I checked the source code of SimpleXpathEngine#performTransform() and found no javax.xml.transform.ErrorListener is set to the TrasnformerFactory. If no ErrorListener is provided, the TransformerFactory will print the messages into System.err. This portion can be improved. I added a SimpleErrorListener class and changed the performTransform() method as follows: ============== org.custommonkey.xmlunit.SimpleXpathEngine =========================== private void performTransform(String xslt, Document document, Result result) throws TransformerException, ConfigurationException { StringWriter sw = new StringWriter(); ErrorListener errorListener = new SimpleErrorListener(new PrintWriter(sw)); try { StreamSource source = new StreamSource(new StringReader(xslt)); TransformerFactory trf = XMLUnit.getTransformerFactory(); trf.setErrorListener(errorListener); Transformer tr = trf.newTransformer(source); tr.setErrorListener(errorListener); tr.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(sw.toString()); } } ------------------------------------------------------------------------------------- With this code change applied, the testcase gave me following report ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.0"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- OK, now the message is wrapped in the ConfigurationException. This is the way things should be. With the changes to performTransform() applied, I tried Xalan to see if the NPE still be raised. This time I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.046"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- Now Xalan ceased throwing NPE. Fine. It seems that setting a ErrorListener object explicitly to the TransformerFactory fixed the NPE problem of Xalan. The message produced by Xalan tends to be verbose, uselessly repeating a single sentence twice or three times. I wanted to make it concise but could not find how to. <<Summary of changes I propose>> - modify src/java/org.custommonkey.xmlunit.SimpleXpathEngine - add src/java/org.custommonkey.xmlunit.SimpleErrorListener - add src/java/org.custommonkey.xmlunit.SAXSourceLocator - modify tests/java/org.custommonkey.xmlunit.test_SimpleXpathEngine - add tests/java/org.custommonkey.xmlunit.test_SimpleErrorListener ---------------------------------------------------------------------- >Comment By: MATSUHASHI KAZUAKI (kmatsuhashi) Date: 2008-06-10 08:38 Message: Logged In: YES user_id=823604 Originator: YES Stefan, Thank you for looking at the issue. I totally agree with your idea. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-06-06 14:23 Message: Logged In: YES user_id=113148 Originator: NO I've introduced an easier mechanism which on Java 1.4 produces org.custommonkey.xmlunit.exceptions.ConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Literalwert mit falschen Anführungszeichen... einfache Anführungszeichen erwartet! for me (the German text means "literal with wrong quotes, single quotes expected") which I think should be good enough. JDK 1.6 produces a generic "couldn't compile stylesheet warning" here, but JAXP13XpathEngine gives the same exception message as 1.4 in the second exception nested into the resulting XpathException. I'd leave it at that, feel free to reopen the issue if you feel trunk could be improved further. http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=268 ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-06-06 14:02 Message: Logged In: YES user_id=113148 Originator: NO personally I'd rather expect an XpathException than a ConfigurationException. I've written and committed a testcase based on yours which only expects either an XpathException or a ConfigurationException and it passes on stock JDK 1.4.2, JDK 1.5 and JDK 1.6, so it really only seems to be Xalan 2.7.0 - you might think about upgrading Xalan 2.7.1. The NPE seems to be coming from XMLUnit and occurs because your version of Xalan returns null for TransformerFactory.newTransformer which is evil. I'll add an explicit null guard. While I agree that having better diagnostics here would be nice, I'm more than a bit wary of adding three classes to get at it - in particular since this is more of an implementation specific problem with an obsolete version of Xalan. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-06-05 11:16 Message: Logged In: YES user_id=113148 Originator: NO many thanks for the very thorough analysis, I'll look into your patch later today. For your project you'd probably better use XMLUnit.newXpathEngine which is supposed to provide you with a JAXP 1.3 XPath engine in your setup. In my experience there are too many problems with broken XSLT processors when using SimpleXpathEngine. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&group_id=23187 |
From: SourceForge.net <no...@so...> - 2008-06-06 14:23:45
|
Bugs item #1985229, was opened at 2008-06-05 10:45 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&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.1 >Status: Pending >Resolution: Fixed Priority: 5 Private: No Submitted By: MATSUHASHI KAZUAKI (kmatsuhashi) Assigned to: Stefan Bodewig (bodewig) Summary: SimpleXpathEngine throws NPE for invalid xpath given Initial Comment: My environment: xmlunit-1.1, Windows 2000, JDK 1.5.0_7 with Xalan-j2.7.0, ant-1.7.0, junit3.8.1 <<What I noticed about xmlunit-1.1>> I modified the org.custommonkey.xmlunit.test_SimpleXpathEngine class: add a test method "testEvaluateInvalidXPath". ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open source])"; String result = newXpathEngine().evaluate(xpath, testDocument); } ------------------------------------------------------------------------------------- When I ran the junit, I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.032"> <error type="java.lang.NullPointerException">java.lang.NullPointerException at org.custommonkey.xmlunit.SimpleXpathEngine.performTransform(SimpleXpathEngine.java:136) at org.custommonkey.xmlunit.SimpleXpathEngine.evaluate(SimpleXpathEngine.java:202) at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPathWith(test_SimpleXpathEngine.java:85) </error> </testcase> ------------------------------------------------------------------------------------- The root cause was obvious: the XPath I gave was syntactically wrong. It had odd number of single quotation. It had to be 'open source' rather than 'open source. Also I noticed some lines of messages from the underlying XSLT processor (in my case, Xalan-j 2.7.0) were written into System.err. These messages were valuable. They told me what was the cause. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <system-err><![CDATA[SystemId は不明; 行 #1; 桁 #251; 引用符が誤っているリテラル... 単一引用符が必要でした! SystemId は不明; 行 #1; 桁 #251; ] が必要でしたが、source が見つかりました (エラーのロケーションは不明)java.lang.ClassCastException: org.apache.xpath.objects.XString ]]></system-err> ------------------------------------------------------------------------------------- <<Discussion>> Point.1: NullPointerException is terrible. Why I got a NullPointerException? The XMLunit document says the design idea is to throw org.custommonkey.xmlunit.exceptions.ConfiguratinException when a invalid XPath given rather than NPE. Point.2: Why the XSLT processor diagnostics goes to System.err? I want the message to be carried by the thrown ConfigurationException object rather than immediately swept away into System.err. Let me tell why. I've developed some custom Ant tasks (namely "AntUnit4XML") which drives the xmlunit's SimpleXpathEngine object under the AntUnit assertion mechanism. When I ran my assertion tasks, the messages from XSLT processor behind the SimpleXpathEngine vanished somehow (actually swept away into System.err of the forked process, which is invisible). I tried to figure out how to salvage the diagnostics but I couldn't. Eventually I misses the XSLT processor diagnostics. <<How I investigated>> I changed my testcase to make it more informative: ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open 'source'])"; try { String result = newXpathEngine().evaluate(xpath, testDocument); fail("expected Exception to be thrown but not"); } catch (NullPointerException npe) { String msg = "NullPointerException has been thrown." + ((npe.getMessage() != null) ? " with message \"" + npe.getMessage() + "\"" : ""); fail(msg); } catch (ConfigurationException ce) { String msg = ce.getClass().getName() + " has been thrown with message \"" + ce.getMessage() + "\""; //assertTrue(msg + "\", expected \"Error\" contained but not", // ce.getMessage().indexOf("Error")>=0); fail(msg); } catch (Exception e) { String msg = "unexpected " + e.getClass().getName() + ((e.getMessage() != null) ? " " + e.getMessage() : ""); fail(msg); } } ------------------------------------------------------------------------------------- Then I examined Saxon6.5.5 as alternative XSLT processor to see how it deals with my invalid XPath. I put the saxon.jar in the JRE/lib/endorsed dir, and slightly modified the build.xml' test target: ============================= build.xml ================================================= <target name="test" depends="compile" description="runs the tests"> <junit ... <sysproperty key="javax.xml.transform.TransformerFactory" value="com.icl.saxon.TransformerFactoryImpl"/> ... ----------------------------------------------------------------------------------------- When I run the test, I got the following report. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.25"> <failure message="expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...>" type="junit.framework.ComparisonFailure">junit.framework.ComparisonFailure: expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...> at org.custommonkey.xmlunit.test_SimpleXpathEngine.testGetXPathResultNode(test_SimpleXpathEngine.java:60) </failure> </testcase> ... <system-out><![CDATA[[testEvaluateInvalidXPath] org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown. message="Failed to compile stylesheet. 1 error detected." ]]></system-out> <system-err><![CDATA[Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Error in expression count(test//*[@attrOne='open source]): expected "]", found "<name>" ]]></system-err> ------------------------------------------------------------------------------------- Saxon did not throw NPE. Saxon threw TransformerConfigurationException, which was caught by try ... catch ... block in the test method, and wrapped by SimpleXpathEngine into a ConfigurationException. Goodness. This is the way we want it work. This examination proved that it was Xalan who actually threw the NPE. Then my next question I got was how can I make Xalan not to throw NPE? .. well, let me tell about it later. I wanted the ConfigurationException contain the diagnostics from SAXON rather than System.err. Why the diagnostics goes to System.err? I checked the source code of SimpleXpathEngine#performTransform() and found no javax.xml.transform.ErrorListener is set to the TrasnformerFactory. If no ErrorListener is provided, the TransformerFactory will print the messages into System.err. This portion can be improved. I added a SimpleErrorListener class and changed the performTransform() method as follows: ============== org.custommonkey.xmlunit.SimpleXpathEngine =========================== private void performTransform(String xslt, Document document, Result result) throws TransformerException, ConfigurationException { StringWriter sw = new StringWriter(); ErrorListener errorListener = new SimpleErrorListener(new PrintWriter(sw)); try { StreamSource source = new StreamSource(new StringReader(xslt)); TransformerFactory trf = XMLUnit.getTransformerFactory(); trf.setErrorListener(errorListener); Transformer tr = trf.newTransformer(source); tr.setErrorListener(errorListener); tr.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(sw.toString()); } } ------------------------------------------------------------------------------------- With this code change applied, the testcase gave me following report ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.0"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- OK, now the message is wrapped in the ConfigurationException. This is the way things should be. With the changes to performTransform() applied, I tried Xalan to see if the NPE still be raised. This time I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.046"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- Now Xalan ceased throwing NPE. Fine. It seems that setting a ErrorListener object explicitly to the TransformerFactory fixed the NPE problem of Xalan. The message produced by Xalan tends to be verbose, uselessly repeating a single sentence twice or three times. I wanted to make it concise but could not find how to. <<Summary of changes I propose>> - modify src/java/org.custommonkey.xmlunit.SimpleXpathEngine - add src/java/org.custommonkey.xmlunit.SimpleErrorListener - add src/java/org.custommonkey.xmlunit.SAXSourceLocator - modify tests/java/org.custommonkey.xmlunit.test_SimpleXpathEngine - add tests/java/org.custommonkey.xmlunit.test_SimpleErrorListener ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-06-06 16:23 Message: Logged In: YES user_id=113148 Originator: NO I've introduced an easier mechanism which on Java 1.4 produces org.custommonkey.xmlunit.exceptions.ConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Literalwert mit falschen Anführungszeichen... einfache Anführungszeichen erwartet! for me (the German text means "literal with wrong quotes, single quotes expected") which I think should be good enough. JDK 1.6 produces a generic "couldn't compile stylesheet warning" here, but JAXP13XpathEngine gives the same exception message as 1.4 in the second exception nested into the resulting XpathException. I'd leave it at that, feel free to reopen the issue if you feel trunk could be improved further. http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=268 ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-06-06 16:02 Message: Logged In: YES user_id=113148 Originator: NO personally I'd rather expect an XpathException than a ConfigurationException. I've written and committed a testcase based on yours which only expects either an XpathException or a ConfigurationException and it passes on stock JDK 1.4.2, JDK 1.5 and JDK 1.6, so it really only seems to be Xalan 2.7.0 - you might think about upgrading Xalan 2.7.1. The NPE seems to be coming from XMLUnit and occurs because your version of Xalan returns null for TransformerFactory.newTransformer which is evil. I'll add an explicit null guard. While I agree that having better diagnostics here would be nice, I'm more than a bit wary of adding three classes to get at it - in particular since this is more of an implementation specific problem with an obsolete version of Xalan. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-06-05 13:16 Message: Logged In: YES user_id=113148 Originator: NO many thanks for the very thorough analysis, I'll look into your patch later today. For your project you'd probably better use XMLUnit.newXpathEngine which is supposed to provide you with a JAXP 1.3 XPath engine in your setup. In my experience there are too many problems with broken XSLT processors when using SimpleXpathEngine. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&group_id=23187 |
From: <bo...@us...> - 2008-06-06 14:16:30
|
Revision: 268 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=268&view=rev Author: bodewig Date: 2008-06-06 07:16:39 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Try to get more information about the error if the XPath expression is invalid, Issue 1985229 Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 14:00:14 UTC (rev 267) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 14:16:39 UTC (rev 268) @@ -42,9 +42,11 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.Iterator; -import javax.xml.transform.Result; +import javax.xml.transform.ErrorListener; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.Result; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -132,14 +134,31 @@ throws TransformerException, ConfigurationException, XpathException { try { StreamSource source = new StreamSource(new StringReader(xslt)); - Transformer transformer = - XMLUnit.getTransformerFactory().newTransformer(source); + TransformerFactory tf = XMLUnit.newTransformerFactory(); + ErrorListener el = new ErrorListener() { + public void error(TransformerException ex) + throws TransformerException { + // any error in our simple stylesheet must be fatal + throw ex; + } + public void fatalError(TransformerException ex) + throws TransformerException { + throw ex; + } + public void warning(TransformerException ex) { + // there shouldn't be any warning + ex.printStackTrace(); + } + }; + tf.setErrorListener(el); + Transformer transformer = tf.newTransformer(source); // Issue 1985229 says Xalan-J 2.7.0 may return null for // illegal input if (transformer == null) { throw new XpathException("failed to obtain an XSLT transformer" + " for XPath expression."); } + transformer.setErrorListener(el); transformer.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-06-06 14:00:14 UTC (rev 267) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-06-06 14:16:39 UTC (rev 268) @@ -402,15 +402,25 @@ */ public static TransformerFactory getTransformerFactory() { if (transformerFactory == null) { - transformerFactory = TransformerFactory.newInstance(); - if (uriResolver != null) { - transformerFactory.setURIResolver(uriResolver); - } + transformerFactory = newTransformerFactory(); } return transformerFactory; } /** + * Get a fresh transformer to use for XSLT transformations (and by + * implication serialization and XPaths). + * @return a new instance of the default transformer factory + */ + static TransformerFactory newTransformerFactory() { + TransformerFactory tf = TransformerFactory.newInstance(); + if (uriResolver != null) { + tf.setURIResolver(uriResolver); + } + return tf; + } + + /** * Sets the URIResolver to use during transformations. */ public static void setURIResolver(URIResolver resolver) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-06-06 14:02:05
|
Bugs item #1985229, was opened at 2008-06-05 10:45 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&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.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: MATSUHASHI KAZUAKI (kmatsuhashi) Assigned to: Stefan Bodewig (bodewig) Summary: SimpleXpathEngine throws NPE for invalid xpath given Initial Comment: My environment: xmlunit-1.1, Windows 2000, JDK 1.5.0_7 with Xalan-j2.7.0, ant-1.7.0, junit3.8.1 <<What I noticed about xmlunit-1.1>> I modified the org.custommonkey.xmlunit.test_SimpleXpathEngine class: add a test method "testEvaluateInvalidXPath". ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open source])"; String result = newXpathEngine().evaluate(xpath, testDocument); } ------------------------------------------------------------------------------------- When I ran the junit, I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.032"> <error type="java.lang.NullPointerException">java.lang.NullPointerException at org.custommonkey.xmlunit.SimpleXpathEngine.performTransform(SimpleXpathEngine.java:136) at org.custommonkey.xmlunit.SimpleXpathEngine.evaluate(SimpleXpathEngine.java:202) at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPathWith(test_SimpleXpathEngine.java:85) </error> </testcase> ------------------------------------------------------------------------------------- The root cause was obvious: the XPath I gave was syntactically wrong. It had odd number of single quotation. It had to be 'open source' rather than 'open source. Also I noticed some lines of messages from the underlying XSLT processor (in my case, Xalan-j 2.7.0) were written into System.err. These messages were valuable. They told me what was the cause. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <system-err><![CDATA[SystemId は不明; 行 #1; 桁 #251; 引用符が誤っているリテラル... 単一引用符が必要でした! SystemId は不明; 行 #1; 桁 #251; ] が必要でしたが、source が見つかりました (エラーのロケーションは不明)java.lang.ClassCastException: org.apache.xpath.objects.XString ]]></system-err> ------------------------------------------------------------------------------------- <<Discussion>> Point.1: NullPointerException is terrible. Why I got a NullPointerException? The XMLunit document says the design idea is to throw org.custommonkey.xmlunit.exceptions.ConfiguratinException when a invalid XPath given rather than NPE. Point.2: Why the XSLT processor diagnostics goes to System.err? I want the message to be carried by the thrown ConfigurationException object rather than immediately swept away into System.err. Let me tell why. I've developed some custom Ant tasks (namely "AntUnit4XML") which drives the xmlunit's SimpleXpathEngine object under the AntUnit assertion mechanism. When I ran my assertion tasks, the messages from XSLT processor behind the SimpleXpathEngine vanished somehow (actually swept away into System.err of the forked process, which is invisible). I tried to figure out how to salvage the diagnostics but I couldn't. Eventually I misses the XSLT processor diagnostics. <<How I investigated>> I changed my testcase to make it more informative: ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open 'source'])"; try { String result = newXpathEngine().evaluate(xpath, testDocument); fail("expected Exception to be thrown but not"); } catch (NullPointerException npe) { String msg = "NullPointerException has been thrown." + ((npe.getMessage() != null) ? " with message \"" + npe.getMessage() + "\"" : ""); fail(msg); } catch (ConfigurationException ce) { String msg = ce.getClass().getName() + " has been thrown with message \"" + ce.getMessage() + "\""; //assertTrue(msg + "\", expected \"Error\" contained but not", // ce.getMessage().indexOf("Error")>=0); fail(msg); } catch (Exception e) { String msg = "unexpected " + e.getClass().getName() + ((e.getMessage() != null) ? " " + e.getMessage() : ""); fail(msg); } } ------------------------------------------------------------------------------------- Then I examined Saxon6.5.5 as alternative XSLT processor to see how it deals with my invalid XPath. I put the saxon.jar in the JRE/lib/endorsed dir, and slightly modified the build.xml' test target: ============================= build.xml ================================================= <target name="test" depends="compile" description="runs the tests"> <junit ... <sysproperty key="javax.xml.transform.TransformerFactory" value="com.icl.saxon.TransformerFactoryImpl"/> ... ----------------------------------------------------------------------------------------- When I run the test, I got the following report. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.25"> <failure message="expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...>" type="junit.framework.ComparisonFailure">junit.framework.ComparisonFailure: expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...> at org.custommonkey.xmlunit.test_SimpleXpathEngine.testGetXPathResultNode(test_SimpleXpathEngine.java:60) </failure> </testcase> ... <system-out><![CDATA[[testEvaluateInvalidXPath] org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown. message="Failed to compile stylesheet. 1 error detected." ]]></system-out> <system-err><![CDATA[Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Error in expression count(test//*[@attrOne='open source]): expected "]", found "<name>" ]]></system-err> ------------------------------------------------------------------------------------- Saxon did not throw NPE. Saxon threw TransformerConfigurationException, which was caught by try ... catch ... block in the test method, and wrapped by SimpleXpathEngine into a ConfigurationException. Goodness. This is the way we want it work. This examination proved that it was Xalan who actually threw the NPE. Then my next question I got was how can I make Xalan not to throw NPE? .. well, let me tell about it later. I wanted the ConfigurationException contain the diagnostics from SAXON rather than System.err. Why the diagnostics goes to System.err? I checked the source code of SimpleXpathEngine#performTransform() and found no javax.xml.transform.ErrorListener is set to the TrasnformerFactory. If no ErrorListener is provided, the TransformerFactory will print the messages into System.err. This portion can be improved. I added a SimpleErrorListener class and changed the performTransform() method as follows: ============== org.custommonkey.xmlunit.SimpleXpathEngine =========================== private void performTransform(String xslt, Document document, Result result) throws TransformerException, ConfigurationException { StringWriter sw = new StringWriter(); ErrorListener errorListener = new SimpleErrorListener(new PrintWriter(sw)); try { StreamSource source = new StreamSource(new StringReader(xslt)); TransformerFactory trf = XMLUnit.getTransformerFactory(); trf.setErrorListener(errorListener); Transformer tr = trf.newTransformer(source); tr.setErrorListener(errorListener); tr.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(sw.toString()); } } ------------------------------------------------------------------------------------- With this code change applied, the testcase gave me following report ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.0"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- OK, now the message is wrapped in the ConfigurationException. This is the way things should be. With the changes to performTransform() applied, I tried Xalan to see if the NPE still be raised. This time I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.046"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- Now Xalan ceased throwing NPE. Fine. It seems that setting a ErrorListener object explicitly to the TransformerFactory fixed the NPE problem of Xalan. The message produced by Xalan tends to be verbose, uselessly repeating a single sentence twice or three times. I wanted to make it concise but could not find how to. <<Summary of changes I propose>> - modify src/java/org.custommonkey.xmlunit.SimpleXpathEngine - add src/java/org.custommonkey.xmlunit.SimpleErrorListener - add src/java/org.custommonkey.xmlunit.SAXSourceLocator - modify tests/java/org.custommonkey.xmlunit.test_SimpleXpathEngine - add tests/java/org.custommonkey.xmlunit.test_SimpleErrorListener ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-06-06 16:02 Message: Logged In: YES user_id=113148 Originator: NO personally I'd rather expect an XpathException than a ConfigurationException. I've written and committed a testcase based on yours which only expects either an XpathException or a ConfigurationException and it passes on stock JDK 1.4.2, JDK 1.5 and JDK 1.6, so it really only seems to be Xalan 2.7.0 - you might think about upgrading Xalan 2.7.1. The NPE seems to be coming from XMLUnit and occurs because your version of Xalan returns null for TransformerFactory.newTransformer which is evil. I'll add an explicit null guard. While I agree that having better diagnostics here would be nice, I'm more than a bit wary of adding three classes to get at it - in particular since this is more of an implementation specific problem with an obsolete version of Xalan. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-06-05 13:16 Message: Logged In: YES user_id=113148 Originator: NO many thanks for the very thorough analysis, I'll look into your patch later today. For your project you'd probably better use XMLUnit.newXpathEngine which is supposed to provide you with a JAXP 1.3 XPath engine in your setup. In my experience there are too many problems with broken XSLT processors when using SimpleXpathEngine. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&group_id=23187 |
From: <bo...@us...> - 2008-06-06 14:00:07
|
Revision: 267 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=267&view=rev Author: bodewig Date: 2008-06-06 07:00:14 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Add an explicit null guard for issue 1985229 Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 13:45:43 UTC (rev 266) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 14:00:14 UTC (rev 267) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -123,16 +123,23 @@ * @param xslt * @param document * @param result + * @throws XpathException * @throws TransformerException * @throws ConfigurationException */ private void performTransform(String xslt, Document document, Result result) - throws TransformerException, ConfigurationException { + throws TransformerException, ConfigurationException, XpathException { try { StreamSource source = new StreamSource(new StringReader(xslt)); Transformer transformer = XMLUnit.getTransformerFactory().newTransformer(source); + // Issue 1985229 says Xalan-J 2.7.0 may return null for + // illegal input + if (transformer == null) { + throw new XpathException("failed to obtain an XSLT transformer" + + " for XPath expression."); + } transformer.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(ex); @@ -149,7 +156,7 @@ * @return the root node of the Document created by the copy-of transform. */ protected Node getXPathResultNode(String select, Document document) - throws ConfigurationException, TransformerException { + throws ConfigurationException, TransformerException, XpathException { return getXPathResultAsDocument(select, document).getDocumentElement(); } @@ -164,7 +171,7 @@ */ protected Document getXPathResultAsDocument(String select, Document document) - throws ConfigurationException, TransformerException { + throws ConfigurationException, TransformerException, XpathException { DOMResult result = new DOMResult(); performTransform(getCopyTransformation(select), document, result); return (Document) result.getNode(); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2008-06-06 13:45:43 UTC (rev 266) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2008-06-06 14:00:14 UTC (rev 267) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2006-2007, Jeff Martin, Tim Bacon +Copyright (c) 2006-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -57,6 +57,16 @@ * @param message the detail message * @param cause the root cause of the exception */ + public XpathException(String message) { + this(message, null); + } + + /** + * Inititializes the exeption. + * + * @param message the detail message + * @param cause the root cause of the exception + */ public XpathException(String message, Throwable t) { super(message, t); } Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-06-06 13:45:43 UTC (rev 266) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-06-06 14:00:14 UTC (rev 267) @@ -3429,6 +3429,13 @@ presence of CDATA sections. <ulink href="https://sourceforge.net/tracker/index.php?func=detail&aid=1903923&group_id=23187&atid=377768">Issue 1903923</ulink>.</listitem> + + <listitem> + Two protected methods + in <literal>SimpleXPathEngine</literal> (which you + shouldn't extend anyway) have added XpathException to + their throws list. + </listitem> </itemizedlist> </section> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-06-06 13:46:06
|
Revision: 266 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=266&view=rev Author: bodewig Date: 2008-06-06 06:45:43 -0700 (Fri, 06 Jun 2008) Log Message: ----------- test for issue 1985229 Modified Paths: -------------- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java 2008-06-06 13:07:18 UTC (rev 265) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java 2008-06-06 13:45:43 UTC (rev 266) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2007, Jeff Martin, Tim Bacon +Copyright (c) 2007-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,6 +38,8 @@ import java.util.HashMap; import junit.framework.TestCase; +import org.custommonkey.xmlunit.exceptions.ConfigurationException; +import org.custommonkey.xmlunit.exceptions.XpathException; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -179,4 +181,15 @@ } + public void testEvaluateInvalidXPath() throws Exception { + String xpath = "count(test//*[@attrOne='open source])"; + try { + String result = newXpathEngine().evaluate(xpath, testDocument); + fail("expected Exception to be thrown but wasn't"); + } catch (XpathException ex) { + // expected + } catch (ConfigurationException ex) { + // acceptable in the JAXP 1.2 case + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-06-06 13:07:16
|
Revision: 265 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=265&view=rev Author: bodewig Date: 2008-06-06 06:07:18 -0700 (Fri, 06 Jun 2008) Log Message: ----------- allow command line control over forking/not-forking of <junit> Modified Paths: -------------- trunk/xmlunit/build.xml Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2008-06-06 12:49:58 UTC (rev 264) +++ trunk/xmlunit/build.xml 2008-06-06 13:07:18 UTC (rev 265) @@ -57,6 +57,9 @@ <property name="javac.target" value="1.3"/> <property name="javac.debug" value="true"/> + <!-- junit task properties --> + <property name="junit.fork" value="yes"/> + <!-- some library paths --> <!-- where is JAXP? property name="${xmlxsl.lib}" location="."/ --> <!-- where is JUnit? property name="${junit.lib}" location="."/ --> @@ -126,7 +129,7 @@ <target name="test" depends="compile" description="runs the tests"> - <junit printsummary="yes" haltonfailure="no" fork="yes" + <junit printsummary="yes" haltonfailure="no" fork="${junit.fork}" forkMode="perBatch" failureproperty="tests.failed"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="user.dir" value="${basedir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-06-06 12:49:56
|
Revision: 264 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=264&view=rev Author: bodewig Date: 2008-06-06 05:49:58 -0700 (Fri, 06 Jun 2008) Log Message: ----------- fix linefeeds and remove executable properties Modified Paths: -------------- trunk/xmlunit/docbook.xml trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NamespaceContext.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTestException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTester.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleNamespaceContext.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CountingNodeTester.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/ConfigurationException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java trunk/xmlunit/src/java/overview.html trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ComparingPiecesOfXML.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/DOMTreeWalking.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ValidatingXMLDocuments.java trunk/xmlunit/tests/etc/controlNamespaces.xml trunk/xmlunit/tests/etc/test.blame.html trunk/xmlunit/tests/etc/testNamespaces.xml trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_XMLUnitNamespaceContext2Jaxp13.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_AbstractNodeTester.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ForumMessage4406472.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java Property Changed: ---------------- trunk/xmlunit/docbook.xml trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ATourOfXMLUnit.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ComparingPiecesOfXML.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/DOMTreeWalking.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ValidatingXMLDocuments.java trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/XPathTests.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeInputStream.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ForumMessage4406472.java Modified: trunk/xmlunit/docbook.xml =================================================================== --- trunk/xmlunit/docbook.xml 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/docbook.xml 2008-06-06 12:49:58 UTC (rev 264) @@ -81,4 +81,4 @@ <move file="${src.userguide.dir}/${user.guide}.pdf" todir="${userguide.docs.dir}"/> </target> -</project> \ No newline at end of file +</project> Property changes on: trunk/xmlunit/docbook.xml ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java 2008-06-06 12:49:58 UTC (rev 264) @@ -51,4 +51,4 @@ public CountingNodeTester(int expectedNumNodes) { super(expectedNumNodes); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java 2008-06-06 12:49:58 UTC (rev 264) @@ -184,4 +184,4 @@ NodeDescriptor.appendNodeDetail(buf, testNodeDetail); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java 2008-06-06 12:49:58 UTC (rev 264) @@ -207,4 +207,4 @@ new Difference(NO_NAMESPACE_SCHEMA_LOCATION_ID, "xsi:noNamespaceSchemaLocation attribute", true); -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2008-06-06 12:49:58 UTC (rev 264) @@ -910,4 +910,4 @@ */ private static final DifferenceFoundException flowControlException = new DifferenceFoundException(); -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java 2008-06-06 12:49:58 UTC (rev 264) @@ -88,4 +88,4 @@ */ void skippedComparison(Node control, Node test); -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java 2008-06-06 12:49:58 UTC (rev 264) @@ -104,4 +104,4 @@ public void close() throws IOException { wrappedStream.close(); } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeInputStream.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java 2008-06-06 12:49:58 UTC (rev 264) @@ -263,4 +263,4 @@ } } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java 2008-06-06 12:49:58 UTC (rev 264) @@ -50,4 +50,4 @@ * been compared */ void matchFound(Difference difference); -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/NamespaceContext.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/NamespaceContext.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/NamespaceContext.java 2008-06-06 12:49:58 UTC (rev 264) @@ -60,4 +60,4 @@ * Get all prefixes of this context. */ Iterator getPrefixes(); -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java 2008-06-06 12:49:58 UTC (rev 264) @@ -132,4 +132,4 @@ private int reallyAvailable() { return nodeContentBytes.size() - atPos; } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTestException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTestException.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTestException.java 2008-06-06 12:49:58 UTC (rev 264) @@ -89,4 +89,4 @@ } return stringBuffer.toString(); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTester.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTester.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTester.java 2008-06-06 12:49:58 UTC (rev 264) @@ -62,4 +62,4 @@ * @exception NodeTestException if this instance was expecting more nodes */ void noMoreNodes(NodeTest forTest) throws NodeTestException ; -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleNamespaceContext.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleNamespaceContext.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleNamespaceContext.java 2008-06-06 12:49:58 UTC (rev 264) @@ -74,4 +74,4 @@ public Iterator getPrefixes() { return prefixMap.keySet().iterator(); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2008-06-06 12:49:58 UTC (rev 264) @@ -241,4 +241,4 @@ } return nsDecls.toString(); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java 2008-06-06 12:49:58 UTC (rev 264) @@ -71,4 +71,4 @@ * Establish a namespace context. */ void setNamespaceContext(NamespaceContext ctx); -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java 2008-06-06 12:49:58 UTC (rev 264) @@ -63,4 +63,4 @@ // some string is null, delegate return super.textualDifference(d); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CountingNodeTester.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CountingNodeTester.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CountingNodeTester.java 2008-06-06 12:49:58 UTC (rev 264) @@ -88,4 +88,4 @@ public void resetCounter() { actualNumNodes = 0; } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2008-06-06 12:49:58 UTC (rev 264) @@ -70,4 +70,4 @@ // no numbers or null, delegate return super.textualDifference(d); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java 2008-06-06 12:49:58 UTC (rev 264) @@ -195,4 +195,4 @@ } return count; } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java 2008-06-06 12:49:58 UTC (rev 264) @@ -121,4 +121,4 @@ delegateTo.skippedComparison(control, test); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/ConfigurationException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/ConfigurationException.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/ConfigurationException.java 2008-06-06 12:49:58 UTC (rev 264) @@ -47,4 +47,4 @@ public ConfigurationException(String s) { super(s, null); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java 2008-06-06 12:49:58 UTC (rev 264) @@ -61,4 +61,4 @@ return cause; } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java 2008-06-06 12:49:58 UTC (rev 264) @@ -70,4 +70,4 @@ return cause; } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2008-06-06 12:49:58 UTC (rev 264) @@ -60,4 +60,4 @@ public XpathException(String message, Throwable t) { super(message, t); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2008-06-06 12:49:58 UTC (rev 264) @@ -112,4 +112,4 @@ public void setNamespaceContext(NamespaceContext ctx) { xpath.setNamespaceContext(new XMLUnitNamespaceContext2Jaxp13(ctx)); } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-06-06 12:49:58 UTC (rev 264) @@ -222,4 +222,4 @@ l.add(e); } } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/util/IntegerBuffer.java 2008-06-06 12:49:58 UTC (rev 264) @@ -143,4 +143,4 @@ System.arraycopy(buffer, 0, i, 0, buffer.length); buffer = i; } -} \ No newline at end of file +} Modified: trunk/xmlunit/src/java/overview.html =================================================================== --- trunk/xmlunit/src/java/overview.html 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/java/overview.html 2008-06-06 12:49:58 UTC (rev 264) @@ -106,4 +106,4 @@ grew out of that. We hope you find it useful, and welcome any feedback you can give us.</p> </body> -</html> \ No newline at end of file +</html> Property changes on: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ATourOfXMLUnit.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ComparingPiecesOfXML.java =================================================================== --- trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ComparingPiecesOfXML.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ComparingPiecesOfXML.java 2008-06-06 12:49:58 UTC (rev 264) @@ -126,4 +126,4 @@ d.similar()); assertXMLEqual("expected pieces to be similar", CONTROL, TEST); } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ComparingPiecesOfXML.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/DOMTreeWalking.java =================================================================== --- trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/DOMTreeWalking.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/DOMTreeWalking.java 2008-06-06 12:49:58 UTC (rev 264) @@ -73,4 +73,4 @@ public void noMoreNodes(NodeTest test) {} } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/DOMTreeWalking.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ValidatingXMLDocuments.java =================================================================== --- trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ValidatingXMLDocuments.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ValidatingXMLDocuments.java 2008-06-06 12:49:58 UTC (rev 264) @@ -93,4 +93,4 @@ return null; } } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/ValidatingXMLDocuments.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/xmlunit/src/user-guide/org/custommonkey/xmlunit/examples/XPathTests.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/tests/etc/controlNamespaces.xml =================================================================== --- trunk/xmlunit/tests/etc/controlNamespaces.xml 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/etc/controlNamespaces.xml 2008-06-06 12:49:58 UTC (rev 264) @@ -8,4 +8,4 @@ <tool ja:version="1.5.1">ant</tool> <tool ja:version="2.4">xalan</tool> <tool ja:version="2.0.1">xerces</tool> -</openSource> \ No newline at end of file +</openSource> Modified: trunk/xmlunit/tests/etc/test.blame.html =================================================================== --- trunk/xmlunit/tests/etc/test.blame.html 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/etc/test.blame.html 2008-06-06 12:49:58 UTC (rev 264) @@ -10,4 +10,4 @@ <li>boogie...?</li> </ul> </body> -</html> \ No newline at end of file +</html> Modified: trunk/xmlunit/tests/etc/testNamespaces.xml =================================================================== --- trunk/xmlunit/tests/etc/testNamespaces.xml 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/etc/testNamespaces.xml 2008-06-06 12:49:58 UTC (rev 264) @@ -8,4 +8,4 @@ <tool jakarta:version="1.5.1">ant</tool> <tool jakarta:version="2.4">xalan</tool> <tool jakarta:version="2.0.1">xerces</tool> -</openSource> \ No newline at end of file +</openSource> Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java 2008-06-06 12:49:58 UTC (rev 264) @@ -179,4 +179,4 @@ } -} \ No newline at end of file +} Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java 2008-06-06 12:49:58 UTC (rev 264) @@ -80,4 +80,4 @@ + "<second><![CDATA[" + cdata + "]]></second><third>" + text + "</third></root>"; } -} \ No newline at end of file +} Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java 2008-06-06 12:49:58 UTC (rev 264) @@ -81,4 +81,4 @@ assertFalse(d.identical()); } -} \ No newline at end of file +} Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java 2008-06-06 12:49:58 UTC (rev 264) @@ -148,4 +148,4 @@ + "<second><![CDATA[" + cdata + "]]></second><third>" + text + "</third></root>"; } -} \ No newline at end of file +} Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-06-06 12:49:58 UTC (rev 264) @@ -226,4 +226,4 @@ assertTrue(v.isInstanceValid(s)); } -} \ No newline at end of file +} Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_XMLUnitNamespaceContext2Jaxp13.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_XMLUnitNamespaceContext2Jaxp13.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_XMLUnitNamespaceContext2Jaxp13.java 2008-06-06 12:49:58 UTC (rev 264) @@ -168,4 +168,4 @@ assertTrue("Context contained " + PREFIXES[i], found[i]); } } -} \ No newline at end of file +} Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_AbstractNodeTester.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_AbstractNodeTester.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_AbstractNodeTester.java 2008-06-06 12:49:58 UTC (rev 264) @@ -144,4 +144,4 @@ Assert.assertTrue("noMoreNodes not called", noMoreNodesCalled); } } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeInputStream.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ForumMessage4406472.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ForumMessage4406472.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ForumMessage4406472.java 2008-06-06 12:49:58 UTC (rev 264) @@ -118,4 +118,4 @@ d.overrideDifferenceListener(new ModifiedDifferenceListener()); assertTrue(d.toString(), d.similar()); } -} \ No newline at end of file +} Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ForumMessage4406472.java ___________________________________________________________________ Name: svn:executable - * Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java 2008-05-30 09:07:27 UTC (rev 263) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/util/test_IntegerBuffer.java 2008-06-06 12:49:58 UTC (rev 264) @@ -165,4 +165,4 @@ assertEquals((char) i, is[i + Math.abs(Character.MIN_VALUE)]); } } -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-06-05 11:20:07
|
Bugs item #1952324, was opened at 2008-04-26 17:45 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1952324&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: .NET 0.3.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Steve Wagner (ciroque) Assigned to: Nobody/Anonymous (nobody) Summary: Specific Version reference to nunit.framework.dll Initial Comment: Apparently the library was compiled such that it requires version 2.4.6 of the NUnit Framework assembly. We have upgraded to 2.4.7 and rolling back is not a viable option. While I can rebuild the sasembly it would get quite tedious to do that with every upgrade of the library. Thanks! ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-06-05 13:20 Message: Logged In: YES user_id=113148 Originator: NO XMLUnit 0.3.1 has been compiled against NUnit 2.4.6 and we get the "hard reference" to it because NUnit 2.4.x is strongly named (2.2.x hasn't been that#s why XMLUnit 0.3 never showed the same symptoms). In theory a binding redirect should work, in practice it doesn't work for me. See http://sourceforge.net/mailarchive/forum.php?thread_name=y1u4p8garz2.fsf%40v30161.1blu.de&forum_name=nunit-users ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1952324&group_id=23187 |
From: SourceForge.net <no...@so...> - 2008-06-05 11:16:21
|
Bugs item #1985229, was opened at 2008-06-05 10:45 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&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.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: MATSUHASHI KAZUAKI (kmatsuhashi) >Assigned to: Stefan Bodewig (bodewig) Summary: SimpleXpathEngine throws NPE for invalid xpath given Initial Comment: My environment: xmlunit-1.1, Windows 2000, JDK 1.5.0_7 with Xalan-j2.7.0, ant-1.7.0, junit3.8.1 <<What I noticed about xmlunit-1.1>> I modified the org.custommonkey.xmlunit.test_SimpleXpathEngine class: add a test method "testEvaluateInvalidXPath". ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open source])"; String result = newXpathEngine().evaluate(xpath, testDocument); } ------------------------------------------------------------------------------------- When I ran the junit, I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.032"> <error type="java.lang.NullPointerException">java.lang.NullPointerException at org.custommonkey.xmlunit.SimpleXpathEngine.performTransform(SimpleXpathEngine.java:136) at org.custommonkey.xmlunit.SimpleXpathEngine.evaluate(SimpleXpathEngine.java:202) at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPathWith(test_SimpleXpathEngine.java:85) </error> </testcase> ------------------------------------------------------------------------------------- The root cause was obvious: the XPath I gave was syntactically wrong. It had odd number of single quotation. It had to be 'open source' rather than 'open source. Also I noticed some lines of messages from the underlying XSLT processor (in my case, Xalan-j 2.7.0) were written into System.err. These messages were valuable. They told me what was the cause. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <system-err><![CDATA[SystemId は不明; 行 #1; 桁 #251; 引用符が誤っているリテラル... 単一引用符が必要でした! SystemId は不明; 行 #1; 桁 #251; ] が必要でしたが、source が見つかりました (エラーのロケーションは不明)java.lang.ClassCastException: org.apache.xpath.objects.XString ]]></system-err> ------------------------------------------------------------------------------------- <<Discussion>> Point.1: NullPointerException is terrible. Why I got a NullPointerException? The XMLunit document says the design idea is to throw org.custommonkey.xmlunit.exceptions.ConfiguratinException when a invalid XPath given rather than NPE. Point.2: Why the XSLT processor diagnostics goes to System.err? I want the message to be carried by the thrown ConfigurationException object rather than immediately swept away into System.err. Let me tell why. I've developed some custom Ant tasks (namely "AntUnit4XML") which drives the xmlunit's SimpleXpathEngine object under the AntUnit assertion mechanism. When I ran my assertion tasks, the messages from XSLT processor behind the SimpleXpathEngine vanished somehow (actually swept away into System.err of the forked process, which is invisible). I tried to figure out how to salvage the diagnostics but I couldn't. Eventually I misses the XSLT processor diagnostics. <<How I investigated>> I changed my testcase to make it more informative: ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open 'source'])"; try { String result = newXpathEngine().evaluate(xpath, testDocument); fail("expected Exception to be thrown but not"); } catch (NullPointerException npe) { String msg = "NullPointerException has been thrown." + ((npe.getMessage() != null) ? " with message \"" + npe.getMessage() + "\"" : ""); fail(msg); } catch (ConfigurationException ce) { String msg = ce.getClass().getName() + " has been thrown with message \"" + ce.getMessage() + "\""; //assertTrue(msg + "\", expected \"Error\" contained but not", // ce.getMessage().indexOf("Error")>=0); fail(msg); } catch (Exception e) { String msg = "unexpected " + e.getClass().getName() + ((e.getMessage() != null) ? " " + e.getMessage() : ""); fail(msg); } } ------------------------------------------------------------------------------------- Then I examined Saxon6.5.5 as alternative XSLT processor to see how it deals with my invalid XPath. I put the saxon.jar in the JRE/lib/endorsed dir, and slightly modified the build.xml' test target: ============================= build.xml ================================================= <target name="test" depends="compile" description="runs the tests"> <junit ... <sysproperty key="javax.xml.transform.TransformerFactory" value="com.icl.saxon.TransformerFactoryImpl"/> ... ----------------------------------------------------------------------------------------- When I run the test, I got the following report. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.25"> <failure message="expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...>" type="junit.framework.ComparisonFailure">junit.framework.ComparisonFailure: expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...> at org.custommonkey.xmlunit.test_SimpleXpathEngine.testGetXPathResultNode(test_SimpleXpathEngine.java:60) </failure> </testcase> ... <system-out><![CDATA[[testEvaluateInvalidXPath] org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown. message="Failed to compile stylesheet. 1 error detected." ]]></system-out> <system-err><![CDATA[Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Error in expression count(test//*[@attrOne='open source]): expected "]", found "<name>" ]]></system-err> ------------------------------------------------------------------------------------- Saxon did not throw NPE. Saxon threw TransformerConfigurationException, which was caught by try ... catch ... block in the test method, and wrapped by SimpleXpathEngine into a ConfigurationException. Goodness. This is the way we want it work. This examination proved that it was Xalan who actually threw the NPE. Then my next question I got was how can I make Xalan not to throw NPE? .. well, let me tell about it later. I wanted the ConfigurationException contain the diagnostics from SAXON rather than System.err. Why the diagnostics goes to System.err? I checked the source code of SimpleXpathEngine#performTransform() and found no javax.xml.transform.ErrorListener is set to the TrasnformerFactory. If no ErrorListener is provided, the TransformerFactory will print the messages into System.err. This portion can be improved. I added a SimpleErrorListener class and changed the performTransform() method as follows: ============== org.custommonkey.xmlunit.SimpleXpathEngine =========================== private void performTransform(String xslt, Document document, Result result) throws TransformerException, ConfigurationException { StringWriter sw = new StringWriter(); ErrorListener errorListener = new SimpleErrorListener(new PrintWriter(sw)); try { StreamSource source = new StreamSource(new StringReader(xslt)); TransformerFactory trf = XMLUnit.getTransformerFactory(); trf.setErrorListener(errorListener); Transformer tr = trf.newTransformer(source); tr.setErrorListener(errorListener); tr.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(sw.toString()); } } ------------------------------------------------------------------------------------- With this code change applied, the testcase gave me following report ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.0"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- OK, now the message is wrapped in the ConfigurationException. This is the way things should be. With the changes to performTransform() applied, I tried Xalan to see if the NPE still be raised. This time I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.046"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- Now Xalan ceased throwing NPE. Fine. It seems that setting a ErrorListener object explicitly to the TransformerFactory fixed the NPE problem of Xalan. The message produced by Xalan tends to be verbose, uselessly repeating a single sentence twice or three times. I wanted to make it concise but could not find how to. <<Summary of changes I propose>> - modify src/java/org.custommonkey.xmlunit.SimpleXpathEngine - add src/java/org.custommonkey.xmlunit.SimpleErrorListener - add src/java/org.custommonkey.xmlunit.SAXSourceLocator - modify tests/java/org.custommonkey.xmlunit.test_SimpleXpathEngine - add tests/java/org.custommonkey.xmlunit.test_SimpleErrorListener ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-06-05 13:16 Message: Logged In: YES user_id=113148 Originator: NO many thanks for the very thorough analysis, I'll look into your patch later today. For your project you'd probably better use XMLUnit.newXpathEngine which is supposed to provide you with a JAXP 1.3 XPath engine in your setup. In my experience there are too many problems with broken XSLT processors when using SimpleXpathEngine. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&group_id=23187 |
From: SourceForge.net <no...@so...> - 2008-06-05 08:45:35
|
Bugs item #1985229, was opened at 2008-06-05 08:45 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&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: MATSUHASHI KAZUAKI (kmatsuhashi) Assigned to: Nobody/Anonymous (nobody) Summary: SimpleXpathEngine throws NPE for invalid xpath given Initial Comment: My environment: xmlunit-1.1, Windows 2000, JDK 1.5.0_7 with Xalan-j2.7.0, ant-1.7.0, junit3.8.1 <<What I noticed about xmlunit-1.1>> I modified the org.custommonkey.xmlunit.test_SimpleXpathEngine class: add a test method "testEvaluateInvalidXPath". ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open source])"; String result = newXpathEngine().evaluate(xpath, testDocument); } ------------------------------------------------------------------------------------- When I ran the junit, I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.032"> <error type="java.lang.NullPointerException">java.lang.NullPointerException at org.custommonkey.xmlunit.SimpleXpathEngine.performTransform(SimpleXpathEngine.java:136) at org.custommonkey.xmlunit.SimpleXpathEngine.evaluate(SimpleXpathEngine.java:202) at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPathWith(test_SimpleXpathEngine.java:85) </error> </testcase> ------------------------------------------------------------------------------------- The root cause was obvious: the XPath I gave was syntactically wrong. It had odd number of single quotation. It had to be 'open source' rather than 'open source. Also I noticed some lines of messages from the underlying XSLT processor (in my case, Xalan-j 2.7.0) were written into System.err. These messages were valuable. They told me what was the cause. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <system-err><![CDATA[SystemId は不明; 行 #1; 桁 #251; 引用符が誤っているリテラル... 単一引用符が必要でした! SystemId は不明; 行 #1; 桁 #251; ] が必要でしたが、source が見つかりました (エラーのロケーションは不明)java.lang.ClassCastException: org.apache.xpath.objects.XString ]]></system-err> ------------------------------------------------------------------------------------- <<Discussion>> Point.1: NullPointerException is terrible. Why I got a NullPointerException? The XMLunit document says the design idea is to throw org.custommonkey.xmlunit.exceptions.ConfiguratinException when a invalid XPath given rather than NPE. Point.2: Why the XSLT processor diagnostics goes to System.err? I want the message to be carried by the thrown ConfigurationException object rather than immediately swept away into System.err. Let me tell why. I've developed some custom Ant tasks (namely "AntUnit4XML") which drives the xmlunit's SimpleXpathEngine object under the AntUnit assertion mechanism. When I ran my assertion tasks, the messages from XSLT processor behind the SimpleXpathEngine vanished somehow (actually swept away into System.err of the forked process, which is invisible). I tried to figure out how to salvage the diagnostics but I couldn't. Eventually I misses the XSLT processor diagnostics. <<How I investigated>> I changed my testcase to make it more informative: ============== org.custommonkey.xmlunit.test_SimpleXpathEngine ====================== public void testEvaluateInvalidXPath() throws Exception { String xpath = "count(test//*[@attrOne='open 'source'])"; try { String result = newXpathEngine().evaluate(xpath, testDocument); fail("expected Exception to be thrown but not"); } catch (NullPointerException npe) { String msg = "NullPointerException has been thrown." + ((npe.getMessage() != null) ? " with message \"" + npe.getMessage() + "\"" : ""); fail(msg); } catch (ConfigurationException ce) { String msg = ce.getClass().getName() + " has been thrown with message \"" + ce.getMessage() + "\""; //assertTrue(msg + "\", expected \"Error\" contained but not", // ce.getMessage().indexOf("Error")>=0); fail(msg); } catch (Exception e) { String msg = "unexpected " + e.getClass().getName() + ((e.getMessage() != null) ? " " + e.getMessage() : ""); fail(msg); } } ------------------------------------------------------------------------------------- Then I examined Saxon6.5.5 as alternative XSLT processor to see how it deals with my invalid XPath. I put the saxon.jar in the JRE/lib/endorsed dir, and slightly modified the build.xml' test target: ============================= build.xml ================================================= <target name="test" depends="compile" description="runs the tests"> <junit ... <sysproperty key="javax.xml.transform.TransformerFactory" value="com.icl.saxon.TransformerFactoryImpl"/> ... ----------------------------------------------------------------------------------------- When I run the test, I got the following report. ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.25"> <failure message="expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...>" type="junit.framework.ComparisonFailure">junit.framework.ComparisonFailure: expected:<...test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></tes...> but was:<...xpathResult><test><nodeWithoutAttributes>intellectual property rights </nodeWithoutAttributes><nodeWithoutAttributes>make us all poorer </nodeWithoutAttributes><nodeWithAttributes attrOne="open source " attrTwo="is the answer ">free your code from its chains</nodeWithAttributes></test></xpathResul...> at org.custommonkey.xmlunit.test_SimpleXpathEngine.testGetXPathResultNode(test_SimpleXpathEngine.java:60) </failure> </testcase> ... <system-out><![CDATA[[testEvaluateInvalidXPath] org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown. message="Failed to compile stylesheet. 1 error detected." ]]></system-out> <system-err><![CDATA[Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Error in expression count(test//*[@attrOne='open source]): expected "]", found "<name>" ]]></system-err> ------------------------------------------------------------------------------------- Saxon did not throw NPE. Saxon threw TransformerConfigurationException, which was caught by try ... catch ... block in the test method, and wrapped by SimpleXpathEngine into a ConfigurationException. Goodness. This is the way we want it work. This examination proved that it was Xalan who actually threw the NPE. Then my next question I got was how can I make Xalan not to throw NPE? .. well, let me tell about it later. I wanted the ConfigurationException contain the diagnostics from SAXON rather than System.err. Why the diagnostics goes to System.err? I checked the source code of SimpleXpathEngine#performTransform() and found no javax.xml.transform.ErrorListener is set to the TrasnformerFactory. If no ErrorListener is provided, the TransformerFactory will print the messages into System.err. This portion can be improved. I added a SimpleErrorListener class and changed the performTransform() method as follows: ============== org.custommonkey.xmlunit.SimpleXpathEngine =========================== private void performTransform(String xslt, Document document, Result result) throws TransformerException, ConfigurationException { StringWriter sw = new StringWriter(); ErrorListener errorListener = new SimpleErrorListener(new PrintWriter(sw)); try { StreamSource source = new StreamSource(new StringReader(xslt)); TransformerFactory trf = XMLUnit.getTransformerFactory(); trf.setErrorListener(errorListener); Transformer tr = trf.newTransformer(source); tr.setErrorListener(errorListener); tr.transform(new DOMSource(document), result); } catch (javax.xml.transform.TransformerConfigurationException ex) { throw new ConfigurationException(sw.toString()); } } ------------------------------------------------------------------------------------- With this code change applied, the testcase gave me following report ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.0"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error at xsl:value-of on line 1 of file:/C:/eclipse/workspace/xmlunit-1.1/: Unmatched quote in expression count(test//*[@attrOne='open source])" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- OK, now the message is wrapped in the ConfigurationException. This is the way things should be. With the changes to performTransform() applied, I tried Xalan to see if the NPE still be raised. This time I got the following report: ============== TEST-org.custommonkey.xmlunit.test_SimpleXpathEngine.xml ============= <testcase classname="org.custommonkey.xmlunit.test_SimpleXpathEngine" name="testEvaluateInvalidXPath" time="0.046"> <failure message="org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!"" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: org.custommonkey.xmlunit.exceptions.ConfigurationException has been thrown with message "Error on line 1 column 179: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!Errorjavax.xml.transform.TransformerException: javax.xml.transform.TransformerException: 引用符が誤っているリテラル... 単一引用符が必要でした!" at org.custommonkey.xmlunit.test_SimpleXpathEngine.testEvaluateInvalidXPath(test_SimpleXpathEngine.java:98) </failure> </testcase> ------------------------------------------------------------------------------------- Now Xalan ceased throwing NPE. Fine. It seems that setting a ErrorListener object explicitly to the TransformerFactory fixed the NPE problem of Xalan. The message produced by Xalan tends to be verbose, uselessly repeating a single sentence twice or three times. I wanted to make it concise but could not find how to. <<Summary of changes I propose>> - modify src/java/org.custommonkey.xmlunit.SimpleXpathEngine - add src/java/org.custommonkey.xmlunit.SimpleErrorListener - add src/java/org.custommonkey.xmlunit.SAXSourceLocator - modify tests/java/org.custommonkey.xmlunit.test_SimpleXpathEngine - add tests/java/org.custommonkey.xmlunit.test_SimpleErrorListener ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1985229&group_id=23187 |
From: <bo...@us...> - 2008-05-30 09:07:22
|
Revision: 263 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=263&view=rev Author: bodewig Date: 2008-05-30 02:07:27 -0700 (Fri, 30 May 2008) Log Message: ----------- attach license information Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/src/etc/xmlunit-ivy.xml trunk/xmlunit/src/etc/xmlunit.pom Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2008-04-04 15:51:52 UTC (rev 262) +++ trunk/xmlunit/build.xml 2008-05-30 09:07:27 UTC (rev 263) @@ -1,3 +1,36 @@ +<?xml version="1.0"?> +<!-- +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> <project name="xmlunit" default="test" basedir="."> <!-- allow properties to be overridden in a properties file --> Modified: trunk/xmlunit/src/etc/xmlunit-ivy.xml =================================================================== --- trunk/xmlunit/src/etc/xmlunit-ivy.xml 2008-04-04 15:51:52 UTC (rev 262) +++ trunk/xmlunit/src/etc/xmlunit-ivy.xml 2008-05-30 09:07:27 UTC (rev 263) @@ -1,3 +1,36 @@ +<?xml version="1.0"?> +<!-- +Copyright (c) 2007-2008, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> <ivy-module version="1.3"> <info organization="@GROUP@" module="@ARTIFACT@" Modified: trunk/xmlunit/src/etc/xmlunit.pom =================================================================== --- trunk/xmlunit/src/etc/xmlunit.pom 2008-04-04 15:51:52 UTC (rev 262) +++ trunk/xmlunit/src/etc/xmlunit.pom 2008-05-30 09:07:27 UTC (rev 263) @@ -1,6 +1,39 @@ <?xml version="1.0"?> <!-- +Copyright (c) 2007-2008, Jeff Martin, Tim Bacon +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> + +<!-- + This POM is not usable as means to build XMLUnit with Maven2, it is a minimal POM to allow XMLUnit's artifacts to be added to a Maven repository. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-04-26 15:45:38
|
Bugs item #1952324, was opened at 2008-04-26 08:45 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1952324&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: .NET 0.3.1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Steve Wagner (ciroque) Assigned to: Nobody/Anonymous (nobody) Summary: Specific Version reference to nunit.framework.dll Initial Comment: Apparently the library was compiled such that it requires version 2.4.6 of the NUnit Framework assembly. We have upgraded to 2.4.7 and rolling back is not a viable option. While I can rebuild the sasembly it would get quite tedious to do that with every upgrade of the library. Thanks! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1952324&group_id=23187 |
From: SourceForge.net <no...@so...> - 2008-04-19 02:20:24
|
Feature Requests item #1877458, was opened at 2008-01-22 07:50 Message generated for change (Comment added) made by sf-robot You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1877458&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: XMLUnit for Java Group: None >Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: Olivier Armand (extended) Assigned to: Nobody/Anonymous (nobody) Summary: Support for XML entities comparison Initial Comment: The DifferenceEngine's JavaDoc ( http://xmlunit.sourceforge.net/api/org/custommonkey/xmlunit/DifferenceEngine.html ) indicates: "Nodes of other types (eg ENTITY_NODE) will be skipped." This means that for example this test case fails: assertXMLEqual("<root>bla\r\nbla</root>", "<root>bla
\nbla</root>"); I suppose this is because XmlUnit sees \r\n on one side and only \n on the other side since 
 is skipped. In my case the control and the test are generated by different processing chain (and XML parsers/serializers), which may produce either entities or standard characters. XMLUnit.setNormalizeWhitespace(true); seems to be a solution for the special case of this entity, but true support for XML entities comparison would be much better. ---------------------------------------------------------------------- >Comment By: SourceForge Robot (sf-robot) Date: 2008-04-18 19:20 Message: Logged In: YES user_id=1312539 Originator: NO 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: 2008-04-04 08:47 Message: Logged In: YES user_id=113148 Originator: NO my fault, the " case passes even without the setExpandEntityReferences flag and the 
 case fails even with the flag. My best guess is that 
 simply doesn't expand to the same thing as \r. assertXMLEqual("<root>bla \nbla</root>", "<root>bla
\nbla</root>") passes as well, with and without explicit entity reference expansion. Anyway, I've added the flag now. I'd be grateful if you could test XMLUnit's svn trunk, set the flag and see whether it resolves the issues you see (apart from the \r case). http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=261 ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-04-04 08:29 Message: Logged In: YES user_id=113148 Originator: NO If I change your example to assertXMLEqual("<root>bla1\nbla</root>", "<root>bla1\nbla</root>"); it passes for me, so there is something strange with the expansion of a carriage return. My reading of EntityReference's Javadocs "Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference." is that we can rely on the parser to expand simple character references and my test with "1" -> "1 seems to confirm this. If I use " and \" it fails, again. I'll throw in a property for XMLUnit that invokes DocumentBuilderFactory.setExpandEntityReferences for more control, we'll see how that works out. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1877458&group_id=23187 |
From: <bo...@us...> - 2008-04-04 15:51:52
|
Revision: 262 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=262&view=rev Author: bodewig Date: 2008-04-04 08:51:52 -0700 (Fri, 04 Apr 2008) Log Message: ----------- typo Modified Paths: -------------- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-04-04 15:46:09 UTC (rev 261) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-04-04 15:51:52 UTC (rev 262) @@ -3421,7 +3421,7 @@ </listitem> <listitem> - <literal>XMLUnit.setsetIgnoreDiffBetweenTextAndCDATA</literal> + <literal>XMLUnit.setIgnoreDiffBetweenTextAndCDATA</literal> now also sets <literal>DocumentBuilderFactory.setCoalescing</literal>. This has been done so that whitespace differences can be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-04-04 15:47:08
|
Feature Requests item #1877458, was opened at 2008-01-22 16:50 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1877458&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: XMLUnit for Java Group: None >Status: Pending >Resolution: Fixed Priority: 5 Private: No Submitted By: Olivier Armand (extended) Assigned to: Nobody/Anonymous (nobody) Summary: Support for XML entities comparison Initial Comment: The DifferenceEngine's JavaDoc ( http://xmlunit.sourceforge.net/api/org/custommonkey/xmlunit/DifferenceEngine.html ) indicates: "Nodes of other types (eg ENTITY_NODE) will be skipped." This means that for example this test case fails: assertXMLEqual("<root>bla\r\nbla</root>", "<root>bla
\nbla</root>"); I suppose this is because XmlUnit sees \r\n on one side and only \n on the other side since 
 is skipped. In my case the control and the test are generated by different processing chain (and XML parsers/serializers), which may produce either entities or standard characters. XMLUnit.setNormalizeWhitespace(true); seems to be a solution for the special case of this entity, but true support for XML entities comparison would be much better. ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-04-04 17:47 Message: Logged In: YES user_id=113148 Originator: NO my fault, the " case passes even without the setExpandEntityReferences flag and the 
 case fails even with the flag. My best guess is that 
 simply doesn't expand to the same thing as \r. assertXMLEqual("<root>bla \nbla</root>", "<root>bla
\nbla</root>") passes as well, with and without explicit entity reference expansion. Anyway, I've added the flag now. I'd be grateful if you could test XMLUnit's svn trunk, set the flag and see whether it resolves the issues you see (apart from the \r case). http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=261 ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-04-04 17:29 Message: Logged In: YES user_id=113148 Originator: NO If I change your example to assertXMLEqual("<root>bla1\nbla</root>", "<root>bla1\nbla</root>"); it passes for me, so there is something strange with the expansion of a carriage return. My reading of EntityReference's Javadocs "Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference." is that we can rely on the parser to expand simple character references and my test with "1" -> "1 seems to confirm this. If I use " and \" it fails, again. I'll throw in a property for XMLUnit that invokes DocumentBuilderFactory.setExpandEntityReferences for more control, we'll see how that works out. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1877458&group_id=23187 |
From: <bo...@us...> - 2008-04-04 15:46:06
|
Revision: 261 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=261&view=rev Author: bodewig Date: 2008-04-04 08:46:09 -0700 (Fri, 04 Apr 2008) Log Message: ----------- Add flag that controls the parser's entity expansion Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-04-04 15:12:40 UTC (rev 260) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-04-04 15:46:09 UTC (rev 261) @@ -82,6 +82,7 @@ private static boolean ignoreAttributeOrder = false; private static String xsltVersion = "1.0"; private static String xpathFactoryName = null; + private static boolean expandEntities = false; private static final String XSLT_VERSION_START = " version=\""; private static final String XSLT_VERSION_END = "\">"; @@ -850,5 +851,25 @@ return XSLTConstants.XSLT_START_NO_VERSION + XSLT_VERSION_START + getXSLTVersion() + XSLT_VERSION_END; } + + /** + * Whether the parser shall be instructed to expand entity references. + * + * <p>Defaults to false.</p> + * + * @see javax.xml.parsers.DocumentBuilderFactory#setExpandEntityReferences + */ + public static void setExpandEntityReferences(boolean b) { + expandEntities = b; + getControlDocumentBuilderFactory().setExpandEntityReferences(b); + getTestDocumentBuilderFactory().setExpandEntityReferences(b); + } + + /** + * Whether the parser shall be instructed to expand entity references. + */ + public static boolean getExpandEntityReferences() { + return expandEntities; + } } Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-04-04 15:12:40 UTC (rev 260) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-04-04 15:46:09 UTC (rev 261) @@ -2354,6 +2354,15 @@ </programlisting> </section> + <section id="Entity Reference Expansion"> + <title>Entity Reference Expansion</title> + + <para>Normally the XML parser will expand character references + to their Unicode equivalents but for more complex entity + definitions the parser may expand them or not. + Using <literal>XMLUnit.setExpandEntityReferences</literal> you + can control the parser's setting.</para> + </section> </section> </section> @@ -3455,6 +3464,13 @@ <xref linkend="MatchTracker"/>. <ulink url="https://sourceforge.net/tracker/index.php?func=detail&aid=1860491&group_id=23187&atid=377771">Issue 1860491</ulink>.</listitem> + <listitem>It is now possible to have more control over + whether the parser expand entity references or not by + using <literal>XMLUnit.setExpandEntityReferences</literal>, + see <xref linkend="Entity Reference + Expansion"/>. <ulink href="https://sourceforge.net/tracker/index.php?func=detail&aid=1877458&group_id=23187&atid=377771">Issue + 1877458</ulink>.</listitem> + <listitem>New examples have been added: <itemizedlist> <listitem><literal>RecursiveElementNameAndTextQualifier</literal> Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-04-04 15:12:40 UTC (rev 260) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-04-04 15:46:09 UTC (rev 261) @@ -866,5 +866,21 @@ XMLUnit.setIgnoreDiffBetweenTextAndCDATA(false); } } + + /** + * Not a real test. Need something that actually fails unless I + * set the flag. + */ + public void testEntityExpansion() throws Exception { + String control = "<root>bla bla</root>"; + String test = "<root>bla
bla</root>"; + //XMLUnit.setExpandEntityReferences(true); + try { + Diff diff = buildDiff(control, test); + assertTrue(diff.toString(), diff.similar()); + } finally { + XMLUnit.setExpandEntityReferences(false); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-04-04 15:28:57
|
Feature Requests item #1877458, was opened at 2008-01-22 16:50 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1877458&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: XMLUnit for Java Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Olivier Armand (extended) Assigned to: Nobody/Anonymous (nobody) Summary: Support for XML entities comparison Initial Comment: The DifferenceEngine's JavaDoc ( http://xmlunit.sourceforge.net/api/org/custommonkey/xmlunit/DifferenceEngine.html ) indicates: "Nodes of other types (eg ENTITY_NODE) will be skipped." This means that for example this test case fails: assertXMLEqual("<root>bla\r\nbla</root>", "<root>bla
\nbla</root>"); I suppose this is because XmlUnit sees \r\n on one side and only \n on the other side since 
 is skipped. In my case the control and the test are generated by different processing chain (and XML parsers/serializers), which may produce either entities or standard characters. XMLUnit.setNormalizeWhitespace(true); seems to be a solution for the special case of this entity, but true support for XML entities comparison would be much better. ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-04-04 17:29 Message: Logged In: YES user_id=113148 Originator: NO If I change your example to assertXMLEqual("<root>bla1\nbla</root>", "<root>bla1\nbla</root>"); it passes for me, so there is something strange with the expansion of a carriage return. My reading of EntityReference's Javadocs "Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference." is that we can rely on the parser to expand simple character references and my test with "1" -> "1 seems to confirm this. If I use " and \" it fails, again. I'll throw in a property for XMLUnit that invokes DocumentBuilderFactory.setExpandEntityReferences for more control, we'll see how that works out. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1877458&group_id=23187 |
From: SourceForge.net <no...@so...> - 2008-04-04 15:14:09
|
Bugs item #1903923, was opened at 2008-02-28 15:26 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1903923&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.1 >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Stefan Bodewig (bodewig) Assigned to: Stefan Bodewig (bodewig) Summary: ignoreWhitespace and CDATA don't mix well Initial Comment: as originally reported by "nobody" in bug 1863632 public void testDit() throws SAXException, IOException { String shcont = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Data><Person><Name><![CDATA[JOE]]></Name></Person></Data>"; String newTest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +"<Data>" +" <Person>" +" <Name>" +" <![CDATA[JOE]]>" +" </Name>" +" </Person>" +"</Data>"; XMLUnit.setIgnoreWhitespace(true); try { Diff diff = XMLUnit.compareXML(shcont, newTest); System.out.println(diff.toString()); assertTrue(diff.similar()); } finally { XMLUnit.setIgnoreWhitespace(false); } } fails ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-04-04 17:14 Message: Logged In: YES user_id=113148 Originator: YES if you setIgnoreDiffBetweenCDATAAndText to true as well, whitespace can be ignored in the presence of CDATA as well. http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=260 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1903923&group_id=23187 |
From: <bo...@us...> - 2008-04-04 15:12:39
|
Revision: 260 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=260&view=rev Author: bodewig Date: 2008-04-04 08:12:40 -0700 (Fri, 04 Apr 2008) Log Message: ----------- set DocumentBuilderFactory to coalescing mode when ignoring differences between CDATA and Text Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-03-28 16:14:21 UTC (rev 259) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-04-04 15:12:40 UTC (rev 260) @@ -666,9 +666,16 @@ * Whether CDATA sections and Text nodes should be considered the same. * * <p>The default is false.</p> + * + * <p>This also set the DocumentBuilderFactory's {@link + * javax.xml.parsers.DocumentBuilderFactory#setCoalescing + * coalescing} flag on the factories for the control and test + * document.</p> */ public static void setIgnoreDiffBetweenTextAndCDATA(boolean b) { ignoreDiffBetweenTextAndCDATA = b; + getControlDocumentBuilderFactory().setCoalescing(b); + getTestDocumentBuilderFactory().setCoalescing(b); } /** Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-28 16:14:21 UTC (rev 259) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-04-04 15:12:40 UTC (rev 260) @@ -3410,6 +3410,16 @@ kind of difference) the XPath for the "missing" node will be null. It used to be some random XPath of a different node. </listitem> + + <listitem> + <literal>XMLUnit.setsetIgnoreDiffBetweenTextAndCDATA</literal> + now also + sets <literal>DocumentBuilderFactory.setCoalescing</literal>. + This has been done so that whitespace differences can be + resolved according to the corresponding flags even in the + presence of CDATA + sections. <ulink href="https://sourceforge.net/tracker/index.php?func=detail&aid=1903923&group_id=23187&atid=377768">Issue + 1903923</ulink>.</listitem> </itemizedlist> </section> Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-28 16:14:21 UTC (rev 259) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-04-04 15:12:40 UTC (rev 260) @@ -843,4 +843,28 @@ assertEquals(12, count[0]); } + public void testCDATAAndIgnoreWhitespace() throws Exception { + String control = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<Data><Person><Name><![CDATA[JOE]]></Name></Person></Data>"; + + String test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + +"<Data>" + +" <Person>" + +" <Name>" + +" <![CDATA[JOE]]>" + +" </Name>" + +" </Person>" + +"</Data>"; + + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true); + try { + Diff diff = buildDiff(control, test); + assertTrue(diff.toString(), diff.similar()); + } finally { + XMLUnit.setIgnoreWhitespace(false); + XMLUnit.setIgnoreDiffBetweenTextAndCDATA(false); + } + } } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-28 16:14:49
|
Revision: 259 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=259&view=rev Author: bodewig Date: 2008-03-28 09:14:21 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Document MatchTracker Modified Paths: -------------- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-28 15:53:54 UTC (rev 258) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-28 16:14:21 UTC (rev 259) @@ -2093,6 +2093,66 @@ </section> + <section id="MatchTracker"> + <title><literal>MatchTracker</literal></title> + + <para>Sometimes you might be interested in any sort of + comparison result and want to get notified of successful matches + as well. Maybe you want to provide feedback on the amount of + differences and similarities between two documents, for + example.</para> + + <para>The interface <literal>MatchTracker</literal> can be + implemented to get notified on each and every successful match, + note that there may be a lot more comparisions going on than you + might expect and that your callback gets notified a lot.</para> + + <example> + <title>The <literal>MatchTracker</literal> interface</title> + <programlisting language="Java"><![CDATA[ +package org.custommonkey.xmlunit; + +/** + * Listener for callbacks from a {@link DifferenceEngine#compare + * DifferenceEngine comparison} that is notified on each and every + * comparision that resulted in a match. + */ +public interface MatchTracker { + /** + * Receive notification that 2 match. + * @param match a Difference instance as defined in {@link + * DifferenceConstants DifferenceConstants} describing the test + * that matched and containing the detail of the nodes that have + * been compared + */ + void matchFound(Difference difference); +} +]]></programlisting></example> + + <para>Despite its name the <literal>Difference</literal> + instance passed into the <literal>matchFound</literal> method + really describes a match and not a difference. You can expect + that the <literal>getValue</literal> method on both the + control and the test <literal>NodeDetail</literal> will be + equal.</para> + + <para><literal>DifferenceEngine</literal> provides a constructor + overload that allows you to pass in + a <literal>MatchTracker</literal> instance and also provides + a <literal>setMatchTracker</literal> + method. <literal>Diff</literal> + and <literal>DetailedDiff</literal> + provide <literal>overrideMatchTracker</literal> methods that + fill the same purpose.</para> + + <para>Note that your <literal>MatchTracker</literal> won't + receive any callbacks once the + configured <literal>ComparisonController</literal> has decided + that <literal>DifferenceEngine</literal> should halt the + comparision.</para> + + </section> + <section id="Comparing: JUnit 3"> <title>JUnit 3.x Convenience Methods</title> @@ -3379,6 +3439,12 @@ method. <ulink url="https://sourceforge.net/tracker/index.php?func=detail&aid=1854284&group_id=23187&atid=377771">Issue 1854284</ulink>.</listitem> + <listitem>A new callback + interface <literal>MatchTracker</literal> is now notified on + successful matches of Nodes. For more details see + <xref linkend="MatchTracker"/>. <ulink url="https://sourceforge.net/tracker/index.php?func=detail&aid=1860491&group_id=23187&atid=377771">Issue + 1860491</ulink>.</listitem> + <listitem>New examples have been added: <itemizedlist> <listitem><literal>RecursiveElementNameAndTextQualifier</literal> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2008-03-28 15:55:29
|
Feature Requests item #1860491, was opened at 2007-12-29 19:01 Message generated for change (Settings changed) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1860491&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: XMLUnit for Java Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Notice about successful matchings of nodes? Initial Comment: Hello, at the moment, the user gets informed via DifferenceListener.differenceFound(), whenever a *difference* between two nodes is recognized. But as I understood XMLUnit, there is no chance to get informed about a successful *matching* of nodes. This could be helpful, too. Not that urgent, but maybe you could think about it. Thanks in advance, Joerg ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2008-03-28 16:55 Message: Logged In: YES user_id=113148 Originator: NO trunk now has such a callback interface, it is called MatchTracker. http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=258 ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-01-04 11:41 Message: Logged In: YES user_id=113148 Originator: NO That's why it is a DifferenceListener ;-) OK, an additional callback interface that gets notified of successful matches would certainly be possible, it just might get overwhelmed with invocations. Any idea on its name? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=1860491&group_id=23187 |
From: <bo...@us...> - 2008-03-28 15:54:19
|
Revision: 258 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=258&view=rev Author: bodewig Date: 2008-03-28 08:53:54 -0700 (Fri, 28 Mar 2008) Log Message: ----------- provide a callback for successful matches Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java Added Paths: ----------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2008-03-27 14:05:06 UTC (rev 257) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2008-03-28 15:53:54 UTC (rev 258) @@ -83,6 +83,7 @@ private DifferenceEngine differenceEngine; private DifferenceListener differenceListenerDelegate; private ElementQualifier elementQualifierDelegate; + private MatchTracker matchTrackerDelegate; /** * Construct a Diff that compares the XML in two Strings @@ -397,12 +398,25 @@ } /** + * Override the <code>MatchTracker</code> used to track + * successfully matched nodes. + * @param delegate the MatchTracker instance to delegate handling to. + */ + public void overrideMatchTracker(MatchTracker delegate) { + this.matchTrackerDelegate = delegate; + if (differenceEngine != null) { + differenceEngine.setMatchTracker(delegate); + } + } + + /** * Lazily initializes the difference engine if it hasn't been set * via a constructor. */ private DifferenceEngine getDifferenceEngine() { return differenceEngine == null - ? new DifferenceEngine(this) : differenceEngine; + ? new DifferenceEngine(this, matchTrackerDelegate) + : differenceEngine; } } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2008-03-27 14:05:06 UTC (rev 257) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2008-03-28 15:53:54 UTC (rev 258) @@ -70,20 +70,44 @@ private static final String NOT_NULL_NODE = "not null"; private static final String ATTRIBUTE_ABSENT = "[attribute absent]"; private final ComparisonController controller; + private MatchTracker matchTracker; private final XpathNodeTracker controlTracker; private final XpathNodeTracker testTracker; /** + * Simple constructor that uses no MatchTracker at all. + * @param controller the instance used to determine whether a Difference + * detected by this class should halt further comparison or not + * @see ComparisonController#haltComparison(Difference) + */ + public DifferenceEngine(ComparisonController controller) { + this(controller, null); + } + + /** * Simple constructor * @param controller the instance used to determine whether a Difference * detected by this class should halt further comparison or not + * @param matchTracker the instance that is notified on each + * successful match. May be null. * @see ComparisonController#haltComparison(Difference) + * @see MatchTracker#matchFound(Difference) */ - public DifferenceEngine(ComparisonController controller) { + public DifferenceEngine(ComparisonController controller, + MatchTracker matchTracker) { this.controller = controller; + this.matchTracker = matchTracker; this.controlTracker = new XpathNodeTracker(); this.testTracker = new XpathNodeTracker(); } + + /** + * @param matchTracker the instance that is notified on each + * successful match. May be null. + */ + public void setMatchTracker(MatchTracker matchTracker) { + this.matchTracker = matchTracker; + } /** * Entry point for Node comparison testing. @@ -792,21 +816,23 @@ Difference difference, XpathNodeTracker controlLoc, XpathNodeTracker testLoc) throws DifferenceFoundException { + NodeDetail controlDetail = new NodeDetail(String.valueOf(expected), + control, + controlLoc == null ? null + : controlLoc.toXpathString()); + NodeDetail testDetail = new NodeDetail(String.valueOf(actual), + test, + testLoc == null ? null + : testLoc.toXpathString()); + Difference differenceInstance = new Difference(difference, + controlDetail, testDetail); if (unequal(expected, actual)) { - NodeDetail controlDetail = new NodeDetail(String.valueOf(expected), - control, - controlLoc == null ? null - : controlLoc.toXpathString()); - NodeDetail testDetail = new NodeDetail(String.valueOf(actual), - test, - testLoc == null ? null - : testLoc.toXpathString()); - Difference differenceInstance = new Difference(difference, - controlDetail, testDetail); listener.differenceFound(differenceInstance); if (controller.haltComparison(differenceInstance)) { throw flowControlException; } + } else if (matchTracker != null) { + matchTracker.matchFound(differenceInstance); } } Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java 2008-03-28 15:53:54 UTC (rev 258) @@ -0,0 +1,53 @@ +/* +****************************************************************** +Copyright (c) 2008, Stefan Bodewig +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit; + +/** + * Listener for callbacks from a {@link DifferenceEngine#compare + * DifferenceEngine comparison} that is notified on each and every + * comparision that resulted in a match. + */ +public interface MatchTracker { + /** + * Receive notification that 2 match. + * @param match a Difference instance as defined in {@link + * DifferenceConstants DifferenceConstants} describing the test + * that matched and containing the detail of the nodes that have + * been compared + */ + void matchFound(Difference difference); +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/MatchTracker.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2008-03-27 14:05:06 UTC (rev 257) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java 2008-03-28 15:53:54 UTC (rev 258) @@ -311,6 +311,11 @@ return new DetailedDiff(super.buildDiff(control, test)); } + protected Diff buildDiff(String control, String test, + DifferenceEngine engine) throws Exception { + return new DetailedDiff(super.buildDiff(control, test, engine)); + } + public test_DetailedDiff(String name) { super(name); firstForecast = "<weather><today icon=\"clouds\" temp=\"17\">" Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-27 14:05:06 UTC (rev 257) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-28 15:53:54 UTC (rev 258) @@ -487,6 +487,12 @@ return new Diff(control, test); } + protected Diff buildDiff(String control, String test, + DifferenceEngine engine) throws Exception { + return new Diff(XMLUnit.buildControlDocument(control), + XMLUnit.buildTestDocument(test), engine); + } + /** * Construct a test * @param name Test name @@ -764,4 +770,77 @@ assertFalse(diff.toString(), diff.identical()); assertFalse(diff.toString(), diff.similar()); } + + public void testMatchTrackerSetViaOverride() throws Exception { + Diff diff = buildDiff("<foo/>", "<foo/>"); + final int[] count = new int[1]; + diff.overrideMatchTracker(new MatchTracker() { + public void matchFound(Difference d) { + count[0]++; + } + }); + assertTrue(diff.identical()); + // NODE_TYPE (not null), NODE_TYPE(Document), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), HAS_DOCTYPE_DECLARATION(no), + // HAS_CHILD_NODES(true) + // + // NODE_TYPE(Element), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) + assertEquals(12, count[0]); + } + + public void testMatchTrackerSetViaEngine() throws Exception { + final int[] count = new int[1]; + DifferenceEngine engine = + new DifferenceEngine(new ComparisonController() { + public boolean haltComparison(Difference afterDifference) { + fail("haltComparison invoked"); + // NOTREACHED + return false; + } + }, new MatchTracker() { + public void matchFound(Difference d) { + count[0]++; + } + }); + Diff diff = buildDiff("<foo/>", "<foo/>", engine); + assertTrue(diff.identical()); + // NODE_TYPE (not null), NODE_TYPE(Document), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), HAS_DOCTYPE_DECLARATION(no), + // HAS_CHILD_NODES(true) + // + // NODE_TYPE(Element), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) + assertEquals(12, count[0]); + } + + public void testMatchTrackerSetViaOverrideOnEngine() throws Exception { + DifferenceEngine engine = + new DifferenceEngine(new ComparisonController() { + public boolean haltComparison(Difference afterDifference) { + fail("haltComparison invoked"); + // NOTREACHED + return false; + } + }); + Diff diff = buildDiff("<foo/>", "<foo/>", engine); + final int[] count = new int[1]; + diff.overrideMatchTracker(new MatchTracker() { + public void matchFound(Difference d) { + count[0]++; + } + }); + assertTrue(diff.identical()); + // NODE_TYPE (not null), NODE_TYPE(Document), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), HAS_DOCTYPE_DECLARATION(no), + // HAS_CHILD_NODES(true) + // + // NODE_TYPE(Element), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) + assertEquals(12, count[0]); + } + } Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2008-03-27 14:05:06 UTC (rev 257) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java 2008-03-28 15:53:54 UTC (rev 258) @@ -843,6 +843,40 @@ assertEquals(ATTR_NAME_NOT_FOUND_ID, listener.comparingWhat); } + public void testMatchTrackerSetViaConstructor() throws Exception { + Element control = document.createElement("foo"); + Element test = document.createElement("foo"); + final int[] count = new int[1]; + DifferenceEngine d = + new DifferenceEngine(new SimpleComparisonController(), + new MatchTracker() { + public void matchFound(Difference d) { + count[0]++; + } + }); + d.compare(control, test, listener, null); + // NODE_TYPE (not null), NODE_TYPE(Element), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) + assertEquals(7, count[0]); + } + + public void testMatchTrackerSetViaSetter() throws Exception { + Element control = document.createElement("foo"); + Element test = document.createElement("foo"); + final int[] count = new int[1]; + engine.setMatchTracker(new MatchTracker() { + public void matchFound(Difference d) { + count[0]++; + } + }); + engine.compare(control, test, listener, null); + // NODE_TYPE (not null), NODE_TYPE(Element), NAMESPACE_URI(none), + // NAMESPACE_PREFIX(none), ELEMENT_TAG_NAME(foo), + // ELEMENT_NUM_ATTRIBUTE(none), HAS_CHILD_NODES(false) + assertEquals(7, count[0]); + } + 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...> - 2008-03-27 14:05:10
|
Revision: 257 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=257&view=rev Author: bodewig Date: 2008-03-27 07:05:06 -0700 (Thu, 27 Mar 2008) Log Message: ----------- Document DifferenceListener changes Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2008-03-26 20:59:54 UTC (rev 256) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2008-03-27 14:05:06 UTC (rev 257) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-26 20:59:54 UTC (rev 256) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-27 14:05:06 UTC (rev 257) @@ -1639,7 +1639,7 @@ ignored by <literal>DifferenceEngine</literal>, it becomes important when used together with <literal>Diff</literal>, though (see <xref linkend="Diff"/>). The return value should be - one of the three constants defined in the the + one of the four constants defined in the the <literal>DifferenceListener</literal> interface:</para> <programlisting language="Java"><![CDATA[ @@ -1661,6 +1661,12 @@ * interpreted as being similar. */ int RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR; + /** + * Override return value for the <code>differenceFound</code> method. + * Indicates that the nodes identified as being similar should be + * interpreted as being different. + */ + int RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT = 3; ]]></programlisting> <para>The <literal>skippedComparison</literal> method is @@ -3366,6 +3372,13 @@ addition to W3C XML Schema. See <xref linkend="JAXP 1.3 Validation"/> for details.</listitem> + <listitem><literal>DifferenceListener</literal> can now + "upgrade" recoverable differences to non-recoverable by + returning <literal>RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT</literal> + in the <literal>differenceFound</literal> + method. <ulink url="https://sourceforge.net/tracker/index.php?func=detail&aid=1854284&group_id=23187&atid=377771">Issue + 1854284</ulink>.</listitem> + <listitem>New examples have been added: <itemizedlist> <listitem><literal>RecursiveElementNameAndTextQualifier</literal> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |