From: <bo...@us...> - 2010-08-31 15:19:36
|
Revision: 446 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=446&view=rev Author: bodewig Date: 2010-08-31 15:19:27 +0000 (Tue, 31 Aug 2010) Log Message: ----------- extract common interface of DifferenceEngine and NewDifferenceEngine Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java Added Paths: ----------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngineContract.java Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java 2010-08-31 15:08:26 UTC (rev 445) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java 2010-08-31 15:19:27 UTC (rev 446) @@ -80,7 +80,7 @@ private boolean compared = false; private boolean haltComparison = false; private StringBuffer messages; - private DifferenceEngine differenceEngine; + private DifferenceEngineContract differenceEngine; private DifferenceListener differenceListenerDelegate; private ElementQualifier elementQualifierDelegate; private MatchTracker matchTrackerDelegate; @@ -106,7 +106,7 @@ * Construct a Diff that compares the XML in two Documents */ public Diff(Document controlDoc, Document testDoc) { - this(controlDoc, testDoc, (DifferenceEngine) null); + this(controlDoc, testDoc, (DifferenceEngineContract) null); } /** @@ -141,7 +141,7 @@ * DifferenceEngine */ public Diff(Document controlDoc, Document testDoc, - DifferenceEngine comparator) { + DifferenceEngineContract comparator) { this(controlDoc, testDoc, comparator, new ElementNameQualifier()); } @@ -150,7 +150,7 @@ * DifferenceEngine and ElementQualifier */ public Diff(Document controlDoc, Document testDoc, - DifferenceEngine comparator, + DifferenceEngineContract comparator, ElementQualifier elementQualifier) { this.controlDoc = getManipulatedDocument(controlDoc); this.testDoc = getManipulatedDocument(testDoc); @@ -413,7 +413,7 @@ * Lazily initializes the difference engine if it hasn't been set * via a constructor. */ - private DifferenceEngine getDifferenceEngine() { + private DifferenceEngineContract getDifferenceEngine() { return differenceEngine == null ? new DifferenceEngine(this, matchTrackerDelegate) : differenceEngine; Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java 2010-08-31 15:08:26 UTC (rev 445) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngine.java 2010-08-31 15:19:27 UTC (rev 446) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2009, Jeff Martin, Tim Bacon +Copyright (c) 2001-2010, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -65,7 +65,9 @@ * sourceforge.net</a> * @see DifferenceListener#differenceFound(Difference) */ -public class DifferenceEngine implements DifferenceConstants { +public class DifferenceEngine + implements DifferenceConstants, DifferenceEngineContract { + private static final String NULL_NODE = "null"; private static final String NOT_NULL_NODE = "not null"; private static final String ATTRIBUTE_ABSENT = "[attribute absent]"; Added: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngineContract.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngineContract.java (rev 0) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngineContract.java 2010-08-31 15:19:27 UTC (rev 446) @@ -0,0 +1,65 @@ +/* +****************************************************************** +Copyright (c) 2010, 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; + +import org.w3c.dom.Node; + +/** + * The pieces of DifferenceEngine's API used by Diff. + * + * <p>This interface allows Diff to switch between {@link + * DifferenceEngine} and {@link NewDifferenceEngine} at will.</p> + */ +public interface DifferenceEngineContract { + /** + * @param matchTracker the instance that is notified on each + * successful match. May be null. + */ + void setMatchTracker(MatchTracker matchTracker); + /** + * Entry point for Node comparison testing. + * @param control Control XML to compare + * @param test Test XML to compare + * @param listener Notified of any {@link Difference differences} detected + * during node comparison testing + * @param elementQualifier Used to determine which elements qualify for + * comparison e.g. when a node has repeated child elements that may occur + * in any sequence and that sequence is not considered important. + */ + void compare(Node control, Node test, DifferenceListener listener, + ElementQualifier elementQualifier); +} \ No newline at end of file Property changes on: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEngineContract.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java 2010-08-31 15:08:26 UTC (rev 445) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java 2010-08-31 15:19:27 UTC (rev 446) @@ -64,7 +64,9 @@ * sourceforge.net</a> * @see DifferenceListener#differenceFound(Difference) */ -public class NewDifferenceEngine implements DifferenceConstants { +public class NewDifferenceEngine + implements DifferenceConstants, DifferenceEngineContract { + private static final Integer ZERO = Integer.valueOf(0); private final ComparisonController controller; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-09-02 10:59:49
|
Revision: 452 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=452&view=rev Author: bodewig Date: 2010-09-02 10:59:43 +0000 (Thu, 02 Sep 2010) Log Message: ----------- handle CDATA/Text comparisons inside NewDifferenceEngine like it is done in legacy's DifferenceEngine - i.e. hide the difference from listeners completely Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java 2010-08-31 16:32:41 UTC (rev 451) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java 2010-09-02 10:59:43 UTC (rev 452) @@ -42,6 +42,7 @@ import net.sf.xmlunit.diff.Comparison; import net.sf.xmlunit.diff.ComparisonListener; import net.sf.xmlunit.diff.ComparisonResult; +import net.sf.xmlunit.diff.ComparisonType; import net.sf.xmlunit.diff.DOMDifferenceEngine; import net.sf.xmlunit.diff.DifferenceEvaluator; import net.sf.xmlunit.diff.DifferenceEvaluators; @@ -292,6 +293,31 @@ } } + private static final Short TEXT_TYPE = Short.valueOf(Node.TEXT_NODE); + private static final Short CDATA_TYPE = + Short.valueOf(Node.CDATA_SECTION_NODE); + + private static boolean swallowComparison(Comparison comparison, + ComparisonResult outcome) { + if (outcome == ComparisonResult.EQUAL) { + return true; + } + if (XMLUnit.getIgnoreDiffBetweenTextAndCDATA() + && comparison.getType() == ComparisonType.NODE_TYPE) { + return ( + TEXT_TYPE.equals(comparison.getControlDetails().getValue()) + || + CDATA_TYPE.equals(comparison.getControlDetails().getValue()) + ) + && ( + TEXT_TYPE.equals(comparison.getTestDetails().getValue()) + || + CDATA_TYPE.equals(comparison.getTestDetails().getValue()) + ); + } + return false; + } + public static class ComparisonController2DifferenceEvaluator implements DifferenceEvaluator { private final ComparisonController cc; @@ -301,13 +327,14 @@ public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) { - if (outcome != ComparisonResult.EQUAL) { + if (!swallowComparison(comparison, outcome)) { Difference diff = toDifference(comparison); if (diff != null && cc.haltComparison(diff)) { return ComparisonResult.CRITICAL; } + return outcome; } - return outcome; + return ComparisonResult.EQUAL; } } @@ -336,7 +363,7 @@ public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) { - if (outcome != ComparisonResult.EQUAL) { + if (!swallowComparison(comparison, outcome)) { Difference diff = toDifference(comparison); if (diff != null) { switch (dl.differenceFound(diff)) { @@ -351,8 +378,9 @@ return ComparisonResult.DIFFERENT; } } + return outcome; } - return outcome; + return ComparisonResult.EQUAL; } } } Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java 2010-08-31 16:32:41 UTC (rev 451) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/XMLUnit.java 2010-09-02 10:59:43 UTC (rev 452) @@ -75,7 +75,7 @@ private static EntityResolver testEntityResolver = null; private static EntityResolver controlEntityResolver = null; private static NamespaceContext namespaceContext = null; - private static Boolean ignoreDiffBetweenTextAndCDATA = null; + private static boolean ignoreDiffBetweenTextAndCDATA = false; private static boolean ignoreComments = false; private static boolean normalize = false; private static boolean normalizeWhitespace = false; @@ -685,7 +685,7 @@ * document.</p> */ public static void setIgnoreDiffBetweenTextAndCDATA(boolean b) { - ignoreDiffBetweenTextAndCDATA = Boolean.valueOf(b); + ignoreDiffBetweenTextAndCDATA = b; getControlDocumentBuilderFactory().setCoalescing(b); getTestDocumentBuilderFactory().setCoalescing(b); } @@ -696,21 +696,10 @@ * @return false by default */ public static boolean getIgnoreDiffBetweenTextAndCDATA() { - return ignoreDiffBetweenTextAndCDATA == null ? false - : ignoreDiffBetweenTextAndCDATA.booleanValue(); + return ignoreDiffBetweenTextAndCDATA; } /** - * Whether CDATA sections and Text nodes should be considered the same. - * - * @return true by default - */ - public static boolean getExplicitIgnoreDiffBetweenTextAndCDATA() { - return ignoreDiffBetweenTextAndCDATA == null ? true - : ignoreDiffBetweenTextAndCDATA.booleanValue(); - } - - /** * Whether comments should be ignored. * * <p>The default value is false</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-09-13 10:41:18
|
Revision: 467 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=467&view=rev Author: bodewig Date: 2010-09-13 10:41:11 +0000 (Mon, 13 Sep 2010) Log Message: ----------- tear evaluation of difference and differencelistener apart in legacy difference engine Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java Added Paths: ----------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEvaluator.java Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java 2010-09-13 09:49:28 UTC (rev 466) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/Diff.java 2010-09-13 10:41:11 UTC (rev 467) @@ -72,7 +72,7 @@ * <br />Examples and more at <a href="http://xmlunit.sourceforge.net"/>xmlunit.sourceforge.net</a> */ public class Diff - implements DifferenceListener, ComparisonController { + implements DifferenceEvaluator, DifferenceListener, ComparisonController { private final Document controlDoc; private final Document testDoc; private boolean similar = true; @@ -287,10 +287,7 @@ * Always RETURN_ACCEPT_DIFFERENCE if the call is not delegated. */ public int differenceFound(Difference difference) { - int returnValue = RETURN_ACCEPT_DIFFERENCE; - if (differenceListenerDelegate != null) { - returnValue = differenceListenerDelegate.differenceFound(difference); - } + int returnValue = evaluate(difference); switch (returnValue) { case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: @@ -325,6 +322,14 @@ return returnValue; } + public int evaluate(Difference difference) { + int returnValue = RETURN_ACCEPT_DIFFERENCE; + if (differenceListenerDelegate != null) { + returnValue = differenceListenerDelegate.differenceFound(difference); + } + return returnValue; + } + /** * DifferenceListener implementation. * If the {@link Diff#overrideDifferenceListener overrideDifferenceListener} @@ -422,6 +427,8 @@ && !XMLUnit.getNormalizeWhitespace() && + differenceListenerDelegate == null + && !usesUnknownElementQualifier() ) { return new NewDifferenceEngine(this, matchTrackerDelegate); Added: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEvaluator.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEvaluator.java (rev 0) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEvaluator.java 2010-09-13 10:41:11 UTC (rev 467) @@ -0,0 +1,55 @@ +/* +****************************************************************** +Copyright (c) 2010, 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; + +/** + * Contains the pure evaluation logic of DifferenceListener + */ +public interface DifferenceEvaluator { + /** + * Receive notification of a difference and decides whether 2 + * nodes are different. + * @param difference a Difference instance as defined in {@link + * DifferenceConstants DifferenceConstants} describing the cause + * of the difference and containing the detail of the nodes that + * differ + * @return int one of the RETURN_... constants of + * DifferenceListener describing how this difference was + * interpreted + */ + int evaluate(Difference difference); +} Property changes on: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/DifferenceEvaluator.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java 2010-09-13 09:49:28 UTC (rev 466) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/NewDifferenceEngine.java 2010-09-13 10:41:11 UTC (rev 467) @@ -45,7 +45,6 @@ import net.sf.xmlunit.diff.ComparisonResult; import net.sf.xmlunit.diff.ComparisonType; import net.sf.xmlunit.diff.DOMDifferenceEngine; -import net.sf.xmlunit.diff.DifferenceEvaluator; import net.sf.xmlunit.diff.DifferenceEvaluators; import net.sf.xmlunit.diff.ElementSelector; import net.sf.xmlunit.input.CommentLessSource; @@ -123,7 +122,7 @@ ElementQualifier elementQualifier) { DOMDifferenceEngine engine = new DOMDifferenceEngine(); - IsBetweenDocumentNodeAndRootElement checkPrelude = + final IsBetweenDocumentNodeAndRootElement checkPrelude = new IsBetweenDocumentNodeAndRootElement(); engine.addComparisonListener(checkPrelude); @@ -132,19 +131,44 @@ .addMatchListener(new MatchTracker2ComparisonListener(matchTracker)); } - DifferenceEvaluator controllerAsEvaluator = - new ComparisonController2DifferenceEvaluator(controller, - checkPrelude); + net.sf.xmlunit.diff.DifferenceEvaluator controllerAsEvaluator = + new ComparisonController2DifferenceEvaluator(controller); + net.sf.xmlunit.diff.DifferenceEvaluator ev = null; if (listener != null) { - DifferenceEvaluator l = - new DifferenceListener2DifferenceEvaluator(listener, checkPrelude); - engine - .setDifferenceEvaluator(DifferenceEvaluators.first(l, - controllerAsEvaluator)); + net.sf.xmlunit.diff.DifferenceEvaluator e = null; + if (listener instanceof org.custommonkey.xmlunit.DifferenceEvaluator) { + e = new DifferenceEvaluatorAdapter((DifferenceEvaluator) listener); + final ComparisonListener l = new DifferenceListener2ComparisonListener(listener); + engine + .addDifferenceListener(new ComparisonListener() { + public void comparisonPerformed(Comparison comparison, + ComparisonResult outcome) { + if (!swallowComparison(comparison, outcome, + checkPrelude)) { + l.comparisonPerformed(comparison, outcome); + } + } + }); + } else { + e = new DifferenceListener2DifferenceEvaluator(listener); + } + ev = DifferenceEvaluators.first(e, controllerAsEvaluator); } else { - engine - .setDifferenceEvaluator(controllerAsEvaluator); + ev = controllerAsEvaluator; } + final net.sf.xmlunit.diff.DifferenceEvaluator evaluator = ev; + engine + .setDifferenceEvaluator(new net.sf.xmlunit.diff.DifferenceEvaluator() { + public ComparisonResult evaluate(Comparison comparison, + ComparisonResult outcome) { + if (!swallowComparison(comparison, outcome, + checkPrelude)) { + return evaluator.evaluate(comparison, outcome); + } + return outcome; + } + }); + if (elementQualifier != null) { engine .setElementSelector(new ElementQualifier2ElementSelector(elementQualifier)); @@ -345,25 +369,46 @@ } public static class ComparisonController2DifferenceEvaluator - implements DifferenceEvaluator { + implements net.sf.xmlunit.diff.DifferenceEvaluator { private final ComparisonController cc; - private final IsBetweenDocumentNodeAndRootElement checkPrelude; - public ComparisonController2DifferenceEvaluator(ComparisonController c, - IsBetweenDocumentNodeAndRootElement checkPrelude) { + public ComparisonController2DifferenceEvaluator(ComparisonController c) { cc = c; - this.checkPrelude = checkPrelude; } public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) { - if (!swallowComparison(comparison, outcome, checkPrelude)) { - Difference diff = toDifference(comparison); - if (diff != null && cc.haltComparison(diff)) { - return ComparisonResult.CRITICAL; + Difference diff = toDifference(comparison); + if (diff != null && cc.haltComparison(diff)) { + return ComparisonResult.CRITICAL; + } + return outcome; + } + } + + public static class DifferenceEvaluatorAdapter + implements net.sf.xmlunit.diff.DifferenceEvaluator { + private final DifferenceEvaluator de; + public DifferenceEvaluatorAdapter(DifferenceEvaluator d) { + de = d; + } + + public ComparisonResult evaluate(Comparison comparison, + ComparisonResult outcome) { + Difference diff = toDifference(comparison); + if (diff != null) { + switch (de.evaluate(diff)) { + case DifferenceListener + .RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: + return ComparisonResult.EQUAL; + case DifferenceListener + .RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: + return ComparisonResult.SIMILAR; + case DifferenceListener + .RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: + return ComparisonResult.DIFFERENT; } - return outcome; } - return ComparisonResult.EQUAL; + return outcome; } } @@ -383,36 +428,30 @@ } public static class DifferenceListener2DifferenceEvaluator - implements DifferenceEvaluator { + implements net.sf.xmlunit.diff.DifferenceEvaluator { private final DifferenceListener dl; - private final IsBetweenDocumentNodeAndRootElement checkPrelude; - public DifferenceListener2DifferenceEvaluator(DifferenceListener dl, - IsBetweenDocumentNodeAndRootElement checkPrelude) { + public DifferenceListener2DifferenceEvaluator(DifferenceListener dl) { this.dl = dl; - this.checkPrelude = checkPrelude; } public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) { - if (!swallowComparison(comparison, outcome, checkPrelude)) { - Difference diff = toDifference(comparison); - if (diff != null) { - switch (dl.differenceFound(diff)) { - case DifferenceListener - .RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: - return ComparisonResult.EQUAL; - case DifferenceListener - .RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: - return ComparisonResult.SIMILAR; - case DifferenceListener - .RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: - return ComparisonResult.DIFFERENT; - } + Difference diff = toDifference(comparison); + if (diff != null) { + switch (dl.differenceFound(diff)) { + case DifferenceListener + .RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: + return ComparisonResult.EQUAL; + case DifferenceListener + .RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: + return ComparisonResult.SIMILAR; + case DifferenceListener + .RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT: + return ComparisonResult.DIFFERENT; } - return outcome; } - return ComparisonResult.EQUAL; + return outcome; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |