From: <bo...@us...> - 2010-08-13 11:54:20
|
Revision: 424 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=424&view=rev Author: bodewig Date: 2010-08-13 11:54:14 +0000 (Fri, 13 Aug 2010) Log Message: ----------- don't tie the DifferenceEngine's interface to DOM Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/AbstractDifferenceEngine.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluators.java trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs trunk/xmlunit/src/main/net-core/diff/Comparison.cs trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/AbstractDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/AbstractDifferenceEngine.java 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/AbstractDifferenceEngine.java 2010-08-13 11:54:14 UTC (rev 424) @@ -74,8 +74,8 @@ * listeners and returns the outcome. */ protected final ComparisonResult compare(Comparison comp) { - Object controlValue = comp.getControlNodeDetails().getValue(); - Object testValue = comp.getTestNodeDetails().getValue(); + Object controlValue = comp.getControlDetails().getValue(); + Object testValue = comp.getTestDetails().getValue(); boolean equal = controlValue == null ? testValue == null : controlValue.equals(testValue); ComparisonResult initial = Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java 2010-08-13 11:54:14 UTC (rev 424) @@ -13,37 +13,36 @@ */ package net.sf.xmlunit.diff; -import org.w3c.dom.Node; - /** * Details of a single comparison XMLUnit has performed. */ public class Comparison { /** - * The details of a Node that took part in the comparision. + * The details of a target (usually some representation of an XML + * Node) that took part in the comparison. */ public static class Detail { - private final Node node; + private final Object target; private final String xpath; private final Object value; - private Detail(Node n, String x, Object v) { - node = n; + private Detail(Object n, String x, Object v) { + target = n; xpath = x; value = v; } /** - * The actual Node. + * The actual target. */ - public Node getNode() { return node; } + public Object getTarget() { return target; } /** - * XPath leading to the Node. + * XPath leading to the target. */ public String getXPath() { return xpath; } /** - * The value for comparision found at the current node. + * The value for comparison found at the current target. */ public Object getValue() { return value; } } @@ -51,32 +50,32 @@ private final Detail control, test; private final ComparisonType type; - public Comparison(ComparisonType t, Node controlNode, + public Comparison(ComparisonType t, Object controlTarget, String controlXPath, Object controlValue, - Node testNode, String testXPath, Object testValue) { + Object testTarget, String testXPath, Object testValue) { type = t; - control = new Detail(controlNode, controlXPath, controlValue); - test = new Detail(testNode, testXPath, testValue); + control = new Detail(controlTarget, controlXPath, controlValue); + test = new Detail(testTarget, testXPath, testValue); } /** - * The kind of comparision performed. + * The kind of comparison performed. */ public ComparisonType getType() { return type; } /** - * Details of the control node. + * Details of the control target. */ - public Detail getControlNodeDetails() { + public Detail getControlDetails() { return control; } /** - * Details of the test node. + * Details of the test target. */ - public Detail getTestNodeDetails() { + public Detail getTestDetails() { return test; } Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluators.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluators.java 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluators.java 2010-08-13 11:54:14 UTC (rev 424) @@ -48,9 +48,9 @@ switch (comparison.getType()) { case NODE_TYPE: Short control = (Short) comparison - .getControlNodeDetails().getValue(); + .getControlDetails().getValue(); Short test = (Short) comparison - .getTestNodeDetails().getValue(); + .getTestDetails().getValue(); if ((control.equals(TEXT) && test.equals(CDATA)) || (control.equals(CDATA) && test.equals(TEXT))) { Modified: trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs 2010-08-13 11:54:14 UTC (rev 424) @@ -59,8 +59,8 @@ /// listeners and returns the outcome. /// </summary> protected internal ComparisonResult Compare(Comparison comp) { - object controlValue = comp.ControlNodeDetails.Value; - object testValue = comp.TestNodeDetails.Value; + object controlValue = comp.ControlDetails.Value; + object testValue = comp.TestDetails.Value; bool equal = controlValue == null ? testValue == null : controlValue.Equals(testValue); ComparisonResult initial = Modified: trunk/xmlunit/src/main/net-core/diff/Comparison.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/Comparison.cs 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/main/net-core/diff/Comparison.cs 2010-08-13 11:54:14 UTC (rev 424) @@ -12,8 +12,6 @@ limitations under the License. */ -using System.Xml; - namespace net.sf.xmlunit.diff { /// <summary> @@ -22,29 +20,30 @@ public class Comparison { /// <summary> - /// The details of a Node that took part in the comparision. + /// The details of a target (usually a representation of an + /// XML node) that took part in the comparison. /// </summary> public sealed class Detail { - private readonly XmlNode node; + private readonly object target; private readonly string xpath; private readonly object value; - internal Detail(XmlNode n, string x, object v) { - node = n; + internal Detail(object t, string x, object v) { + target = t; xpath = x; value = v; } /// <summary> - /// The actual Node. + /// The actual target. /// </summary> - public XmlNode Node { get { return node; } } + public object Target { get { return target; } } /// <summary> - /// XPath leading to the Node. + /// XPath leading to the target. /// </summary> public string XPath { get { return xpath; } } /// <summary> - /// The value for comparision found at the current node. + /// The value for comparison found at the current target. /// </summary> public object Value { get { return value; } } } @@ -52,17 +51,17 @@ private readonly Detail control, test; private readonly ComparisonType type; - public Comparison(ComparisonType t, XmlNode controlNode, + public Comparison(ComparisonType t, object controlTarget, string controlXPath, object controlValue, - XmlNode testNode, string testXPath, + object testTarget, string testXPath, object testValue) { type = t; - control = new Detail(controlNode, controlXPath, controlValue); - test = new Detail(testNode, testXPath, testValue); + control = new Detail(controlTarget, controlXPath, controlValue); + test = new Detail(testTarget, testXPath, testValue); } /// <summary> - /// The kind of comparision performed. + /// The kind of comparison performed. /// </summary> public ComparisonType Type { get { @@ -71,18 +70,18 @@ } /// <summary> - /// Details of the control node. + /// Details of the control target. /// </summary> - public Detail ControlNodeDetails { + public Detail ControlDetails { get { return control; } } /// <summary> - /// Details of the test node. + /// Details of the test target. /// </summary> - public Detail TestNodeDetails { + public Detail TestDetails { get { return test; } Modified: trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs 2010-08-13 11:54:14 UTC (rev 424) @@ -41,9 +41,9 @@ switch (comparison.Type) { case ComparisonType.NODE_TYPE: XmlNodeType control = - (XmlNodeType) comparison.ControlNodeDetails.Value; + (XmlNodeType) comparison.ControlDetails.Value; XmlNodeType test = - (XmlNodeType) comparison.TestNodeDetails.Value; + (XmlNodeType) comparison.TestDetails.Value; if ((control == XmlNodeType.Text && test == XmlNodeType.CDATA) || (control == XmlNodeType.CDATA && test == XmlNodeType.Text) Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java 2010-08-13 11:54:14 UTC (rev 424) @@ -152,11 +152,11 @@ if (comparison.getType() == ComparisonType.NODE_TYPE) { if (outcome == ComparisonResult.EQUAL || ( - comparison.getControlNodeDetails() - .getNode() instanceof CharacterData + comparison.getControlDetails() + .getTarget() instanceof CharacterData && - comparison.getTestNodeDetails() - .getNode() instanceof CharacterData + comparison.getTestDetails() + .getTarget() instanceof CharacterData )) { return ComparisonResult.EQUAL; } @@ -429,9 +429,9 @@ ComparisonResult outcome) { fail("unexpected Comparison of type " + comparison.getType() + " with outcome " + outcome + " and values '" - + comparison.getControlNodeDetails().getValue() + + comparison.getControlDetails().getValue() + "' and '" - + comparison.getTestNodeDetails().getValue() + "'"); + + comparison.getTestDetails().getValue() + "'"); } }); e1.setAttributeNS("urn:xmlunit:test", "attr1", "value1"); Modified: trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs 2010-08-10 16:12:49 UTC (rev 423) +++ trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs 2010-08-13 11:54:14 UTC (rev 424) @@ -143,11 +143,9 @@ if (comparison.Type == ComparisonType.NODE_TYPE) { if (outcome == ComparisonResult.EQUAL || ( - comparison.ControlNodeDetails.Node - is XmlCharacterData + comparison.ControlDetails.Target is XmlCharacterData && - comparison.TestNodeDetails.Node is XmlCharacterData - )) { + comparison.TestDetails.Target is XmlCharacterData)) { return ComparisonResult.EQUAL; } } @@ -423,9 +421,9 @@ ComparisonResult r) { Assert.Fail("unexpected Comparison of type " + comp.Type + " with outcome " + r + " and values '" - + comp.ControlNodeDetails.Value + + comp.ControlDetails.Value + "' and '" - + comp.TestNodeDetails.Value + "'"); + + comp.TestDetails.Value + "'"); }; d.DifferenceEvaluator = DifferenceEvaluators.DefaultStopWhenDifferent; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |