From: <bo...@us...> - 2008-03-05 16:42:34
|
Revision: 244 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=244&view=rev Author: bodewig Date: 2008-03-05 08:42:35 -0800 (Wed, 05 Mar 2008) Log Message: ----------- add Schema defintion validation based on javax.xml.validation Added Paths: ----------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java trunk/xmlunit/tests/etc/broken.xsd trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-05 16:42:35 UTC (rev 244) @@ -0,0 +1,125 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit.jaxp13; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.xml.XMLConstants; +import javax.xml.transform.Source; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +/** + * Validator class based of {@link javax.xml.validation javax.xml.validation}. + * + * <p>This class currently only provides support for validating schema + * definitions. It defaults to the W3C XML Schema 1.0 but can be used + * to validate against any schema language supported by your + * SchemaFactory implementation.</p> + */ +public class Validator { + private final String schemaLanguage; + private final ArrayList sources = new ArrayList(); + + /** + * validates using W3C XML Schema 1.0. + */ + public Validator() { + this(XMLConstants.W3C_XML_SCHEMA_NS_URI); + } + + /** + * validates using the specified schema language. + * + * @param schemaLanguage the schema language to use - see {@link + * javax.xml.validation.SchemaFactory SchemaFactory}. + */ + public Validator(String schemaLanguage) { + this.schemaLanguage = schemaLanguage; + } + + /** + * Adds a source for the schema defintion. + */ + public void addSchemaSource(Source s) { + sources.add(s); + } + + /** + * Is the given schema definition valid? + */ + public boolean isSchemaValid() { + return getSchemaErrors().size() == 0; + } + + /** + * Obtain a list of all errors in the schema defintion. + * + * <p>The list contains {@link org.xml.sax.SAXParseException + * SAXParseException}s.</p> + */ + public List/*<SAXParseException>*/ getSchemaErrors() { + final ArrayList l = new ArrayList(); + ErrorHandler h = new ErrorHandler() { + public void error(SAXParseException e) { + l.add(e); + } + public void fatalError(SAXParseException e) { + l.add(e); + } + public void warning(SAXParseException e) { + l.add(e); + } + }; + try { + parseSchema(h); + } catch (SAXException e) { + // error has been recorded in our ErrorHandler anyway + } + return Collections.unmodifiableList(l); + } + + private Schema parseSchema(ErrorHandler h) throws SAXException { + SchemaFactory fac = SchemaFactory.newInstance(schemaLanguage); + fac.setErrorHandler(h); + return fac.newSchema((Source[]) sources.toArray(new Source[0])); + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/etc/broken.xsd =================================================================== --- trunk/xmlunit/tests/etc/broken.xsd (rev 0) +++ trunk/xmlunit/tests/etc/broken.xsd 2008-03-05 16:42:35 UTC (rev 244) @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.publishing.org" + xmlns="http://www.publishing.org" + version="1.0" + elementFormDefault="qualified"> + + <xsd:element name="Book" type="BookType"/> + + <xsd:complexType name="BookType"> + <xsd:element name="Title" type="xsd:string" minOccurs="1" maxOccurs="1"/> + <xsd:element name="Author" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/> + <xsd:element name="Date" type="xsd:string" minOccurs="1" maxOccurs="1"/> + <xsd:element name="ISBN" type="xsd:string" minOccurs="1" maxOccurs="1"/> + </xsd:complexType> +</xsd:schema> + Property changes on: trunk/xmlunit/tests/etc/broken.xsd ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-05 16:42:35 UTC (rev 244) @@ -0,0 +1,96 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit.jaxp13; + +import java.io.FileInputStream; +import java.util.Iterator; +import java.util.List; +import javax.xml.transform.stream.StreamSource; + +import junit.framework.TestCase; + +import org.custommonkey.xmlunit.test_Constants; + +public class test_Validator extends TestCase { + + public void testGoodSchemaIsValid() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource( + new FileInputStream(test_Constants.BASEDIR + + "/tests/etc/Book.xsd") + ) + ); + assertTrue(v.isSchemaValid()); + } + + public void testGoodSchemaHasNoErrors() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource( + new FileInputStream(test_Constants.BASEDIR + + "/tests/etc/Book.xsd") + ) + ); + assertEquals(0, v.getSchemaErrors().size()); + } + + public void testBrokenSchemaIsInvalid() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource( + new FileInputStream(test_Constants.BASEDIR + + "/tests/etc/broken.xsd") + ) + ); + assertFalse(v.isSchemaValid()); + } + + public void testBrokenSchemaHasErrors() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource( + new FileInputStream(test_Constants.BASEDIR + + "/tests/etc/broken.xsd") + ) + ); + List l = v.getSchemaErrors(); + /* + for (Iterator i = l.iterator(); i.hasNext(); ) { + System.err.println(i.next()); + } + */ + assertTrue(l.size() > 0); + } + +} \ No newline at end of file Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-06 08:49:46
|
Revision: 245 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=245&view=rev Author: bodewig Date: 2008-03-06 00:49:51 -0800 (Thu, 06 Mar 2008) Log Message: ----------- simplify Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-05 16:42:35 UTC (rev 244) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-06 08:49:51 UTC (rev 245) @@ -37,7 +37,6 @@ package org.custommonkey.xmlunit.jaxp13; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.xml.XMLConstants; import javax.xml.transform.Source; @@ -114,7 +113,7 @@ } catch (SAXException e) { // error has been recorded in our ErrorHandler anyway } - return Collections.unmodifiableList(l); + return l; } private Schema parseSchema(ErrorHandler h) throws SAXException { Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-05 16:42:35 UTC (rev 244) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-06 08:49:51 UTC (rev 245) @@ -36,7 +36,7 @@ package org.custommonkey.xmlunit.jaxp13; -import java.io.FileInputStream; +import java.io.File; import java.util.Iterator; import java.util.List; import javax.xml.transform.stream.StreamSource; @@ -49,41 +49,29 @@ public void testGoodSchemaIsValid() throws Exception { Validator v = new Validator(); - v.addSchemaSource(new StreamSource( - new FileInputStream(test_Constants.BASEDIR - + "/tests/etc/Book.xsd") - ) - ); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.xsd"))); assertTrue(v.isSchemaValid()); } public void testGoodSchemaHasNoErrors() throws Exception { Validator v = new Validator(); - v.addSchemaSource(new StreamSource( - new FileInputStream(test_Constants.BASEDIR - + "/tests/etc/Book.xsd") - ) - ); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.xsd"))); assertEquals(0, v.getSchemaErrors().size()); } public void testBrokenSchemaIsInvalid() throws Exception { Validator v = new Validator(); - v.addSchemaSource(new StreamSource( - new FileInputStream(test_Constants.BASEDIR - + "/tests/etc/broken.xsd") - ) - ); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/broken.xsd"))); assertFalse(v.isSchemaValid()); } public void testBrokenSchemaHasErrors() throws Exception { Validator v = new Validator(); - v.addSchemaSource(new StreamSource( - new FileInputStream(test_Constants.BASEDIR - + "/tests/etc/broken.xsd") - ) - ); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/broken.xsd"))); List l = v.getSchemaErrors(); /* for (Iterator i = l.iterator(); i.hasNext(); ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-07 04:56:37
|
Revision: 246 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=246&view=rev Author: bodewig Date: 2008-03-06 20:56:39 -0800 (Thu, 06 Mar 2008) Log Message: ----------- Add instance validation and document new Validator class Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java trunk/xmlunit/src/user-guide/XMLUnit-Java.xml trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-06 08:49:51 UTC (rev 245) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-07 04:56:39 UTC (rev 246) @@ -42,6 +42,7 @@ import javax.xml.transform.Source; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.custommonkey.xmlunit.exceptions.XMLUnitRuntimeException; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -56,13 +57,14 @@ */ public class Validator { private final String schemaLanguage; + private final SchemaFactory factory; private final ArrayList sources = new ArrayList(); /** * validates using W3C XML Schema 1.0. */ public Validator() { - this(XMLConstants.W3C_XML_SCHEMA_NS_URI); + this(XMLConstants.W3C_XML_SCHEMA_NS_URI, null); } /** @@ -72,7 +74,27 @@ * javax.xml.validation.SchemaFactory SchemaFactory}. */ public Validator(String schemaLanguage) { + this(schemaLanguage, null); + } + + /** + * validates using the specified schema factory. + */ + public Validator(SchemaFactory factory) { + this(null, factory); + } + + /** + * validates using the specified schema language or factory. + * + * @param schemaLanguage the schema language to use - see {@link + * javax.xml.validation.SchemaFactory SchemaFactory}. + * @param schemaFactory the concrete factory to use. If this is + * non-null, the first argument will be ignored. + */ + protected Validator(String schemaLanguage, SchemaFactory factory) { this.schemaLanguage = schemaLanguage; + this.factory = factory; } /** @@ -97,28 +119,90 @@ */ public List/*<SAXParseException>*/ getSchemaErrors() { final ArrayList l = new ArrayList(); - ErrorHandler h = new ErrorHandler() { - public void error(SAXParseException e) { - l.add(e); - } - public void fatalError(SAXParseException e) { - l.add(e); - } - public void warning(SAXParseException e) { - l.add(e); - } - }; try { - parseSchema(h); + parseSchema(new CollectingErrorHandler(l)); } catch (SAXException e) { // error has been recorded in our ErrorHandler anyway } return l; } + /** + * Is the given schema instance valid according to the configured + * schema definition(s)? + * + * @throws XMLUnitRuntimeException if the schema definition is + * invalid or the Source is a SAXSource and the underlying + * XMLReader throws an IOException (see {@link + * javax.xml.validation.Validator#validate validate in + * Validator}). + */ + public boolean isInstanceValid(Source instance) + throws XMLUnitRuntimeException { + return getInstanceErrors(instance).size() == 0; + } + + /** + * Obtain a list of all errors in the given instance. + * + * <p>The list contains {@link org.xml.sax.SAXParseException + * SAXParseException}s.</p> + * + * @throws XMLUnitRuntimeException if the schema definition is + * invalid or the Source is a SAXSource and the underlying + * XMLReader throws an IOException (see {@link + * javax.xml.validation.Validator#validate validate in + * Validator}). + */ + public List/*<SAXParseException>*/ getInstanceErrors(Source instance) + throws XMLUnitRuntimeException { + Schema schema = null; + try { + schema = parseSchema(null); + } catch (SAXException e) { + throw new XMLUnitRuntimeException("Schema is invalid", e); + } + + final ArrayList l = new ArrayList(); + javax.xml.validation.Validator v = schema.newValidator(); + v.setErrorHandler(new CollectingErrorHandler(l)); + try { + v.validate(instance); + } catch (SAXException e) { + // error has been recorded in our ErrorHandler anyway + } catch (java.io.IOException i) { + throw new XMLUnitRuntimeException("Error reading instance source", + i); + } + return l; + } + private Schema parseSchema(ErrorHandler h) throws SAXException { - SchemaFactory fac = SchemaFactory.newInstance(schemaLanguage); + SchemaFactory fac = factory != null ? factory + : SchemaFactory.newInstance(schemaLanguage); fac.setErrorHandler(h); - return fac.newSchema((Source[]) sources.toArray(new Source[0])); + try { + return fac.newSchema((Source[]) + sources.toArray(new Source[sources.size()])); + } finally { + fac.setErrorHandler(null); + } } + + private static final class CollectingErrorHandler implements ErrorHandler { + private final List l; + + CollectingErrorHandler(List l) { + this.l = l; + } + public void error(SAXParseException e) { + l.add(e); + } + public void fatalError(SAXParseException e) { + l.add(e); + } + public void warning(SAXParseException e) { + l.add(e); + } + } } \ No newline at end of file Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-06 08:49:51 UTC (rev 245) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2008-03-07 04:56:39 UTC (rev 246) @@ -456,6 +456,14 @@ or more XML Schema definitions. See <xref linkend="XML Schema Validation"/> for details.</para> + <para>XMLUnit 1.2 introduces a new <literal>Validator</literal> + class that relies on JAXP + 1.3's <literal>javax.xml.validation</literal> package. This + Validator can validate against W3C XML Schema, but may support + different Schema languages like RELAX NG if your JAXP + implementation supports it. See + <xref linkend="JAXP 1.3 Validation"/> for details.</para> + </section> <section id="Xpath Tests"><title>Xpath Tests</title> @@ -2436,7 +2444,7 @@ the configured <literal>EntityResolver</literal> may still be used.</para> - <example> + <example id="schema-jaxp12"> <title>Validating Against a Local XML Schema</title> <programlisting language="Java"><![CDATA[ InputSource is = new InputSource(new FileInputStream(myXmlDocument)); @@ -2500,6 +2508,65 @@ linkend="XML Schema Validation"/>).</listitem> </itemizedlist> </section> + + <section id="JAXP 1.3 Validation"> + <title>JAXP 1.3 Validation</title> + + <para>JAXP 1.3 - shipping with Java5 or better and available as + a separate product for earlier Java VMs - introduces a new + 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 + 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> + + <para>The + class <literal>org.custommonkey.xmlunit.jaxp13.Validator</literal> + can be used to validate a piece of XML against a schema + definition but also to validate the schema definition itself. + By default <literal>Validator</literal> will assume your + definition uses the W3C XML Schema language, but it provides a + constructor that can be used to specify a different language via + an URL supported by the <literal>SchemaFactory</literal> class. + 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 + to validate are specified as <literal>Source</literal> as + well.</para> + + <para>The following example + uses <literal>org.custommonkey.xmlunit.jaxp13.Validator</literal> + to perform the same type of validation shown in + <xref linkend="schema-jaxp12"/>.</para> + + <example id="schema-jaxp13"> + <title>Validating Against a Local XML Schema</title> + <programlisting language="Java"><![CDATA[ +Validator v = new Validator(); +v.addSchemaSource(new StreamSource(new File(myXmlSchemaFile))); +StreamSource is = new StreamSource(new File(myXmlDocument)); +boolean isValid = v.isInstanceValid(is); +]]></programlisting></example> + + <para>Validating a schema definition is shown in the next + example.</para> + + <example> + <title>Validating a XML Schema Defintion</title> + <programlisting language="Java"><![CDATA[ +Validator v = new Validator(); +v.addSchemaSource(new StreamSource(new File(myXmlSchemaFile))); +boolean isValid = v.isSchemaValid(); +]]></programlisting></example> + + <para>There is no explicit JUnit 3 support + for <literal>org.custommonkey.xmlunit.jaxp13.Validator</literal>.</para> + + </section> + </section> <section id="XPath Tests"> @@ -3259,6 +3326,16 @@ by <literal>Validator</literal> can now be configured completely. <ulink href="https://sourceforge.net/tracker/index.php?func=detail&aid=1903928&group_id=23187&atid=377771">Issue 1903928</ulink>.</listitem> + + <listitem>A new + class <literal>org.custommonkey.xmlunit.jaxp13.Validator</literal> + can be used to validate schema definitions and schema + instances using the <literal>javax.xml.validation</literal> + package of JAXP 1.3. Depending on your JAXP implementation + this may allow you to validate documents against schema + definitions written in RELAX NG or other schema languages in + addition to W3C XML Schema. See + <xref linkend="JAXP 1.3 Validation"/> for details.</listitem> </itemizedlist> </section> Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-06 08:49:51 UTC (rev 245) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-07 04:56:39 UTC (rev 246) @@ -37,6 +37,7 @@ package org.custommonkey.xmlunit.jaxp13; import java.io.File; +import java.io.IOException; import java.util.Iterator; import java.util.List; import javax.xml.transform.stream.StreamSource; @@ -44,6 +45,9 @@ import junit.framework.TestCase; import org.custommonkey.xmlunit.test_Constants; +import org.custommonkey.xmlunit.exceptions.XMLUnitRuntimeException; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; public class test_Validator extends TestCase { @@ -73,12 +77,81 @@ v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + "/tests/etc/broken.xsd"))); List l = v.getSchemaErrors(); - /* for (Iterator i = l.iterator(); i.hasNext(); ) { - System.err.println(i.next()); + Object ex = i.next(); + assertTrue(ex instanceof SAXParseException); + /* + System.err.println(ex); + */ } - */ assertTrue(l.size() > 0); } + public void testGoodInstanceIsValid() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.xsd"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/BookXsdGenerated.xml")); + assertTrue(v.isInstanceValid(s)); + } + + public void testBadInstanceIsInvalid() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.xsd"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/invalidBook.xml")); + assertFalse(v.isInstanceValid(s)); + } + + public void testBadInstanceHasErrors() throws Exception { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.xsd"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/invalidBook.xml")); + List l = v.getInstanceErrors(s); + for (Iterator i = l.iterator(); i.hasNext(); ) { + Object ex = i.next(); + assertTrue(ex instanceof SAXParseException); + /* + System.err.println(ex); + */ + } + assertTrue(l.size() > 0); + } + + public void testInstanceValidationOfBrokenSchema() { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/broken.xsd"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/BookXsdGenerated.xml")); + try { + v.isInstanceValid(s); + fail("expected exception because schema is invalid"); + } catch (XMLUnitRuntimeException e) { + assertTrue(e.getCause() instanceof SAXException); + } + } + + public void testInstanceValidationOfMissingFile() { + Validator v = new Validator(); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.xsd"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/not there.xml")); + try { + v.isInstanceValid(s); + fail("expected exception because instance doesn't exist"); + } catch (XMLUnitRuntimeException e) { + assertTrue(e.getCause() instanceof IOException); + } + } } \ 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: <bo...@us...> - 2008-03-07 11:52:51
|
Revision: 247 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=247&view=rev Author: bodewig Date: 2008-03-07 03:51:51 -0800 (Fri, 07 Mar 2008) Log Message: ----------- some RELAX NG experiments Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java trunk/xmlunit/tests/etc/invalidBook.xml trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java Added Paths: ----------- trunk/xmlunit/tests/etc/Book.rng trunk/xmlunit/tests/etc/Book.rngc Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-07 04:56:39 UTC (rev 246) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Validator.java 2008-03-07 11:51:51 UTC (rev 247) @@ -50,10 +50,10 @@ /** * Validator class based of {@link javax.xml.validation javax.xml.validation}. * - * <p>This class currently only provides support for validating schema - * definitions. It defaults to the W3C XML Schema 1.0 but can be used - * to validate against any schema language supported by your - * SchemaFactory implementation.</p> + * <p>This class provides support for validating schema definitions as + * well as instance documents. It defaults to the W3C XML Schema 1.0 + * but can be used to validate against any schema language supported + * by your SchemaFactory implementation.</p> */ public class Validator { private final String schemaLanguage; @@ -122,7 +122,20 @@ try { parseSchema(new CollectingErrorHandler(l)); } catch (SAXException e) { - // error has been recorded in our ErrorHandler anyway + // error should have been recorded in our ErrorHandler, at + // least that's what the Javadocs say "SchemaFactory is + // not allowed to throw SAXException without first + // reporting it to ErrorHandler.". + // + // Unfortunately not all implementations seem to follow + // this rule. In particular using the setup described in + // org.custommonkey.xmlunit.jaxp13.test_Validator#XtestGoodRelaxNGCompactSyntaxIsValid() + // an exception ("SAXParseException: Content is not + // allowed in prolog.") will be thrown that never enters + // our Errorhandler. + if (l.size() == 0) { + l.add(e); + } } return l; } @@ -169,7 +182,11 @@ try { v.validate(instance); } catch (SAXException e) { - // error has been recorded in our ErrorHandler anyway + // error should have been recorded in our ErrorHandler, + // but better double-check. + if (l.size() == 0) { + l.add(e); + } } catch (java.io.IOException i) { throw new XMLUnitRuntimeException("Error reading instance source", i); Added: trunk/xmlunit/tests/etc/Book.rng =================================================================== --- trunk/xmlunit/tests/etc/Book.rng (rev 0) +++ trunk/xmlunit/tests/etc/Book.rng 2008-03-07 11:51:51 UTC (rev 247) @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<element name="Book" ns="http://www.publishing.org" + xmlns="http://relaxng.org/ns/structure/1.0"> + <element name="Title"><text/></element> + <oneOrMore> + <element name="Author"><text/></element> + </oneOrMore> + <element name="Date"><text/></element> + <element name="ISBN"><text/></element> + <element name="Publisher"><text/></element> +</element> Property changes on: trunk/xmlunit/tests/etc/Book.rng ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/etc/Book.rngc =================================================================== --- trunk/xmlunit/tests/etc/Book.rngc (rev 0) +++ trunk/xmlunit/tests/etc/Book.rngc 2008-03-07 11:51:51 UTC (rev 247) @@ -0,0 +1,9 @@ +namespace b = "http://www.publishing.org" + +element b:Book { + element b:Title { text }, + element b:Author { text }+, + element b:Date { text }, + element b:ISBN { text }, + element b:Publisher { text } +} Property changes on: trunk/xmlunit/tests/etc/Book.rngc ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/xmlunit/tests/etc/invalidBook.xml =================================================================== --- trunk/xmlunit/tests/etc/invalidBook.xml 2008-03-07 04:56:39 UTC (rev 246) +++ trunk/xmlunit/tests/etc/invalidBook.xml 2008-03-07 11:51:51 UTC (rev 247) @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Book xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" - xmlns="http://www.publishing.org" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.publishing.org tests/etc/Book.xsd"> + xmlns="http://www.publishing.org"> <Title>Chicken Soup for the Soul</Title> <Author>Jack Canfield</Author> <Author>Mark Victor Hansen</Author> Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-07 04:56:39 UTC (rev 246) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2008-03-07 11:51:51 UTC (rev 247) @@ -154,4 +154,76 @@ assertTrue(e.getCause() instanceof IOException); } } + + /** + * fails unless you manage to setup JAXP 1.3 and RELAX NG support + * + * <p>The setup that worked for Stefan when he wrote this test: + * JDK 1.5.0_09, isorelax-jaxp-bridge-1.0, together with msv.jar, + * isorelax.jar, relaxngDatatype.jar and xsdlib.jar from msv's + * latest nightly build (2008-02-13, actually). The same jars do + * not work with Java6.</p> + * + * @see http://weblogs.java.net/blog/kohsuke/archive/2006/02/validate_xml_us.html + */ + public void XtestGoodRelaxNGSchemaIsValid() throws Exception { + Validator v = new Validator(javax.xml.XMLConstants.RELAXNG_NS_URI); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.rng"))); + assertTrue(v.isSchemaValid()); + } + + /** + * fails unless you manage to setup JAXP 1.3 and RELAX NG support + * @see #XtestGoodRelaxNGSchemaIsValid() + */ + public void XtestGoodInstanceIsValidRNG() throws Exception { + Validator v = new Validator(javax.xml.XMLConstants.RELAXNG_NS_URI); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.rng"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/BookXsdGeneratedNoSchema.xml")); + assertTrue(v.isInstanceValid(s)); + } + + /** + * fails unless you manage to setup JAXP 1.3 and RELAX NG support + * @see #XtestGoodRelaxNGSchemaIsValid() + */ + public void XtestBadInstanceIsInvalidRNG() throws Exception { + Validator v = new Validator(javax.xml.XMLConstants.RELAXNG_NS_URI); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.rng"))); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/invalidBook.xml")); + List l = v.getInstanceErrors(s); + for (Iterator i = l.iterator(); i.hasNext(); ) { + Object ex = i.next(); + assertTrue(ex instanceof SAXParseException); + /* + System.err.println(ex); + */ + } + assertTrue(l.size() > 0); + } + + /** + * fails even using the setup in XtestGoodRelaxNGSchemaIsValid() + * since a SAXParser is trying to read the compact syntax + * definition and chokes on it not being XML. + * @see #XtestGoodRelaxNGSchemaIsValid() + */ + public void XtestGoodRelaxNGCompactSyntaxIsValid() throws Exception { + Validator v = new Validator(javax.xml.XMLConstants.RELAXNG_NS_URI); + v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/Book.rngc"))); + assertTrue(v.isSchemaValid()); + StreamSource s = + new StreamSource(new File(test_Constants.BASEDIR + + "/tests/etc/BookXsdGeneratedNoSchema.xml")); + assertTrue(v.isInstanceValid(s)); + } + } \ 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: <bo...@us...> - 2008-03-12 16:57:54
|
Revision: 248 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=248&view=rev Author: bodewig Date: 2008-03-12 09:57:59 -0700 (Wed, 12 Mar 2008) Log Message: ----------- Add simplistic DifferenceListener that ignores case Added Paths: ----------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java 2008-03-12 16:57:59 UTC (rev 248) @@ -0,0 +1,65 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ +package org.custommonkey.xmlunit.examples; + +import java.util.Locale; +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceListener; + +/** + * Ignores case for all textual content. + */ +public class CaseInsensitiveDifferenceListener + extends TextDifferenceListenerBase { + + public CaseInsensitiveDifferenceListener(DifferenceListener delegateTo) { + super(delegateTo); + } + + protected int textualDifference(Difference d) { + String control = d.getControlNodeDetail().getValue(); + if (control != null) { + control = control.toLowerCase(Locale.US); + if (d.getTestNodeDetail().getValue() != null + && control.equals(d.getTestNodeDetail().getValue() + .toLowerCase(Locale.US))) { + return + DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; + } + } + return DifferenceListener.RETURN_ACCEPT_DIFFERENCE; + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java 2008-03-12 16:57:59 UTC (rev 248) @@ -0,0 +1,124 @@ +/* +****************************************************************** +Copyright (c) 2006-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. + +****************************************************************** +*/ +package org.custommonkey.xmlunit.examples; + +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceConstants; +import org.custommonkey.xmlunit.DifferenceListener; +import org.w3c.dom.Node; + +/** + * Base class that delegates all differences to another DifferenceListener. + * + * <p>Subclasses get a chance to hook into special methods that will + * be invoked for differences in textual values of attributes, CDATA + * sections, Text or comment nodes.</p> + */ +public abstract class TextDifferenceListenerBase + implements DifferenceListener { + + private final DifferenceListener delegateTo; + + protected TextDifferenceListenerBase(DifferenceListener delegateTo) { + this.delegateTo = delegateTo; + } + + /** + * Delegates to the nested DifferenceListener unless the + * Difference is of type {@link DifferenceConstants#ATTR_VALUE_ID + * ATTR_VALUE_ID}, {@link DifferenceConstants#CDATA_VALUE_ID + * CDATA_VALUE_ID}, {@link DifferenceConstants#COMMENT_VALUE_ID + * COMMENT_VALUE_ID} or {@link DifferenceConstants#TEXT_VALUE_ID + * TEXT_VALUE_ID} - for those special differences {@link + * #attributeDifference attributeDifference}, {@link + * #cdataDifference cdataDifference}, {@link #commentDifference + * commentDifference} or {@link #textDifference textDifference} + * are invoked respectively. + */ + public int differenceFound(Difference difference) { + switch (difference.getId()) { + case DifferenceConstants.ATTR_VALUE_ID: + return attributeDifference(difference); + case DifferenceConstants.CDATA_VALUE_ID: + return cdataDifference(difference); + case DifferenceConstants.COMMENT_VALUE_ID: + return commentDifference(difference); + case DifferenceConstants.TEXT_VALUE_ID: + return textDifference(difference); + } + return delegateTo.differenceFound(difference); + } + + /** + * Delegates to {@link #textualDifference textualDifference}. + */ + protected int attributeDifference(Difference d) { + return textualDifference(d); + } + + /** + * Delegates to {@link #textualDifference textualDifference}. + */ + protected int cdataDifference(Difference d) { + return textualDifference(d); + } + + /** + * Delegates to {@link #textualDifference textualDifference}. + */ + protected int commentDifference(Difference d) { + return textualDifference(d); + } + + /** + * Delegates to {@link #textualDifference textualDifference}. + */ + protected int textDifference(Difference d) { + return textualDifference(d); + } + + /** + * Delegates to the nested DifferenceListener. + */ + protected int textualDifference(Difference d) { + return delegateTo.differenceFound(d); + } + + public void skippedComparison(Node control, Node test) { + delegateTo.skippedComparison(control, test); + } + +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java 2008-03-12 16:57:59 UTC (rev 248) @@ -0,0 +1,83 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ +package org.custommonkey.xmlunit.examples; + +import java.util.Locale; +import junit.framework.TestCase; + +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceListener; +import org.w3c.dom.Node; + +public class test_CaseInsensitiveDifferenceListener extends TestCase { + + private static final String ATTR = "aTtr"; + private static final String CDATA = "C Data"; + private static final String CMMT = "a Comment"; + private static final String TEXT = "some Text"; + + public void testCaseInsensitive() throws Exception { + String control = getDoc(ATTR, CDATA, CMMT, TEXT); + String test = getDoc(ATTR.toUpperCase(Locale.US), + CDATA.toUpperCase(Locale.US), + CMMT.toUpperCase(Locale.US), + TEXT.toUpperCase(Locale.US)); + Diff d = new Diff(control, test); + + CaseInsensitiveDifferenceListener c = + new CaseInsensitiveDifferenceListener(new DifferenceListener() { + public int differenceFound(Difference d) { + fail("differenceFound shouldn't get invoked, but" + + " was with type " + d.getId()); + return -42; + } + public void skippedComparison(Node c, Node t) { + fail("skippedComparison shouldn't get invoked"); + } + }); + + d.overrideDifferenceListener(c); + assertTrue(d.identical()); + } + + private static String getDoc(String attr, String cdata, String comment, + String text) { + return "<root><first attr=\"" + attr + "\"/><!--" + comment + "-->" + + "<second><![CDATA[" + cdata + "]]></second><third>" + text + + "</third></root>"; + } +} \ No newline at end of file Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_CaseInsensitiveDifferenceListener.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java 2008-03-12 16:57:59 UTC (rev 248) @@ -0,0 +1,151 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ +package org.custommonkey.xmlunit.examples; + +import junit.framework.TestCase; + +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceListener; +import org.w3c.dom.Node; + +public class test_TextDifferenceListenerBase extends TestCase { + private static final String C_ATTR = "controlAttr"; + private static final String T_ATTR = "testAttr"; + private static final String C_CDATA = "controlCdata"; + private static final String T_CDATA = "testCdata"; + private static final String C_CMMT = "controlComment"; + private static final String T_CMMT = "testComment"; + private static final String C_TEXT = "controlText"; + private static final String T_TEXT = "testText"; + + public void testTextDifferenceDelegations() throws Exception { + final int[] invocations = new int[4]; + + String control = getDoc(C_ATTR, C_CDATA, C_CMMT, C_TEXT); + String test = getDoc(T_ATTR, T_CDATA, T_CMMT, T_TEXT); + + TextDifferenceListenerBase b = new TextDifferenceListenerBase(null) { + protected int attributeDifference(Difference d) { + assertEquals(C_ATTR, d.getControlNodeDetail().getValue()); + assertEquals(T_ATTR, d.getTestNodeDetail().getValue()); + invocations[0]++; + return 1; + } + + protected int cdataDifference(Difference d) { + assertEquals(C_CDATA, d.getControlNodeDetail().getValue()); + assertEquals(T_CDATA, d.getTestNodeDetail().getValue()); + invocations[1]++; + return 1; + } + + protected int commentDifference(Difference d) { + assertEquals(C_CMMT, d.getControlNodeDetail().getValue()); + assertEquals(T_CMMT, d.getTestNodeDetail().getValue()); + invocations[2]++; + return 1; + } + + protected int textDifference(Difference d) { + assertEquals(C_TEXT, d.getControlNodeDetail().getValue()); + assertEquals(T_TEXT, d.getTestNodeDetail().getValue()); + invocations[3]++; + return 1; + } + }; + + Diff d = new Diff(control, test); + d.overrideDifferenceListener(b); + + assertTrue(d.identical()); + + for (int i = 0; i < invocations.length; i++) { + assertEquals(1, invocations[i]); + } + } + + public void testTextualDifference() throws Exception { + final int[] invocations = new int[1]; + + String control = getDoc(C_ATTR, C_CDATA, C_CMMT, C_TEXT); + String test = getDoc(T_ATTR, T_CDATA, T_CMMT, T_TEXT); + + TextDifferenceListenerBase b = new TextDifferenceListenerBase(null) { + protected int textualDifference(Difference d) { + invocations[0]++; + return 1; + } + }; + + Diff d = new Diff(control, test); + d.overrideDifferenceListener(b); + + assertTrue(d.identical()); + assertEquals(4, invocations[0]); + } + + public void testFullDelegation() throws Exception { + final int[] invocations = new int[1]; + + String control = getDoc(C_ATTR, C_CDATA, C_CMMT, C_TEXT); + String test = getDoc(T_ATTR, T_CDATA, T_CMMT, T_TEXT); + + TextDifferenceListenerBase b = + new TextDifferenceListenerBase(new DifferenceListener() { + public int differenceFound(Difference d) { + invocations[0]++; + return 1; + } + public void skippedComparison(Node c, Node t) { + fail("skippedComparison shouldn't get invoked"); + } + }) {}; + + Diff d = new Diff(control, test); + d.overrideDifferenceListener(b); + + assertTrue(d.identical()); + assertEquals(4, invocations[0]); + } + + private static String getDoc(String attr, String cdata, String comment, + String text) { + return "<root><first attr=\"" + attr + "\"/><!--" + comment + "-->" + + "<second><![CDATA[" + cdata + "]]></second><third>" + text + + "</third></root>"; + } +} \ No newline at end of file Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_TextDifferenceListenerBase.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-13 17:08:49
|
Revision: 249 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=249&view=rev Author: bodewig Date: 2008-03-13 10:08:43 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Add a simplistic DifferenceListener that uses a tolerance when comparing numbers Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java Added Paths: ----------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java 2008-03-12 16:57:59 UTC (rev 248) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/CaseInsensitiveDifferenceListener.java 2008-03-13 17:08:43 UTC (rev 249) @@ -60,6 +60,7 @@ DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; } } - return DifferenceListener.RETURN_ACCEPT_DIFFERENCE; + // some string is null, delegate + return super.textualDifference(d); } } \ No newline at end of file Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2008-03-13 17:08:43 UTC (rev 249) @@ -0,0 +1,73 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ +package org.custommonkey.xmlunit.examples; + +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceListener; + +/** + * Expects texts to be floating point numbers and treats them as + * identical if they only differ by a given tolerance value (or less). + */ +public class FloatingPointTolerantDifferenceListener + extends TextDifferenceListenerBase { + + private final double tolerance; + + public FloatingPointTolerantDifferenceListener(DifferenceListener delegateTo, + double tolerance) { + super(delegateTo); + this.tolerance = tolerance; + } + + protected int textualDifference(Difference d) { + String control = d.getControlNodeDetail().getValue(); + String test = d.getTestNodeDetail().getValue(); + if (control != null && test != null) { + try { + double controlVal = Double.parseDouble(control); + double testVal = Double.parseDouble(test); + return Math.abs(controlVal - testVal) < tolerance + ? DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL + : DifferenceListener.RETURN_ACCEPT_DIFFERENCE; + } catch (NumberFormatException nfe) { + // ignore, delegate to nested DifferenceListener + } + } + // no numbers or null, delegate + return super.textualDifference(d); + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java 2008-03-12 16:57:59 UTC (rev 248) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/TextDifferenceListenerBase.java 2008-03-13 17:08:43 UTC (rev 249) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2006-2008, Jeff Martin, Tim Bacon +Copyright (c) 2008, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java 2008-03-13 17:08:43 UTC (rev 249) @@ -0,0 +1,84 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ +package org.custommonkey.xmlunit.examples; + +import java.util.Locale; +import junit.framework.TestCase; + +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.Difference; +import org.custommonkey.xmlunit.DifferenceListener; +import org.w3c.dom.Node; + +public class test_FloatingPointTolerantDifferenceListener extends TestCase { + + public void testFloatingPointTolerance() throws Exception { + String control = "<foo value=\"2.718281828\"/>"; + String test = "<foo value=\"2.71\"/>"; + Diff d = new Diff(control, test); + + FloatingPointTolerantDifferenceListener c = + new FloatingPointTolerantDifferenceListener(new DifferenceListener() { + public int differenceFound(Difference d) { + fail("differenceFound shouldn't get invoked, but" + + " was with type " + d.getId()); + return -42; + } + public void skippedComparison(Node c, Node t) { + fail("skippedComparison shouldn't get invoked"); + } + }, 1e-2); + + d.overrideDifferenceListener(c); + assertTrue(d.identical()); + + c = new FloatingPointTolerantDifferenceListener(new DifferenceListener() { + public int differenceFound(Difference d) { + fail("differenceFound shouldn't get invoked, but" + + " was with type " + d.getId()); + return -42; + } + public void skippedComparison(Node c, Node t) { + fail("skippedComparison shouldn't get invoked"); + } + }, 1e-3); + + d = new Diff(control, test); + d.overrideDifferenceListener(c); + assertFalse(d.identical()); + } + +} \ No newline at end of file Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_FloatingPointTolerantDifferenceListener.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-14 15:48:30
|
Revision: 250 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=250&view=rev Author: bodewig Date: 2008-03-14 08:48:26 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Add RecursiveElementNameAndTextQualifier contributed by Frank Callahan; Issue 1878549 Added Paths: ----------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_RecursiveElementNameAndTextQualifier.java Added: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java (rev 0) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java 2008-03-14 15:48:26 UTC (rev 250) @@ -0,0 +1,198 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit.examples; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.custommonkey.xmlunit.ElementNameQualifier; +import org.custommonkey.xmlunit.ElementQualifier; + +/** + * Compares all Element and Text nodes in two pieces of XML. Allows elements of + * complex, deeply nested types that are returned in different orders but have + * the same content to be recognized as comparable. + * + * @author Frank Callahan + */ +public class RecursiveElementNameAndTextQualifier implements ElementQualifier { + + private static final ElementNameQualifier NAME_QUALIFIER = + new ElementNameQualifier(); + + /** + * Uses element names and the text nested an arbitrary level of + * child elements deeper into the element to compare + * elements. Checks all nodes, not just first child element. + * + * <p> Does not ignore empty text nodes. + */ + public RecursiveElementNameAndTextQualifier() { + } + + /** + * Returns result of recursive comparison of all the nodes of a + * control and test element. + */ + public boolean qualifyForComparison(Element currentControl, + Element currentTest) { + return compareNodes(currentControl, currentTest); + } + + private boolean compareNodes(Node currentControl, Node currentTest) { + try { + + // if they are elements, compare names of the two nodes + if (!NAME_QUALIFIER.qualifyForComparison((Element) currentControl, + (Element) currentTest)) { + return false; + } + + // Compare the control and test elements' children + + NodeList controlNodes = null; + NodeList testNodes = null; + + // Check that both nodes have children and, if so, get lists of them + + if (currentControl.hasChildNodes() && currentTest.hasChildNodes()) { + controlNodes = currentControl.getChildNodes(); + testNodes = currentTest.getChildNodes(); + } else if (currentControl.hasChildNodes() + || currentTest.hasChildNodes()) { + return false; + + // if both nodes are empty, they are comparable + } else { + return true; + } + + // check that both node lists have the same length + + if (countNodesWithoutConsecutiveTextNodes(controlNodes) + != countNodesWithoutConsecutiveTextNodes(testNodes)) { + return false; + } + + // Do checks of test and control nodes' children + + final int cNodes = controlNodes.getLength(); + final int tNodes = testNodes.getLength(); + + int i, j; + for (i = j = 0; i < cNodes && j < tNodes; i++, j++) { + Node testNode = testNodes.item(i); + Node controlNode = controlNodes.item(j); + + // check if both node are same type + if (controlNode.getNodeType() != testNode.getNodeType()) { + return false; + } + // compare text nodes + if (controlNode.getNodeType() == Node.TEXT_NODE) { + // compare concatenated, trimmed text nodes + if (!catText(controlNode).equals(catText(testNode))) { + return false; + } + + // swallow adjacent Text nodes + for (; i < cNodes - 1 + && controlNodes.item(i + 1).getNodeType() == Node.TEXT_NODE; + i++); + for (; j < tNodes - 1 + && testNodes.item(j + 1).getNodeType() == Node.TEXT_NODE; + j++); + + // recursive check of current child control and test nodes' + // children + + } else if (!compareNodes((Element) controlNode, + (Element) testNode)) { + return false; + } + } + if (i != cNodes || j != tNodes) { + return false; + } + + // All descendants of current control and test nodes are comparable + return true; + } catch (Exception e) { + return false; + } + } + /** + * Concatenates contiguous Text nodes and removes all leading and + * trailing whitespace. + * @param textNode + * @return + */ + private static String catText(Node textNode) { + StringBuffer text = new StringBuffer(); + Node next = textNode; + + do { + if (next.getNodeValue() != null) { + text.append(next.getNodeValue().trim()); + next = next.getNextSibling(); + } + } while (next != null && next.getNodeType() == Node.TEXT_NODE); + + return text.toString(); + } + + /** + * Calculates the number of Nodes that are either not Text nodes + * or are Text nodes whose previous sibling isn't a Text node as + * well. I.e. consecutive Text nodes are counted as a single + * node. + */ + private static int countNodesWithoutConsecutiveTextNodes(NodeList l) { + int count = 0; + boolean lastNodeWasText = false; + final int length = l.getLength(); + for (int i = 0; i < length; i++) { + Node n = l.item(i); + if (!lastNodeWasText || n.getNodeType() != Node.TEXT_NODE) { + count++; + } + lastNodeWasText = n.getNodeType() == Node.TEXT_NODE; + } + return count; + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/RecursiveElementNameAndTextQualifier.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_RecursiveElementNameAndTextQualifier.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_RecursiveElementNameAndTextQualifier.java (rev 0) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_RecursiveElementNameAndTextQualifier.java 2008-03-14 15:48:26 UTC (rev 250) @@ -0,0 +1,173 @@ +/* +****************************************************************** +Copyright (c) 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. + +****************************************************************** +*/ + +package org.custommonkey.xmlunit.examples; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.ElementNameAndTextQualifier; +import org.custommonkey.xmlunit.ElementQualifier; +import org.custommonkey.xmlunit.XMLUnit; + +/** + * JUnit testcase for RecursiveElementNameAndTextQualifier with most + * tests copied from MultiLevelElementNameAndTextQualifier' test. + * @see test_Diff#testRepeatedElementNamesWithTextQualification() + */ +public class test_RecursiveElementNameAndTextQualifier extends TestCase { + private static final String TAG_NAME = "tagYoureIt"; + private static final String TAG_NAME2 = "tagYoureIt2"; + private static final String TEXT_A = "textA"; + private static final String TEXT_B = "textB"; + private Document document; + + // copy of ElementNameAndTextQualifier test + public void testSingleTextValue() throws Exception { + ElementQualifier qualifier = + new RecursiveElementNameAndTextQualifier(); + + Element control = document.createElement(TAG_NAME); + control.appendChild(document.createTextNode(TEXT_A)); + + Element test = document.createElement(TAG_NAME); + + assertFalse("control text not comparable to empty text", + qualifier.qualifyForComparison(control, test)); + + test.appendChild(document.createTextNode(TEXT_A)); + assertTrue("control textA comparable to test textA", + qualifier.qualifyForComparison(control, test)); + + test = document.createElement(TAG_NAME); + + test.appendChild(document.createTextNode(TEXT_B)); + assertFalse("control textA not comparable to test textB", + qualifier.qualifyForComparison(control, test)); + } + + // copy of ElementNameAndTextQualifier test + public void testMultipleTextValues() throws Exception { + ElementQualifier qualifier = + new RecursiveElementNameAndTextQualifier(); + + Element control = document.createElement(TAG_NAME); + control.appendChild(document.createTextNode(TEXT_A)); + control.appendChild(document.createTextNode(TEXT_B)); + + Element test = document.createElement(TAG_NAME); + test.appendChild(document.createTextNode(TEXT_A + TEXT_B)); + assertTrue("denormalised control text comparable to normalised test text", + qualifier.qualifyForComparison(control, test)); + } + + // three levels + public void testThreeLevels() throws Exception { + ElementQualifier qualifier = + new RecursiveElementNameAndTextQualifier(); + + Element control = document.createElement(TAG_NAME); + Element child = document.createElement(TAG_NAME2); + control.appendChild(child); + Element child2 = document.createElement(TAG_NAME); + child.appendChild(child2); + child2.appendChild(document.createTextNode(TEXT_B)); + + Element test = document.createElement(TAG_NAME); + child = document.createElement(TAG_NAME2); + test.appendChild(child); + child2 = document.createElement(TAG_NAME); + child.appendChild(child2); + child2.appendChild(document.createTextNode(TEXT_B)); + + assertTrue(qualifier.qualifyForComparison(control, test)); + } + + /** + * @see https://sourceforge.net/forum/forum.php?thread_id=1440169&forum_id=73274 + */ + public void testThread1440169() throws Exception { + String s1 = "<a><b><c>foo</c></b><b><c>bar</c></b></a>"; + String s2 = "<a><b><c>bar</c></b><b><c>foo</c></b></a>"; + Diff d = new Diff(s1, s2); + assertFalse(d.similar()); + + // reset + d = new Diff(s1, s2); + d.overrideElementQualifier(new ElementNameAndTextQualifier()); + assertFalse(d.similar()); + + // reset once again + d = new Diff(s1, s2); + d.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); + assertTrue(d.similar()); + + } + + public void testUserGuideExample() throws Exception { + String control = + "<table>\n" + + " <tr>\n" + + " <td>foo</td>\n" + + " </tr>\n" + + " <tr>\n" + + " <td>bar</td>\n" + + " </tr>\n" + + "</table>\n"; + String test = + "<table>\n" + + " <tr>\n" + + " <td>bar</td>\n" + + " </tr>\n" + + " <tr>\n" + + " <td>foo</td>\n" + + " </tr>\n" + + "</table>\n"; + + Diff d = new Diff(control, test); + d.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); + assertTrue(d.toString(), d.similar()); + } + + public void setUp() throws Exception { + document = XMLUnit.newControlParser().newDocument(); + } + +} Property changes on: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_RecursiveElementNameAndTextQualifier.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-26 05:02:08
|
Revision: 254 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=254&view=rev Author: bodewig Date: 2008-03-25 22:02:03 -0700 (Tue, 25 Mar 2008) Log Message: ----------- normalizeWhitespace trims text and this is by design Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 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-26 04:33:47 UTC (rev 253) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-03-26 05:02:03 UTC (rev 254) @@ -736,7 +736,8 @@ * * <p>Normalized in this context means that all whitespace is * replaced by the space character and adjacent whitespace - * characters are collapsed to a single space character.</p> + * characters are collapsed to a single space character. It will + * also trim the resulting character content on both ends.</p> * * <p>The default value is false.</p> * Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-26 04:33:47 UTC (rev 253) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-26 05:02:03 UTC (rev 254) @@ -671,7 +671,7 @@ public void testNormalizedWhitespace() throws Exception { String xml1 = "<foo>a = b;</foo>"; - String xml2 = "<foo>\r\n\ta = b; \r\n</foo>"; + String xml2 = "<foo>\r\n\ta =\tb; \r\n</foo>"; try { assertFalse(buildDiff(xml1, xml2).identical()); assertFalse(buildDiff(xml1, xml2).similar()); @@ -743,21 +743,4 @@ XMLUnit.setIgnoreWhitespace(false); } } - - /** - * @see https://sourceforge.net/forum/message.php?msg_id=4843316 - */ - public void XtestNormalizeWhiteSpaceDoesntStripLeadingSpace() - throws Exception { - String control = "<name>value</name>"; - String test = "<name> value</name>"; - XMLUnit.setNormalizeWhitespace(true); - try { - Diff diff = XMLUnit.compareXML(control, test); - assertFalse(diff.toString(), diff.similar()); - } finally { - XMLUnit.setNormalizeWhitespace(false); - } - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-03-26 20:59:58
|
Revision: 256 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=256&view=rev Author: bodewig Date: 2008-03-26 13:59:54 -0700 (Wed, 26 Mar 2008) Log Message: ----------- Make it possible to upgrade Differences from recoverable to non-recoverable Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2008-03-26 20:59:54 UTC (rev 256) @@ -81,6 +81,9 @@ case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: difference.setRecoverable(true); break; + case RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: + difference.setRecoverable(false); + break; default: throw new IllegalArgumentException(returnValue + " is not a defined " Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2008-03-26 20:59:54 UTC (rev 256) @@ -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 @@ -307,6 +307,10 @@ haltComparison = true; } break; + case RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: + identical = similar = false; + haltComparison = true; + break; default: throw new IllegalArgumentException(returnValue + " is not a defined DifferenceListener.RETURN_... value"); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceListener.java 2008-03-26 20:59:54 UTC (rev 256) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, 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 @@ -62,6 +62,12 @@ * interpreted as being similar. */ int RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR = 2; + /** + * 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; /** * Receive notification that 2 nodes are different. * @param difference a Difference instance as defined in {@link Modified: trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-26 20:49:12 UTC (rev 255) +++ trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java 2008-03-26 20:59:54 UTC (rev 256) @@ -744,4 +744,24 @@ } } + public void testUpgradingOfRecoverableDifference() throws Exception { + String control = "<foo:bar xmlns:foo='urn:foo'/>"; + String test = "<bar xmlns='urn:foo'/>"; + Diff diff = buildDiff(control, test); + assertFalse(diff.toString(), diff.identical()); + assertTrue(diff.toString(), diff.similar()); + + diff = buildDiff(control, test); + diff.overrideDifferenceListener(new DifferenceListener() { + public int differenceFound(Difference d) { + return RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; + } + public void skippedComparison(Node c, Node t) { + fail("skippedComparison shouldn't get invoked"); + } + }); + + assertFalse(diff.toString(), diff.identical()); + assertFalse(diff.toString(), diff.similar()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 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-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-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: <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: <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: <bo...@us...> - 2008-06-10 09:22:49
|
Revision: 272 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=272&view=rev Author: bodewig Date: 2008-06-10 02:22:52 -0700 (Tue, 10 Jun 2008) Log Message: ----------- fix version Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2008-06-10 09:18:42 UTC (rev 271) +++ trunk/xmlunit/build.xml 2008-06-10 09:22:52 UTC (rev 272) @@ -37,7 +37,7 @@ <property file="build.properties"/> <!-- Version --> - <property name="xmlunit.version" value="1.2alpha"/> + <property name="xmlunit.version" value="1.2"/> <!-- some locations --> <property name="src.dir" value="src"/> Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-06-10 09:18:42 UTC (rev 271) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-06-10 09:22:52 UTC (rev 272) @@ -558,7 +558,7 @@ * @return current version */ public static String getVersion() { - return "1.2alpha"; + return "1.2"; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-06-10 09:35:12
|
Revision: 274 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=274&view=rev Author: bodewig Date: 2008-06-10 02:35:15 -0700 (Tue, 10 Jun 2008) Log Message: ----------- bump version after tag Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2008-06-10 09:23:58 UTC (rev 273) +++ trunk/xmlunit/build.xml 2008-06-10 09:35:15 UTC (rev 274) @@ -37,7 +37,7 @@ <property file="build.properties"/> <!-- Version --> - <property name="xmlunit.version" value="1.2"/> + <property name="xmlunit.version" value="1.3alpha"/> <!-- some locations --> <property name="src.dir" value="src"/> Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-06-10 09:23:58 UTC (rev 273) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java 2008-06-10 09:35:15 UTC (rev 274) @@ -558,7 +558,7 @@ * @return current version */ public static String getVersion() { - return "1.2"; + return "1.3alpha"; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-06-10 13:48:05
|
Revision: 276 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=276&view=rev Author: bodewig Date: 2008-06-10 06:48:04 -0700 (Tue, 10 Jun 2008) Log Message: ----------- Add a maven-metadata.xml file Modified Paths: -------------- trunk/xmlunit/build.xml Added Paths: ----------- trunk/xmlunit/src/etc/xmlunit-maven-metadata.xml Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2008-06-10 13:41:44 UTC (rev 275) +++ trunk/xmlunit/build.xml 2008-06-10 13:48:04 UTC (rev 276) @@ -215,6 +215,7 @@ <fileset dir="${src.dir}/etc"> <include name="xmlunit.pom"/> <include name="xmlunit-ivy.xml"/> + <include name="xmlunit-maven-metadata.xml"/> </fileset> <mapper type="glob" from="xmlunit*" to="xmlunit-${xmlunit.version}*"/> <filterset> Added: trunk/xmlunit/src/etc/xmlunit-maven-metadata.xml =================================================================== --- trunk/xmlunit/src/etc/xmlunit-maven-metadata.xml (rev 0) +++ trunk/xmlunit/src/etc/xmlunit-maven-metadata.xml 2008-06-10 13:48:04 UTC (rev 276) @@ -0,0 +1,47 @@ +<?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. +--> +<metadata> + <groupId>@GROUP@</groupId> + <artifactId>@ARTIFACT@</artifactId> + <version>@VERSION@</version> + <versioning> + <versions> + <version>0.8</version> + <version>1.0</version> + <version>1.1</version> + <version>1.2</version> + <version>@VERSION@</version> + </versions> + </versioning> +</metadata> Property changes on: trunk/xmlunit/src/etc/xmlunit-maven-metadata.xml ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |