From: <bo...@us...> - 2010-05-03 16:08:25
|
Revision: 378 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=378&view=rev Author: bodewig Date: 2010-05-03 16:08:17 +0000 (Mon, 03 May 2010) Log Message: ----------- preliminary interfaces for difference engine Added Paths: ----------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonListener.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonResult.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonType.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluator.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ElementSelector.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/IDifferenceEngine.java trunk/xmlunit/src/main/net-core/diff/ trunk/xmlunit/src/main/net-core/diff/Comparison.cs trunk/xmlunit/src/main/net-core/diff/ComparisonListener.cs trunk/xmlunit/src/main/net-core/diff/ComparisonResult.cs trunk/xmlunit/src/main/net-core/diff/ComparisonType.cs trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluator.cs trunk/xmlunit/src/main/net-core/diff/ElementSelector.cs trunk/xmlunit/src/main/net-core/diff/IDifferenceEngine.cs Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,83 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +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. + */ + public static class Detail { + private final Node node; + private final String xpath; + private final Object value; + + private Detail(Node n, String x, Object v) { + node = n; + xpath = x; + value = v; + } + + /** + * The actual Node. + */ + public Node getNode() { return node; } + /** + * XPath leading to the Node. + */ + public String getXPath() { return xpath; } + /** + * The value for comparision found at the current node. + */ + public Object getValue() { return value; } + } + + private final Detail control, test; + private final ComparisonType type; + + public Comparison(ComparisonType t, Node controlNode, + String controlXPath, Object controlValue, + Node testNode, String testXPath, Object testValue) { + type = t; + control = new Detail(controlNode, controlXPath, controlValue); + test = new Detail(testNode, testXPath, testValue); + } + + /** + * The kind of comparision performed. + */ + public ComparisonType getType() { + return type; + } + + /** + * Details of the control node. + */ + public Detail getControlNodeDetails() { + return control; + } + + /** + * Details of the test node. + */ + public Detail getTestNodeDetails() { + return test; + } + +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/Comparison.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonListener.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonListener.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonListener.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,21 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.diff; + +/** + * Is notified of comparisions and their results. + */ +public interface ComparisonListener { + void comparisonPerformed(Comparison comparison, ComparisonResult outcome); +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonListener.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonResult.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonResult.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonResult.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,40 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.diff; + +/** + * The possible outcomes of a comparision. + */ +public enum ComparisonResult { + /** + * The two nodes are the same for the sake of this comparison. + */ + EQUAL, + /** + * The two nodes are different but similar enough to satisfy a + * weak equality constraint + */ + SIMILAR, + /** + * The two nodes are different. + */ + DIFFERENT, + /** + * The two nodes are different and comparison should stop + * immediately. + * + * <p>Only used as a return type by {@link DifferenceEvaluator} + */ + CRITICAL, +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonResult.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonType.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonType.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonType.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,120 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.diff; + +/** + * The kinds of comparisons XMLUnit performs. + */ +public enum ComparisonType { + /** + * Do both documents have a DOCTYPE (or neither of each)? + */ + HAS_DOCTYPE_DECLARATION, + /** + * If the documents both have DOCTYPEs, compare the names. + */ + DOCTYPE_NAME, + /** + * If the documents both have DOCTYPEs, compare the PUBLIC + * identifiers. + */ + DOCTYPE_PUBLIC, + /** + * If the documents both have DOCTYPEs, compare the SYSTEM + * identifiers. + */ + DOCTYPE_SYSTEM, + + /** + * Check whether both documents provide the same values for + * xsi:schemaLocation (may even be null). + */ + SCHEMA_LOCATION, + /** + * Check whether both documents provide the same values for + * xsi:noNamspaceSchemaLocation (may even be null). + */ + NO_NAMESPACE_SCHEMA_LOCATION, + + /** + * Compare the node types. + */ + NODE_TYPE, + + /** + * Compare the node's namespace prefixes. + */ + NAMESPACE_PREFIX, + /** + * Compare the node's namespace URIs. + */ + NAMESPACE_URI, + + /** + * Compare content of CDATA sections. + */ + CDATA_VALUE, + /** + * Compare content of comments. + */ + COMMENT_VALUE, + /** + * Compare content of text nodes. + */ + TEXT_VALUE, + /** + * Compare targets of processing instructions. + */ + PROCESSING_INSTRUCTION_TARGET, + /** + * Compare data of processing instructions. + */ + PROCESSING_INSTRUCTION_DATA, + + /** + * Compare element names. + */ + ELEMENT_TAG_NAME, + /** + * Compare explicit/implicit status of attributes. + */ + ATTR_VALUE_EXPLICITLY_SPECIFIED, + /** + * Compare number of attributes. + */ + ELEMENT_NUM_ATTRIBUTES, + /** + * Compare attribute's value. + */ + ATTR_VALUE, + /** + * Compare number of child nodes. + */ + CHILD_NODELIST_LENGTH, + /** + * Compare order of child nodes. + */ + CHILD_NODELIST_SEQUENCE, + + /** + * Search for a child node matching a specific child node of the + * other node. + */ + CHILD_LOOKUP, + /** + * Search for an atribute with a name matching a specific + * attribute of the other node. + */ + ATTR_NAME_LOOKUP, +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ComparisonType.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluator.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluator.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluator.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,28 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.diff; + +/** + * May decide to up- or downgrade the severity of a difference and + * even to stop the comparison completely. + */ +public interface DifferenceEvaluator { + /** + * May alter the outcome of a comparison. + * + * @return the new result of the comparison, should return {@link + * ComaprisonResult#CRITICAL} to stop the comparison completely. + */ + ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome); +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluator.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ElementSelector.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ElementSelector.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ElementSelector.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,27 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.diff; + +import org.w3c.dom.Element; + +/** + * Strategy for selecting matching elements. + */ +public interface ElementSelector { + /** + * Determine whether the two elements from the control and test + * XML can be compared. + */ + boolean canBeCompared(Element controlElement, Element testElement); +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/ElementSelector.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/IDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/IDifferenceEngine.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/IDifferenceEngine.java 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,54 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit.diff; + +import javax.xml.transform.Source; + +/** + * XMLUnit's difference engine. + */ +public interface IDifferenceEngine { + /** + * Registers a listener that is notified of each comparison. + */ + void addComparisonListener(ComparisonListener l); + + /** + * Registers a listener that is notified of each comparison with + * outcome {@link ComparisonResult#EQUAL}. + */ + void addMatchListener(ComparisonListener l); + + /** + * Registers a listener that is notified of each comparison with + * outcome other than {@link ComparisonResult#EQUAL}. + */ + void addDifferenceListener(ComparisonListener l); + + /** + * Sets the strategy for selecting elements to compare. + */ + void setElementSelector(ElementSelector s); + + /** + * Determines whether the comparison should stop after given + * difference has been found. + */ + void setDifferenceEvaluator(DifferenceEvaluator e); + + /** + * Compares two pieces of XML and invokes the registered listeners. + */ + void compare(Source control, Source test); +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/IDifferenceEngine.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/Comparison.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/Comparison.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/Comparison.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,92 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Xml; + +namespace net.sf.xmlunit.diff { + + /// <summary> + /// Details of a single comparison XMLUnit has performed. + /// </summary> + public class Comparison { + + /// <summary> + /// The details of a Node that took part in the comparision. + /// </summary> + public sealed class Detail { + private readonly XmlNode node; + private readonly string xpath; + private readonly object value; + + internal Detail(XmlNode n, string x, object v) { + node = n; + xpath = x; + value = v; + } + + /// <summary> + /// The actual Node. + /// </summary> + public XmlNode Node { get { return node; } } + /// <summary> + /// XPath leading to the Node. + /// </summary> + public string XPath { get { return xpath; } } + /// <summary> + /// The value for comparision found at the current node. + /// </summary> + public object Value { get { return value; } } + } + + private readonly Detail control, test; + private readonly ComparisonType type; + + public Comparison(ComparisonType t, XmlNode controlNode, + string controlXPath, object controlValue, + XmlNode testNode, string testXPath, + object testValue) { + type = t; + control = new Detail(controlNode, controlXPath, controlValue); + test = new Detail(testNode, testXPath, testValue); + } + + /// <summary> + /// The kind of comparision performed. + /// </summary> + public ComparisonType Type { + get { + return type; + } + } + + /// <summary> + /// Details of the control node. + /// </summary> + public Detail ControlNodeDetails { + get { + return control; + } + } + + /// <summary> + /// Details of the test node. + /// </summary> + public Detail TestNodeDetails { + get { + return test; + } + } + + } +} Property changes on: trunk/xmlunit/src/main/net-core/diff/Comparison.cs ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/ComparisonListener.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/ComparisonListener.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/ComparisonListener.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,21 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +namespace net.sf.xmlunit.diff { + /// <summary> + /// Is notified of comparisions and their results. + /// </summary> + public delegate void ComparisonListener(Comparison comparison, + ComparisonResult outcome); +} Property changes on: trunk/xmlunit/src/main/net-core/diff/ComparisonListener.cs ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/ComparisonResult.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/ComparisonResult.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/ComparisonResult.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,41 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +namespace net.sf.xmlunit.diff { + + /// <summary> + /// The possible outcomes of a comparision. + /// </summary> + public enum ComparisonResult { + /// <summary> + /// The two nodes are the same for the sake of this comparison. + /// </summary> + EQUAL, + /// <summary> + /// The two nodes are different but similar enough to satisfy a + /// weak equality constraint + /// </summary> + SIMILAR, + /// <summary> + /// The two nodes are different. + /// </summary> + DIFFERENT, + /// <summary> + /// The two nodes are different and comparison should stop + /// immediately. + /// </summary> + /// <remarks>Only used as a return type by {@link DifferenceEvaluator}</remarks> + CRITICAL, + } +} Property changes on: trunk/xmlunit/src/main/net-core/diff/ComparisonResult.cs ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/ComparisonType.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/ComparisonType.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/ComparisonType.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,122 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +namespace net.sf.xmlunit.diff { + + /// <summary> + /// The kinds of comparisons XMLUnit performs. + /// </summary> + public enum ComparisonType { + /// <summary> + /// Do both documents have a DOCTYPE (or neither of each)? + /// </summary> + HAS_DOCTYPE_DECLARATION, + /// <summary> + /// If the documents both have DOCTYPEs, compare the names. + /// </summary> + DOCTYPE_NAME, + /// <summary> + /// If the documents both have DOCTYPEs, compare the PUBLIC + /// identifiers. + /// </summary> + DOCTYPE_PUBLIC, + /// <summary> + /// If the documents both have DOCTYPEs, compare the SYSTEM + /// identifiers. + /// </summary> + DOCTYPE_SYSTEM, + + /// <summary> + /// Check whether both documents provide the same values for + /// xsi:schemaLocation (may even be null). + /// </summary> + SCHEMA_LOCATION, + /// <summary> + /// Check whether both documents provide the same values for + /// xsi:noNamspaceSchemaLocation (may even be null). + /// </summary> + NO_NAMESPACE_SCHEMA_LOCATION, + + /// <summary> + /// Compare the node types. + /// </summary> + NODE_TYPE, + + /// <summary> + /// Compare the node's namespace prefixes. + /// </summary> + NAMESPACE_PREFIX, + /// <summary> + /// Compare the node's namespace URIs. + /// </summary> + NAMESPACE_URI, + + /// <summary> + /// Compare content of CDATA sections. + /// </summary> + CDATA_VALUE, + /// <summary> + /// Compare content of comments. + /// </summary> + COMMENT_VALUE, + /// <summary> + /// Compare content of text nodes. + /// </summary> + TEXT_VALUE, + /// <summary> + /// Compare targets of processing instructions. + /// </summary> + PROCESSING_INSTRUCTION_TARGET, + /// <summary> + /// Compare data of processing instructions. + /// </summary> + PROCESSING_INSTRUCTION_DATA, + + /// <summary> + /// Compare element names. + /// </summary> + ELEMENT_TAG_NAME, + /// <summary> + /// Compare explicit/implicit status of attributes. + /// </summary> + ATTR_VALUE_EXPLICITLY_SPECIFIED, + /// <summary> + /// Compare number of attributes. + /// </summary> + ELEMENT_NUM_ATTRIBUTES, + /// <summary> + /// Compare attribute's value. + /// </summary> + ATTR_VALUE, + /// <summary> + /// Compare number of child nodes. + /// </summary> + CHILD_NODELIST_LENGTH, + /// <summary> + /// Compare order of child nodes. + /// </summary> + CHILD_NODELIST_SEQUENCE, + + /// <summary> + /// Search for a child node matching a specific child node of the + /// other node. + /// </summary> + CHILD_LOOKUP, + /// <summary> + /// Search for an atribute with a name matching a specific + /// attribute of the other node. + /// </summary> + ATTR_NAME_LOOKUP, + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/main/net-core/diff/ComparisonType.cs ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluator.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluator.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluator.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,25 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +namespace net.sf.xmlunit.diff { + + /// <summary> + /// May alter the outcome of a comparison. + /// </summary> + /// <return>the new result of the comparison, should return {@link + /// ComaprisonResult#CRITICAL} to stop the comparison + /// completely.</return> + public delegate ComparisonResult DifferenceEvaluator(Comparison comparison, + ComparisonResult outcome); +} Property changes on: trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluator.cs ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/ElementSelector.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/ElementSelector.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/ElementSelector.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,24 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Xml; + +namespace net.sf.xmlunit.diff { + + /// <summary> + /// Strategy for selecting matching elements. + /// </summary> + public delegate bool ElementSelector(XmlElement controlElement, + XmlElement testElement); +} Property changes on: trunk/xmlunit/src/main/net-core/diff/ElementSelector.cs ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/src/main/net-core/diff/IDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/IDifferenceEngine.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/IDifferenceEngine.cs 2010-05-03 16:08:17 UTC (rev 378) @@ -0,0 +1,54 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +namespace net.sf.xmlunit.diff { + + /// <summary> + /// XMLUnit's difference engine. + /// </summary> + public interface IDifferenceEngine { + /// <summary> + /// Is notified of each comparison. + /// </summary> + event ComparisonListener ComparisonListener; + + /// <summary> + /// Is notified of each comparison with outcome {@link + /// ComparisonResult#EQUAL}. + /// </summary> + event ComparisonListener MatchListener; + + /// <summary> + /// Is notified of each comparison with + /// outcome other than {@link ComparisonResult#EQUAL}. + /// </summary> + event ComparisonListener DifferenceListener; + + /// <summary> + /// Sets the strategy for selecting elements to compare. + /// </summary> + ElementSelector ElementSelector { set; } + + /// <summary> + /// Determines whether the comparison should stop after given + /// difference has been found. + /// </summary> + DifferenceEvaluator DifferenceEvaluator { set; } + + /// <summary> + /// Compares two pieces of XML and invokes the registered listeners. + /// </summary> + void Compare(ISource control, ISource test); + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/main/net-core/diff/IDifferenceEngine.cs ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |