From: <bo...@us...> - 2008-12-12 15:30:26
|
Revision: 278 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=278&view=rev Author: bodewig Date: 2008-12-12 15:30:20 +0000 (Fri, 12 Dec 2008) Log Message: ----------- attribute order is not relevant, neither in Java (fixed some time ago) nor in .NET Modified Paths: -------------- trunk/xmlunit/NUnit.ReadMe trunk/xmlunit/src/csharp/AssemblyInfo.cs trunk/xmlunit/src/csharp/DiffConfiguration.cs trunk/xmlunit/src/csharp/XmlDiff.cs trunk/xmlunit/xmlunit.nant.build Modified: trunk/xmlunit/NUnit.ReadMe =================================================================== --- trunk/xmlunit/NUnit.ReadMe 2008-06-11 10:05:04 UTC (rev 277) +++ trunk/xmlunit/NUnit.ReadMe 2008-12-12 15:30:20 UTC (rev 278) @@ -5,13 +5,23 @@ - Nunit v2.2 or above (http://nunit.org/) - .NET runtime v1.1 or Mono runtime v1.0 (or above) -If you want to build the source code yourself you will also need NAnt (http://nant.sourceforge.net/) +If you want to build the source code yourself you will also need NAnt +(http://nant.sourceforge.net/) -This build of the source code was prepared using .NET csc 1.1.4322, NUnit2.4.6, and NAnt0.8.5 +This build of the source code was prepared using .NET csc 1.1.4322, +NUnit2.4.8, and NAnt0.8.5 Enjoy! http://xmlunit.sourceforge.net/ +Changes in version 0.4: +- order of attributes is ignored, this means there will never be a + difference of type 4 anymore. + + A new flag in DifferenceConfiguration can be used to turn on the old + behavior where attribute order was significant. + + Changes in version 0.3.1: - made it compile and all tests pass on .NET 1.1 as well as 2.0 and NUnit 2.4 Modified: trunk/xmlunit/src/csharp/AssemblyInfo.cs =================================================================== --- trunk/xmlunit/src/csharp/AssemblyInfo.cs 2008-06-11 10:05:04 UTC (rev 277) +++ trunk/xmlunit/src/csharp/AssemblyInfo.cs 2008-12-12 15:30:20 UTC (rev 278) @@ -23,7 +23,7 @@ // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly: AssemblyVersion("0.3.1.0")] +[assembly: AssemblyVersion("0.4.0.0")] // The following attributes specify the key for the sign of your assembly. See the // .NET Framework documentation for more information about signing. Modified: trunk/xmlunit/src/csharp/DiffConfiguration.cs =================================================================== --- trunk/xmlunit/src/csharp/DiffConfiguration.cs 2008-06-11 10:05:04 UTC (rev 277) +++ trunk/xmlunit/src/csharp/DiffConfiguration.cs 2008-12-12 15:30:20 UTC (rev 278) @@ -2,21 +2,32 @@ using System.Xml; public class DiffConfiguration { - public static readonly WhitespaceHandling DEFAULT_WHITESPACE_HANDLING = WhitespaceHandling.All; - public static readonly string DEFAULT_DESCRIPTION = "XmlDiff"; - public static readonly bool DEFAULT_USE_VALIDATING_PARSER = true; + public const WhitespaceHandling DEFAULT_WHITESPACE_HANDLING = WhitespaceHandling.All; + public const string DEFAULT_DESCRIPTION = "XmlDiff"; + public const bool DEFAULT_USE_VALIDATING_PARSER = true; + public const bool DEFAULT_IGNORE_ATTRIBUTE_ORDER = true; private readonly string _description; private readonly bool _useValidatingParser; private readonly WhitespaceHandling _whitespaceHandling; + private readonly bool ignoreAttributeOrder; public DiffConfiguration(string description, bool useValidatingParser, - WhitespaceHandling whitespaceHandling) { + WhitespaceHandling whitespaceHandling, + bool ignoreAttributeOrder) { _description = description; _useValidatingParser = useValidatingParser; _whitespaceHandling = whitespaceHandling; + this.ignoreAttributeOrder = ignoreAttributeOrder; } + + public DiffConfiguration(string description, + bool useValidatingParser, + WhitespaceHandling whitespaceHandling) + : this (description, useValidatingParser, whitespaceHandling, + DEFAULT_IGNORE_ATTRIBUTE_ORDER) { + } public DiffConfiguration(string description, WhitespaceHandling whitespaceHandling) @@ -62,5 +73,11 @@ return _whitespaceHandling; } } + + public bool IgnoreAttributeOrder { + get { + return ignoreAttributeOrder; + } + } } } Modified: trunk/xmlunit/src/csharp/XmlDiff.cs =================================================================== --- trunk/xmlunit/src/csharp/XmlDiff.cs 2008-06-11 10:05:04 UTC (rev 277) +++ trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-12 15:30:20 UTC (rev 278) @@ -144,7 +144,9 @@ testAttrValue = _testReader.Value; if (!String.Equals(controlAttrName, testAttrName)) { + if (!_diffConfiguration.IgnoreAttributeOrder) { DifferenceFound(DifferenceType.ATTR_SEQUENCE_ID, result); + } if (!_testReader.MoveToAttribute(controlAttrName)) { DifferenceFound(DifferenceType.ATTR_NAME_NOT_FOUND_ID, result); Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2008-06-11 10:05:04 UTC (rev 277) +++ trunk/xmlunit/xmlunit.nant.build 2008-12-12 15:30:20 UTC (rev 278) @@ -1,5 +1,5 @@ <project name="xmlunit" description="XmlUnit for .Net" default="compile"> - <property name="project.version" value="0.3.1" overwrite="false"/> + <property name="project.version" value="0.4" overwrite="false"/> <property name="base.dir" value="${project::get-base-directory()}" overwrite="false"/> <property name="src.dir" value="${base.dir}/src/csharp" overwrite="false"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-12-12 16:52:55
|
Revision: 280 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=280&view=rev Author: bodewig Date: 2008-12-12 16:52:49 +0000 (Fri, 12 Dec 2008) Log Message: ----------- port part of the namespaces for attributes logic from the Java version Modified Paths: -------------- trunk/xmlunit/NUnit.ReadMe trunk/xmlunit/src/csharp/XmlDiff.cs Modified: trunk/xmlunit/NUnit.ReadMe =================================================================== --- trunk/xmlunit/NUnit.ReadMe 2008-12-12 15:31:16 UTC (rev 279) +++ trunk/xmlunit/NUnit.ReadMe 2008-12-12 16:52:49 UTC (rev 280) @@ -21,6 +21,7 @@ A new flag in DifferenceConfiguration can be used to turn on the old behavior where attribute order was significant. +- xmlns attributes are now no longer treated as normal attributes Changes in version 0.3.1: - made it compile and all tests pass on .NET 1.1 as well as 2.0 and Modified: trunk/xmlunit/src/csharp/XmlDiff.cs =================================================================== --- trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-12 15:31:16 UTC (rev 279) +++ trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-12 16:52:49 UTC (rev 280) @@ -1,10 +1,13 @@ namespace XmlUnit { using System; + using System.Collections; using System.IO; using System.Xml; using System.Xml.Schema; public class XmlDiff { + private const string XMLNS_PREFIX = "xmlns"; + private readonly XmlReader _controlReader; private readonly XmlReader _testReader; private readonly DiffConfiguration _diffConfiguration; @@ -119,48 +122,62 @@ if (!String.Equals(controlTagName, testTagName)) { DifferenceFound(DifferenceType.ELEMENT_TAG_NAME_ID, result); } else { - int controlAttributeCount = _controlReader.AttributeCount; - int testAttributeCount = _testReader.AttributeCount; - if (controlAttributeCount != testAttributeCount) { + XmlAttribute[] controlAttributes = + GetNonSpecialAttributes(_controlReader); + XmlAttribute[] testAttributes = + GetNonSpecialAttributes(_testReader); + if (controlAttributes.Length != testAttributes.Length) { DifferenceFound(DifferenceType.ELEMENT_NUM_ATTRIBUTES_ID, result); } else { - CompareAttributes(result, controlAttributeCount); + CompareAttributes(result, controlAttributes, testAttributes); } } } - private void CompareAttributes(DiffResult result, int controlAttributeCount) { - string controlAttrValue, controlAttrName; - string testAttrValue, testAttrName; - - _controlReader.MoveToFirstAttribute(); - _testReader.MoveToFirstAttribute(); - for (int i=0; i < controlAttributeCount; ++i) { + private void CompareAttributes(DiffResult result, + XmlAttribute[] controlAttributes, + XmlAttribute[] testAttributes) { + ArrayList unmatchedTestAttributes = new ArrayList(); + unmatchedTestAttributes.AddRange(testAttributes); + for (int i=0; i < controlAttributes.Length; ++i) { - controlAttrName = _controlReader.Name; - testAttrName = _testReader.Name; - - controlAttrValue = _controlReader.Value; - testAttrValue = _testReader.Value; - - if (!String.Equals(controlAttrName, testAttrName)) { - if (!_diffConfiguration.IgnoreAttributeOrder) { - DifferenceFound(DifferenceType.ATTR_SEQUENCE_ID, result); + bool controlIsInNs = IsNamespaced(controlAttributes[i]); + string controlAttrName = + GetUnNamespacedNodeName(controlAttributes[i]); + XmlAttribute testAttr = null; + if (!controlIsInNs) { + testAttr = FindAttributeByName(testAttributes, + controlAttrName); + } else { + testAttr = FindAttributeByNameAndNs(testAttributes, + controlAttrName, + controlAttributes[i] + .NamespaceURI); + } + + if (testAttr != null) { + unmatchedTestAttributes.Remove(testAttr); + if (!_diffConfiguration.IgnoreAttributeOrder + && testAttr != testAttributes[i]) { + DifferenceFound(DifferenceType.ATTR_SEQUENCE_ID, + result); } - - if (!_testReader.MoveToAttribute(controlAttrName)) { - DifferenceFound(DifferenceType.ATTR_NAME_NOT_FOUND_ID, result); + + if (controlAttributes[i].Value != testAttr.Value) { + Console.Error.WriteLine("control: {0}, expected {1}, was {2}", + controlAttrName, + controlAttributes[i].Value, testAttr.Value); + DifferenceFound(DifferenceType.ATTR_VALUE_ID, result); } - testAttrValue = _testReader.Value; + + } else { + DifferenceFound(DifferenceType.ATTR_NAME_NOT_FOUND_ID, + result); } - - if (!String.Equals(controlAttrValue, testAttrValue)) { - DifferenceFound(DifferenceType.ATTR_VALUE_ID, result); - } - - _controlReader.MoveToNextAttribute(); - _testReader.MoveToNextAttribute(); } + foreach (XmlAttribute a in unmatchedTestAttributes) { + DifferenceFound(DifferenceType.ATTR_NAME_NOT_FOUND_ID, result); + } } private void CompareText(DiffResult result) { @@ -207,6 +224,68 @@ } } + private XmlAttribute[] GetNonSpecialAttributes(XmlReader r) { + ArrayList l = new ArrayList(); + int length = r.AttributeCount; + if (length > 0) { + XmlDocument doc = new XmlDocument(); + r.MoveToFirstAttribute(); + for (int i = 0; i < length; i++) { + XmlAttribute a = doc.CreateAttribute(r.Name, r.NamespaceURI); + if (!IsXMLNSAttribute(a)) { + l.Add(a); + } + a.Value = r.Value; + r.MoveToNextAttribute(); + } + } + return (XmlAttribute[]) l.ToArray(typeof(XmlAttribute)); + } + + private bool IsXMLNSAttribute(XmlAttribute attribute) { + return XMLNS_PREFIX == attribute.Prefix || + XMLNS_PREFIX == attribute.Name; + } + + private XmlAttribute FindAttributeByName(XmlAttribute[] attrs, + string name) { + foreach (XmlAttribute a in attrs) { + if (GetUnNamespacedNodeName(a) == name) { + return a; + } + } + return null; + } + + private XmlAttribute FindAttributeByNameAndNs(XmlAttribute[] attrs, + string name, + string nsUri) { + foreach (XmlAttribute a in attrs) { + if (GetUnNamespacedNodeName(a) == name + && a.NamespaceURI == nsUri) { + return a; + } + } + return null; + } + + private string GetUnNamespacedNodeName(XmlNode aNode) { + return GetUnNamespacedNodeName(aNode, IsNamespaced(aNode)); + } + + private string GetUnNamespacedNodeName(XmlNode aNode, + bool isNamespacedNode) { + if (isNamespacedNode) { + return aNode.LocalName; + } + return aNode.Name; + } + + private bool IsNamespaced(XmlNode aNode) { + string ns = aNode.NamespaceURI; + return ns != null && ns.Length > 0; + } + private void CheckEndElement(XmlReader reader, ref bool readResult, DiffResult result) { readResult = reader.Read(); if (!readResult || reader.NodeType != XmlNodeType.EndElement) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-12-15 13:52:02
|
Revision: 285 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=285&view=rev Author: bodewig Date: 2008-12-15 13:51:51 +0000 (Mon, 15 Dec 2008) Log Message: ----------- encapsulate reader state a bit Modified Paths: -------------- trunk/xmlunit/src/csharp/XmlDiff.cs trunk/xmlunit/tests/csharp/XmlDiffTests.cs Modified: trunk/xmlunit/src/csharp/XmlDiff.cs =================================================================== --- trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-15 12:29:52 UTC (rev 284) +++ trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-15 13:51:51 UTC (rev 285) @@ -35,13 +35,13 @@ private XmlReader CreateXmlReader(XmlInput forInput) { XmlReader xmlReader = forInput.CreateXmlReader(); - if (xmlReader is XmlTextReader) { - ((XmlTextReader) xmlReader ).WhitespaceHandling = _diffConfiguration.WhitespaceHandling; - } + if (xmlReader is XmlTextReader) { + ((XmlTextReader) xmlReader ).WhitespaceHandling = _diffConfiguration.WhitespaceHandling; + } if (_diffConfiguration.UseValidatingParser) { - XmlValidatingReader validatingReader = new XmlValidatingReader(xmlReader); - return validatingReader; + XmlValidatingReader validatingReader = new XmlValidatingReader(xmlReader); + return validatingReader; } return xmlReader; @@ -62,82 +62,78 @@ private void Compare(DiffResult result, XmlReader controlReader, XmlReader testReader) { - bool controlRead, testRead; try { + ReaderWithState control = new ReaderWithState(controlReader); + ReaderWithState test = new ReaderWithState(testReader); do { - controlRead = controlReader.Read(); - testRead = testReader.Read(); - Compare(result, controlReader, ref controlRead, - testReader, ref testRead); - } while (controlRead && testRead) ; + control.Read(); + test.Read(); + Compare(result, control, test); + } while (control.HasRead && test.HasRead) ; } catch (FlowControlException e) { Console.Out.WriteLine(e.Message); } } - private void Compare(DiffResult result, - XmlReader controlReader, ref bool controlRead, - XmlReader testReader, ref bool testRead) { - if (controlRead) { - if (testRead) { - CompareNodes(result, controlReader, testReader); - CheckEmptyOrAtEndElement(result, - controlReader, ref controlRead, - testReader, ref testRead); + private void Compare(DiffResult result, ReaderWithState control, + ReaderWithState test) { + if (control.HasRead) { + if (test.HasRead) { + CompareNodes(result, control, test); + CheckEmptyOrAtEndElement(result, control, test); } else { DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result); } } } - private void CompareNodes(DiffResult result, XmlReader controlReader, - XmlReader testReader) { - XmlNodeType controlNodeType = controlReader.NodeType; - XmlNodeType testNodeType = testReader.NodeType; + private void CompareNodes(DiffResult result, ReaderWithState control, + ReaderWithState test) { + XmlNodeType controlNodeType = control.Reader.NodeType; + XmlNodeType testNodeType = test.Reader.NodeType; if (!controlNodeType.Equals(testNodeType)) { CheckNodeTypes(controlNodeType, testNodeType, result, - controlReader, testReader); + control, test); } else if (controlNodeType == XmlNodeType.Element) { - CompareElements(result, controlReader, testReader); + CompareElements(result, control, test); } else if (controlNodeType == XmlNodeType.Text) { - CompareText(result, controlReader, testReader); + CompareText(result, control, test); } } private void CheckNodeTypes(XmlNodeType controlNodeType, XmlNodeType testNodeType, DiffResult result, - XmlReader controlReader, - XmlReader testReader) { - XmlReader readerToAdvance = null; + ReaderWithState control, + ReaderWithState test) { + ReaderWithState readerToAdvance = null; if (controlNodeType.Equals(XmlNodeType.XmlDeclaration)) { - readerToAdvance = controlReader; + readerToAdvance = control; } else if (testNodeType.Equals(XmlNodeType.XmlDeclaration)) { - readerToAdvance = testReader; + readerToAdvance = test; } if (readerToAdvance != null) { DifferenceFound(DifferenceType.HAS_XML_DECLARATION_PREFIX_ID, controlNodeType, testNodeType, result); readerToAdvance.Read(); - CompareNodes(result, controlReader, testReader); + CompareNodes(result, control, test); } else { DifferenceFound(DifferenceType.NODE_TYPE_ID, controlNodeType, testNodeType, result); } } - private void CompareElements(DiffResult result, XmlReader controlReader, - XmlReader testReader) { - string controlTagName = controlReader.Name; - string testTagName = testReader.Name; + private void CompareElements(DiffResult result, ReaderWithState control, + ReaderWithState test) { + string controlTagName = control.Reader.Name; + string testTagName = test.Reader.Name; if (!String.Equals(controlTagName, testTagName)) { DifferenceFound(DifferenceType.ELEMENT_TAG_NAME_ID, result); } else { XmlAttribute[] controlAttributes = - GetNonSpecialAttributes(controlReader); - XmlAttribute[] testAttributes = - GetNonSpecialAttributes(testReader); + GetNonSpecialAttributes(control); + XmlAttribute[] testAttributes = GetNonSpecialAttributes(test); if (controlAttributes.Length != testAttributes.Length) { DifferenceFound(DifferenceType.ELEMENT_NUM_ATTRIBUTES_ID, result); } @@ -191,10 +187,10 @@ } } - private void CompareText(DiffResult result, XmlReader controlReader, - XmlReader testReader) { - string controlText = controlReader.Value; - string testText = testReader.Value; + private void CompareText(DiffResult result, ReaderWithState control, + ReaderWithState test) { + string controlText = control.Reader.Value; + string testText = test.Reader.Value; if (!String.Equals(controlText, testText)) { DifferenceFound(DifferenceType.TEXT_VALUE_ID, result); } @@ -224,34 +220,33 @@ } private void CheckEmptyOrAtEndElement(DiffResult result, - XmlReader controlReader, - ref bool controlRead, - XmlReader testReader, - ref bool testRead) { - if (controlReader.IsEmptyElement) { - if (!testReader.IsEmptyElement) { - CheckEndElement(testReader, ref testRead, result); + ReaderWithState control, + ReaderWithState test) { + if (control.Reader.IsEmptyElement) { + if (!test.Reader.IsEmptyElement) { + CheckEndElement(test, result); } } else { - if (testReader.IsEmptyElement) { - CheckEndElement(controlReader, ref controlRead, result); + if (test.Reader.IsEmptyElement) { + CheckEndElement(control, result); } } } - private XmlAttribute[] GetNonSpecialAttributes(XmlReader r) { + private XmlAttribute[] GetNonSpecialAttributes(ReaderWithState r) { ArrayList l = new ArrayList(); - int length = r.AttributeCount; + int length = r.Reader.AttributeCount; if (length > 0) { XmlDocument doc = new XmlDocument(); - r.MoveToFirstAttribute(); + r.Reader.MoveToFirstAttribute(); for (int i = 0; i < length; i++) { - XmlAttribute a = doc.CreateAttribute(r.Name, r.NamespaceURI); + XmlAttribute a = doc.CreateAttribute(r.Reader.Name, + r.Reader.NamespaceURI); if (!IsXMLNSAttribute(a)) { + a.Value = r.Reader.Value; l.Add(a); } - a.Value = r.Value; - r.MoveToNextAttribute(); + r.Reader.MoveToNextAttribute(); } } return (XmlAttribute[]) l.ToArray(typeof(XmlAttribute)); @@ -301,22 +296,35 @@ return ns != null && ns.Length > 0; } - private void CheckEndElement(XmlReader reader, ref bool readResult, DiffResult result) { - readResult = reader.Read(); - if (!readResult || reader.NodeType != XmlNodeType.EndElement) { + private void CheckEndElement(ReaderWithState reader, DiffResult result) { + bool readResult = reader.Read(); + if (!readResult + || reader.Reader.NodeType != XmlNodeType.EndElement) { DifferenceFound(DifferenceType.CHILD_NODELIST_LENGTH_ID, result); - } + } } + public string OptionalDescription { + get { + return _diffConfiguration.Description; + } + } + private class FlowControlException : ApplicationException { public FlowControlException(Difference cause) : base(cause.ToString()) { } } - public string OptionalDescription { - get { - return _diffConfiguration.Description; + private class ReaderWithState { + internal ReaderWithState(XmlReader reader) { + Reader = reader; + HasRead = false; } + internal readonly XmlReader Reader; + internal bool HasRead; + internal bool Read() { + return HasRead = Reader.Read(); + } } } } Modified: trunk/xmlunit/tests/csharp/XmlDiffTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XmlDiffTests.cs 2008-12-15 12:29:52 UTC (rev 284) +++ trunk/xmlunit/tests/csharp/XmlDiffTests.cs 2008-12-15 13:51:51 UTC (rev 285) @@ -24,9 +24,12 @@ private void AssertExpectedResult(string input1, string input2, bool expected) { TextReader reader1 = new StringReader(input1); TextReader reader2 = new StringReader(input2); + System.Console.Error.WriteLine("comparing {0} to {1}", input1, + input2); DiffResult result = PerformDiff(reader1, reader2); - string msg = "comparing " + input1 + " to " + input2 + ": " + result.Difference; - Assert.AreEqual(expected, result.Equal); + string msg = string.Format("comparing {0} to {1}: {2}", input1, + input2, result.Difference); + Assert.AreEqual(expected, result.Equal, msg); } private void AssertExpectedResult(string[] inputs1, string[] inputs2, bool expected) { @@ -46,11 +49,27 @@ } [Test] public void EqualResultForSameEmptyElements() { - string[] input1 = {"<empty/>" , "<empty></empty>", "<elem><empty/></elem>", "<empty/>" }; - string[] input2 = {"<empty/>" , "<empty></empty>", "<elem><empty></empty></elem>", "<empty></empty>"}; + string[] input1 = {"<empty/>", "<elem><empty/></elem>"}; + string[] input2 = {"<empty></empty>", "<elem><empty></empty></elem>"}; + System.Console.Error.WriteLine("ooooooooooooooooooooooooooooooooooooooooo"); + try { AssertExpectedResult(input1, input2, true); + } finally { + System.Console.Error.WriteLine("ooooooooooooooooooooooooooooooooooooooooo"); + } } + [Test] public void EqualResultForEmptyElementsWithAttributes() { + string[] input1 = {"<empty x='1'/>", "<elem><empty x='1'/></elem>"}; + string[] input2 = {"<empty x='1'></empty>", "<elem><empty x='1'></empty></elem>"}; + System.Console.Error.WriteLine("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + try { + AssertExpectedResult(input1, input2, true); + } finally { + System.Console.Error.WriteLine("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + } + } + [Test] public void NotEqualResultForEmptyVsNotEmptyElements() { string[] input1 = {"<empty/>" , "<empty></empty>", "<empty><empty/></empty>"}; string[] input2 = {"<empty>text</empty>", "<empty>text</empty>", "<empty>text</empty>"}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2008-12-15 14:13:03
|
Revision: 286 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=286&view=rev Author: bodewig Date: 2008-12-15 14:12:57 +0000 (Mon, 15 Dec 2008) Log Message: ----------- make empty element comparisons work for elements with attributes Modified Paths: -------------- trunk/xmlunit/NUnit.ReadMe trunk/xmlunit/src/csharp/XmlDiff.cs trunk/xmlunit/tests/csharp/XmlDiffTests.cs Modified: trunk/xmlunit/NUnit.ReadMe =================================================================== --- trunk/xmlunit/NUnit.ReadMe 2008-12-15 13:51:51 UTC (rev 285) +++ trunk/xmlunit/NUnit.ReadMe 2008-12-15 14:12:57 UTC (rev 286) @@ -24,6 +24,10 @@ - xmlns attributes are now no longer treated as normal attributes and the namespace of attributes is now sigificant +- comparisions of empty elements with attributes failed. + I.e. <foo><bar x="1"/></foo> was considered different from + <foo><bar x="1"></bar></foo> + Changes in version 0.3.1: - made it compile and all tests pass on .NET 1.1 as well as 2.0 and NUnit 2.4 Modified: trunk/xmlunit/src/csharp/XmlDiff.cs =================================================================== --- trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-15 13:51:51 UTC (rev 285) +++ trunk/xmlunit/src/csharp/XmlDiff.cs 2008-12-15 14:12:57 UTC (rev 286) @@ -171,9 +171,6 @@ } if (controlAttributes[i].Value != testAttr.Value) { - Console.Error.WriteLine("control: {0}, expected {1}, was {2}", - controlAttrName, - controlAttributes[i].Value, testAttr.Value); DifferenceFound(DifferenceType.ATTR_VALUE_ID, result); } @@ -222,12 +219,12 @@ private void CheckEmptyOrAtEndElement(DiffResult result, ReaderWithState control, ReaderWithState test) { - if (control.Reader.IsEmptyElement) { - if (!test.Reader.IsEmptyElement) { + if (control.LastElementWasEmpty) { + if (!test.LastElementWasEmpty) { CheckEndElement(test, result); } } else { - if (test.Reader.IsEmptyElement) { + if (test.LastElementWasEmpty) { CheckEndElement(control, result); } } @@ -319,12 +316,41 @@ internal ReaderWithState(XmlReader reader) { Reader = reader; HasRead = false; + LastElementWasEmpty = false; } + internal readonly XmlReader Reader; internal bool HasRead; + internal bool LastElementWasEmpty; + internal bool Read() { - return HasRead = Reader.Read(); + HasRead = Reader.Read(); + if (HasRead) { + switch (Reader.NodeType) { + case XmlNodeType.Element: + LastElementWasEmpty = Reader.IsEmptyElement; + break; + case XmlNodeType.EndElement: + LastElementWasEmpty = false; + break; + default: + // don't care + break; + } + } + return HasRead; } + + internal string State { + get { + return string.Format("Name {0}, NodeType {1}, IsEmpty {2}," + + " HasRead {3}, LastWasEmpty {4}", + Reader.Name, + Reader.NodeType, + Reader.IsEmptyElement, + HasRead, LastElementWasEmpty); + } + } } } } Modified: trunk/xmlunit/tests/csharp/XmlDiffTests.cs =================================================================== --- trunk/xmlunit/tests/csharp/XmlDiffTests.cs 2008-12-15 13:51:51 UTC (rev 285) +++ trunk/xmlunit/tests/csharp/XmlDiffTests.cs 2008-12-15 14:12:57 UTC (rev 286) @@ -24,8 +24,6 @@ private void AssertExpectedResult(string input1, string input2, bool expected) { TextReader reader1 = new StringReader(input1); TextReader reader2 = new StringReader(input2); - System.Console.Error.WriteLine("comparing {0} to {1}", input1, - input2); DiffResult result = PerformDiff(reader1, reader2); string msg = string.Format("comparing {0} to {1}: {2}", input1, input2, result.Difference); @@ -51,23 +49,13 @@ [Test] public void EqualResultForSameEmptyElements() { string[] input1 = {"<empty/>", "<elem><empty/></elem>"}; string[] input2 = {"<empty></empty>", "<elem><empty></empty></elem>"}; - System.Console.Error.WriteLine("ooooooooooooooooooooooooooooooooooooooooo"); - try { AssertExpectedResult(input1, input2, true); - } finally { - System.Console.Error.WriteLine("ooooooooooooooooooooooooooooooooooooooooo"); - } } [Test] public void EqualResultForEmptyElementsWithAttributes() { string[] input1 = {"<empty x='1'/>", "<elem><empty x='1'/></elem>"}; string[] input2 = {"<empty x='1'></empty>", "<elem><empty x='1'></empty></elem>"}; - System.Console.Error.WriteLine("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - try { AssertExpectedResult(input1, input2, true); - } finally { - System.Console.Error.WriteLine("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - } } [Test] public void NotEqualResultForEmptyVsNotEmptyElements() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-04-22 05:29:49
|
Revision: 294 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=294&view=rev Author: bodewig Date: 2009-04-22 05:29:46 +0000 (Wed, 22 Apr 2009) Log Message: ----------- move sources into a new directory structure, preparing for XMLUnit 2.x development Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/src/main/legacy-java/ trunk/xmlunit/src/main/legacy-net/ trunk/xmlunit/src/tests/legacy-java/ trunk/xmlunit/src/tests/legacy-net/ Removed Paths: ------------- trunk/xmlunit/src/csharp/ trunk/xmlunit/src/java/ trunk/xmlunit/tests/csharp/ trunk/xmlunit/tests/java/ Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2009-04-22 05:21:57 UTC (rev 293) +++ trunk/xmlunit/build.xml 2009-04-22 05:29:46 UTC (rev 294) @@ -40,8 +40,8 @@ <property name="xmlunit.version" value="1.3alpha"/> <!-- some locations --> - <property name="src.dir" value="src"/> - <property name="test.dir" value="tests"/> + <property name="src.dir" value="src/main"/> + <property name="test.dir" value="src/tests"/> <property name="build.dir" location="build"/> <property name="lib.dir" value="${build.dir}/lib"/> <property name="out.dir" value="${build.dir}/classes"/> @@ -104,7 +104,7 @@ <target name="compile" depends="-init" description="compiles sources and tests"> - <javac srcdir="${src.dir}/java" destdir="${out.dir}" + <javac srcdir="${src.dir}/legacy-java" destdir="${out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${xmlxsl.lib}"/> @@ -114,7 +114,7 @@ <exclude name="**/jaxp13/**" unless="jaxp13+"/> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> </javac> - <javac srcdir="${test.dir}/java" destdir="${test.out.dir}" + <javac srcdir="${test.dir}/legacy-java" destdir="${test.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${out.dir}"/> @@ -150,7 +150,7 @@ </classpath> <formatter type="xml"/> <batchtest todir="${test.report.dir}"> - <fileset dir="${test.dir}/java"> + <fileset dir="${test.dir}/legacy-java"> <include name="**/test_*.java"/> <exclude name="**/jaxp13/**" unless="jaxp13+.impl"/> </fileset> @@ -175,12 +175,12 @@ description="creates the API documentation"> <delete includeEmptyDirs="true" dir="${docs.dir}/api"/> <javadoc destdir="${docs.dir}/api" - overview="${src.dir}/java/overview.html" + overview="${src.dir}/legacy-java/overview.html" windowtitle="XMLUnit Documentation" footer="<p><a href="http://xmlunit.sourceforge.net/">XMLUnit</a> is hosted by sourceforge.net</p>"> <group title="XMLUnit v${xmlunit.version}" packages="org.custommonkey.xmlunit*"/> - <fileset dir="${src.dir}/java"> + <fileset dir="${src.dir}/legacy-java"> <include name="org/custommonkey/**/*.java"/> </fileset> <classpath> Property changes on: trunk/xmlunit/src/main/legacy-java ___________________________________________________________________ Added: svn:mergeinfo + Property changes on: trunk/xmlunit/src/main/legacy-net ___________________________________________________________________ Added: svn:mergeinfo + Property changes on: trunk/xmlunit/src/tests/legacy-java ___________________________________________________________________ Added: svn:mergeinfo + Property changes on: trunk/xmlunit/src/tests/legacy-net ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2009-04-22 05:21:57 UTC (rev 293) +++ trunk/xmlunit/xmlunit.nant.build 2009-04-22 05:29:46 UTC (rev 294) @@ -2,8 +2,8 @@ <property name="project.version" value="0.4" overwrite="false"/> <property name="base.dir" value="${project::get-base-directory()}" overwrite="false"/> - <property name="src.dir" value="${base.dir}/src/csharp" overwrite="false"/> - <property name="tests.src.dir" value="${base.dir}/tests/csharp" + <property name="src.dir" value="${base.dir}/src/main/legacy-net" overwrite="false"/> + <property name="tests.src.dir" value="${base.dir}/src/tests/legacy-net" overwrite="false"/> <property name="bin.dir" value="${base.dir}/bin" overwrite="false"/> <property name="csc.verbose" value="false" overwrite="false"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-04-23 03:49:11
|
Revision: 295 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=295&view=rev Author: bodewig Date: 2009-04-23 03:48:58 +0000 (Thu, 23 Apr 2009) Log Message: ----------- add junit Modified Paths: -------------- trunk/xmlunit/build.xml Added Paths: ----------- trunk/xmlunit/lib/ trunk/xmlunit/lib/junit-3.8.2.jar Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2009-04-22 05:29:46 UTC (rev 294) +++ trunk/xmlunit/build.xml 2009-04-23 03:48:58 UTC (rev 295) @@ -62,7 +62,6 @@ <!-- some library paths --> <!-- where is JAXP? property name="${xmlxsl.lib}" location="."/ --> - <!-- where is JUnit? property name="${junit.lib}" location="."/ --> <!-- Docbook related properties, macros and targets --> <import file="docbook.xml"/> @@ -108,8 +107,8 @@ debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${xmlxsl.lib}"/> - <pathelement location="${junit.lib}"/> <pathelement path="${java.class.path}"/> + <fileset dir="lib" includes="*.jar"/> </classpath> <exclude name="**/jaxp13/**" unless="jaxp13+"/> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> @@ -119,8 +118,8 @@ <classpath> <pathelement location="${out.dir}"/> <pathelement location="${xmlxsl.lib}"/> - <pathelement location="${junit.lib}"/> <pathelement path="${java.class.path}"/> + <fileset dir="lib" includes="*.jar"/> </classpath> <exclude name="**/jaxp13/**" unless="jaxp13+"/> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> @@ -145,8 +144,8 @@ <pathelement location="${out.dir}"/> <pathelement location="${test.out.dir}"/> <pathelement location="${xmlxsl.lib}"/> - <pathelement location="${junit.lib}"/> <pathelement path="${java.class.path}"/> + <fileset dir="lib" includes="*.jar"/> </classpath> <formatter type="xml"/> <batchtest todir="${test.report.dir}"> @@ -283,7 +282,6 @@ <javac srcdir="src/user-guide" includes="org/" destdir="${userguide.out.dir}" source="1.3" target="1.2"> <classpath> - <pathelement location="${junit.lib}"/> <pathelement location="${out.dir}"/> </classpath> </javac> Added: trunk/xmlunit/lib/junit-3.8.2.jar =================================================================== (Binary files differ) Property changes on: trunk/xmlunit/lib/junit-3.8.2.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-04-23 04:05:50
|
Revision: 297 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=297&view=rev Author: bodewig Date: 2009-04-23 04:05:44 +0000 (Thu, 23 Apr 2009) Log Message: ----------- move test resources Modified Paths: -------------- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/jaxp13/test_Validator.java trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_DetailedDiff.java trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Diff.java trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_JAXP_1_2_Schema_Validation.java trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Transform.java trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Validator.java trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_XMLTestCase.java trunk/xmlunit/src/tests/legacy-net/ValidatorTests.cs trunk/xmlunit/src/tests/legacy-net/XmlAssertionTests.cs trunk/xmlunit/src/tests/resources/BookXsdGenerated.xml Added Paths: ----------- trunk/xmlunit/src/tests/resources/ Removed Paths: ------------- trunk/xmlunit/tests/etc/ Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/jaxp13/test_Validator.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/jaxp13/test_Validator.java 2009-04-23 04:05:44 UTC (rev 297) @@ -54,28 +54,28 @@ public void testGoodSchemaIsValid() throws Exception { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/Book.xsd"))); + + "/src/tests/resources/Book.xsd"))); assertTrue(v.isSchemaValid()); } public void testGoodSchemaHasNoErrors() throws Exception { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/Book.xsd"))); + + "/src/tests/resources/Book.xsd"))); assertEquals(0, v.getSchemaErrors().size()); } public void testBrokenSchemaIsInvalid() throws Exception { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/broken.xsd"))); + + "/src/tests/resources/broken.xsd"))); assertFalse(v.isSchemaValid()); } public void testBrokenSchemaHasErrors() throws Exception { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/broken.xsd"))); + + "/src/tests/resources/broken.xsd"))); List l = v.getSchemaErrors(); for (Iterator i = l.iterator(); i.hasNext(); ) { Object ex = i.next(); @@ -90,30 +90,30 @@ public void testGoodInstanceIsValid() throws Exception { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/Book.xsd"))); + + "/src/tests/resources/Book.xsd"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGenerated.xml")); + + "/src/tests/resources/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"))); + + "/src/tests/resources/Book.xsd"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/invalidBook.xml")); + + "/src/tests/resources/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"))); + + "/src/tests/resources/Book.xsd"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/invalidBook.xml")); + + "/src/tests/resources/invalidBook.xml")); List l = v.getInstanceErrors(s); for (Iterator i = l.iterator(); i.hasNext(); ) { Object ex = i.next(); @@ -128,10 +128,10 @@ public void testInstanceValidationOfBrokenSchema() { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/broken.xsd"))); + + "/src/tests/resources/broken.xsd"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGenerated.xml")); + + "/src/tests/resources/BookXsdGenerated.xml")); try { v.isInstanceValid(s); fail("expected exception because schema is invalid"); @@ -143,10 +143,10 @@ public void testInstanceValidationOfMissingFile() { Validator v = new Validator(); v.addSchemaSource(new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/Book.xsd"))); + + "/src/tests/resources/Book.xsd"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/not there.xml")); + + "/src/tests/resources/not there.xml")); try { v.isInstanceValid(s); fail("expected exception because instance doesn't exist"); @@ -169,7 +169,7 @@ 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"))); + + "/src/tests/resources/Book.rng"))); assertTrue(v.isSchemaValid()); } @@ -180,10 +180,10 @@ 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"))); + + "/src/tests/resources/Book.rng"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml")); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml")); assertTrue(v.isInstanceValid(s)); } @@ -194,10 +194,10 @@ 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"))); + + "/src/tests/resources/Book.rng"))); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/invalidBook.xml")); + + "/src/tests/resources/invalidBook.xml")); List l = v.getInstanceErrors(s); for (Iterator i = l.iterator(); i.hasNext(); ) { Object ex = i.next(); @@ -218,11 +218,11 @@ 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"))); + + "/src/tests/resources/Book.rngc"))); assertTrue(v.isSchemaValid()); StreamSource s = new StreamSource(new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml")); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml")); assertTrue(v.isInstanceValid(s)); } Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_DetailedDiff.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_DetailedDiff.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_DetailedDiff.java 2009-04-23 04:05:44 UTC (rev 297) @@ -109,8 +109,8 @@ int i = 0; String expr = null; File test, control; - control = new File(test_Constants.BASEDIR + "/tests/etc/controlDetail.xml"); - test = new File(test_Constants.BASEDIR + "/tests/etc/testDetail.xml"); + control = new File(test_Constants.BASEDIR + "/src/tests/resources/controlDetail.xml"); + test = new File(test_Constants.BASEDIR + "/src/tests/resources/testDetail.xml"); DetailedDiff differencesWithWhitespace = new DetailedDiff( new Diff(new InputSource(new FileReader(control)), new InputSource(new FileReader(test))) ); Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Diff.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Diff.java 2009-04-23 04:05:44 UTC (rev 297) @@ -145,9 +145,9 @@ public void testFiles() throws Exception { FileReader control = new FileReader(test_Constants.BASEDIR - + "/tests/etc/test.blame.html"); + + "/src/tests/resources/test.blame.html"); FileReader test = new FileReader(test_Constants.BASEDIR - + "/tests/etc/test.blame.html"); + + "/src/tests/resources/test.blame.html"); Diff diff = buildDiff(control, test); assertEquals(diff.toString(), true, diff.identical()); } @@ -389,9 +389,9 @@ public void testNamespacedAttributes() throws Exception { FileReader control = new FileReader(test_Constants.BASEDIR - + "/tests/etc/controlNamespaces.xml"); + + "/src/tests/resources/controlNamespaces.xml"); FileReader test = new FileReader(test_Constants.BASEDIR - + "/tests/etc/testNamespaces.xml"); + + "/src/tests/resources/testNamespaces.xml"); Diff diff = buildDiff(control, test); diff.overrideDifferenceListener( new ExpectedDifferenceListener(DifferenceConstants.NAMESPACE_PREFIX_ID)); Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_JAXP_1_2_Schema_Validation.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_JAXP_1_2_Schema_Validation.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_JAXP_1_2_Schema_Validation.java 2009-04-23 04:05:44 UTC (rev 297) @@ -49,12 +49,12 @@ private Validator validator; public void testUsingStringURI() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); @@ -67,12 +67,12 @@ } public void testUsingInputStream() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); @@ -85,12 +85,12 @@ } public void testUsingInputSource() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); @@ -104,12 +104,12 @@ } public void testUsingAFile() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); @@ -122,12 +122,12 @@ } public void testUsingObjectArrayContainingStringURI() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); @@ -142,12 +142,12 @@ } public void testUsingNonExistentFile() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/BookDoesNotExist.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/BookDoesNotExist.xsd"); assertFalse("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/BookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); @@ -160,12 +160,12 @@ } public void testUsingInvalidXML() throws Exception { - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/InvalidBookXsdGeneratedNoSchema.xml"); + + "/src/tests/resources/InvalidBookXsdGeneratedNoSchema.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Transform.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Transform.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Transform.java 2009-04-23 04:05:44 UTC (rev 297) @@ -113,7 +113,7 @@ + test_Constants.XSLT_START + test_Constants.XSLT_XML_OUTPUT_NOINDENT + "<xsl:template match=\"bug\"><xsl:apply-templates select=\"animal\"/></xsl:template>" - + "<xsl:include href=\"" + test_Constants.BASEDIR + "/tests/etc/animal.xsl\"/>" + + "<xsl:include href=\"" + test_Constants.BASEDIR + "/src/tests/resources/animal.xsl\"/>" + test_Constants.XSLT_END; Transform transform = new Transform(input, xslWithInclude); transform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); @@ -155,7 +155,7 @@ } public void setUp() throws Exception { - animal = new File(test_Constants.BASEDIR + "/tests/etc/animal.xsl"); + animal = new File(test_Constants.BASEDIR + "/src/tests/resources/animal.xsl"); } private static String stripLineFeeds(String s) { Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Validator.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Validator.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_Validator.java 2009-04-23 04:05:44 UTC (rev 297) @@ -58,12 +58,12 @@ private File tempDTDFile; public void testXSchema() throws Exception{ - File xsdFile = new File(test_Constants.BASEDIR + "/tests/etc/Book.xsd"); + File xsdFile = new File(test_Constants.BASEDIR + "/src/tests/resources/Book.xsd"); assertTrue("xsdFile " + xsdFile.getAbsolutePath() + " exists", xsdFile.exists()); File xmlFile = new File(test_Constants.BASEDIR - + "/tests/etc/BookXsdGenerated.xml"); + + "/src/tests/resources/BookXsdGenerated.xml"); assertTrue("xmlFile " + xmlFile.getAbsolutePath() + " exists", xmlFile.exists()); validator = Modified: trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_XMLTestCase.java =================================================================== --- trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_XMLTestCase.java 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-java/org/custommonkey/xmlunit/test_XMLTestCase.java 2009-04-23 04:05:44 UTC (rev 297) @@ -102,23 +102,23 @@ */ public void testXMLEqualsFiles() throws Exception { assertXMLEqual(new FileReader( - test_Constants.BASEDIR + "/tests/etc/test1.xml"), + test_Constants.BASEDIR + "/src/tests/resources/test1.xml"), new FileReader( - test_Constants.BASEDIR + "/tests/etc/test1.xml")); + test_Constants.BASEDIR + "/src/tests/resources/test1.xml")); assertXMLNotEqual(new FileReader( - test_Constants.BASEDIR + "/tests/etc/test1.xml"), + test_Constants.BASEDIR + "/src/tests/resources/test1.xml"), new FileReader( - test_Constants.BASEDIR + "/tests/etc/test2.xml")); + test_Constants.BASEDIR + "/src/tests/resources/test2.xml")); // Bug 956372 assertXMLEqual("equal message", new FileReader( - test_Constants.BASEDIR + "/tests/etc/test1.xml"), + test_Constants.BASEDIR + "/src/tests/resources/test1.xml"), new FileReader( - test_Constants.BASEDIR + "/tests/etc/test1.xml")); + test_Constants.BASEDIR + "/src/tests/resources/test1.xml")); assertXMLNotEqual("notEqual message", new FileReader( - test_Constants.BASEDIR + "/tests/etc/test1.xml"), + test_Constants.BASEDIR + "/src/tests/resources/test1.xml"), new FileReader( - test_Constants.BASEDIR + "/tests/etc/test2.xml")); + test_Constants.BASEDIR + "/src/tests/resources/test2.xml")); try{ assertXMLNotEqual(new FileReader("nosuchfile.xml"), Modified: trunk/xmlunit/src/tests/legacy-net/ValidatorTests.cs =================================================================== --- trunk/xmlunit/src/tests/legacy-net/ValidatorTests.cs 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-net/ValidatorTests.cs 2009-04-23 04:05:44 UTC (rev 297) @@ -8,8 +8,8 @@ [TestFixture] public class ValidatorTests { - public static readonly string VALID_FILE = ".\\..\\tests\\etc\\BookXsdGenerated.xml"; - public static readonly string INVALID_FILE = ".\\..\\tests\\etc\\invalidBook.xml"; + public static readonly string VALID_FILE = ".\\..\\src\\tests\\resources\\BookXsdGenerated.xml"; + public static readonly string INVALID_FILE = ".\\..\\src\\tests\\resources\\invalidBook.xml"; [Test] public void XsdValidFileIsValid() { PerformAssertion(VALID_FILE, true); Modified: trunk/xmlunit/src/tests/legacy-net/XmlAssertionTests.cs =================================================================== --- trunk/xmlunit/src/tests/legacy-net/XmlAssertionTests.cs 2009-04-23 03:50:57 UTC (rev 296) +++ trunk/xmlunit/src/tests/legacy-net/XmlAssertionTests.cs 2009-04-23 04:05:44 UTC (rev 297) @@ -123,18 +123,18 @@ } [Test] public void AssertXslTransformResultsWorksWithXmlInput() { - StreamReader xsl = GetStreamReader(".\\..\\tests\\etc\\animal.xsl"); + StreamReader xsl = GetStreamReader(".\\..\\src\\tests\\resources\\animal.xsl"); XmlInput xslt = new XmlInput(xsl); - StreamReader xml = GetStreamReader(".\\..\\tests\\etc\\testAnimal.xml"); + StreamReader xml = GetStreamReader(".\\..\\src\\tests\\resources\\testAnimal.xml"); XmlInput xmlToTransform = new XmlInput(xml); XmlInput expectedXml = new XmlInput("<dog/>"); XmlAssertion.AssertXslTransformResults(xslt, xmlToTransform, expectedXml); } [Test] public void AssertXslTransformResultsCatchesFalsePositive() { - StreamReader xsl = GetStreamReader(".\\..\\tests\\etc\\animal.xsl"); + StreamReader xsl = GetStreamReader(".\\..\\src\\tests\\resources\\animal.xsl"); XmlInput xslt = new XmlInput(xsl); - StreamReader xml = GetStreamReader(".\\..\\tests\\etc\\testAnimal.xml"); + StreamReader xml = GetStreamReader(".\\..\\src\\tests\\resources\\testAnimal.xml"); XmlInput xmlToTransform = new XmlInput(xml); XmlInput expectedXml = new XmlInput("<cat/>"); bool caughtException = true; Property changes on: trunk/xmlunit/src/tests/resources ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/xmlunit/src/tests/resources/BookXsdGenerated.xml =================================================================== --- trunk/xmlunit/tests/etc/BookXsdGenerated.xml 2009-04-22 05:29:46 UTC (rev 294) +++ trunk/xmlunit/src/tests/resources/BookXsdGenerated.xml 2009-04-23 04:05:44 UTC (rev 297) @@ -1,5 +1,5 @@ <?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"> +<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 src/tests/resources/Book.xsd"> <Title>Chicken Soup for the Soul</Title> <Author>Jack Canfield</Author> <Author>Mark Victor Hansen</Author> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-04-23 11:37:35
|
Revision: 300 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=300&view=rev Author: bodewig Date: 2009-04-23 11:37:34 +0000 (Thu, 23 Apr 2009) Log Message: ----------- Add NUnit 2.4.8 Modified Paths: -------------- trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/lib/nunit.framework.dll Added: trunk/xmlunit/lib/nunit.framework.dll =================================================================== (Binary files differ) Property changes on: trunk/xmlunit/lib/nunit.framework.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2009-04-23 11:37:03 UTC (rev 299) +++ trunk/xmlunit/xmlunit.nant.build 2009-04-23 11:37:34 UTC (rev 300) @@ -14,7 +14,7 @@ <property name="nunit.v2.assembly" value="nunit.framework.dll" overwrite="false"/> <property name="nunit.v2.bin.dir" overwrite="false" - value="c:/apps/SharpDevelop/bin/nunit" /> + value="lib" /> <target name="init" description="prepare for other targets"> <mkdir dir="${bin.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-04 15:10:51
|
Revision: 309 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=309&view=rev Author: bodewig Date: 2009-05-04 15:10:48 +0000 (Mon, 04 May 2009) Log Message: ----------- Placeholder class file for XMLUnit-Java 2, first build system refactorings. Much more to come. Modified Paths: -------------- trunk/xmlunit/build.xml Added Paths: ----------- trunk/xmlunit/src/main/java-core/ trunk/xmlunit/src/main/java-core/net/ trunk/xmlunit/src/main/java-core/net/sf/ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2009-05-04 14:19:57 UTC (rev 308) +++ trunk/xmlunit/build.xml 2009-05-04 15:10:48 UTC (rev 309) @@ -1,35 +1,19 @@ <?xml version="1.0"?> <!-- -Copyright (c) 2001-2008, Jeff Martin, Tim Bacon -All rights reserved. + Licensed to the XMLUnit developers under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + 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 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: + http://www.apache.org/licenses/LICENSE-2.0 - * 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. + 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. --> <project name="xmlunit" default="test" basedir="."> @@ -37,14 +21,15 @@ <property file="build.properties"/> <!-- Version --> - <property name="xmlunit.version" value="1.3alpha"/> + <property name="xmlunit.version" value="2.0alpha"/> <!-- some locations --> <property name="src.dir" value="src/main"/> <property name="test.dir" value="src/tests"/> - <property name="build.dir" location="build"/> + <property name="build.dir" location="build/java"/> <property name="lib.dir" value="${build.dir}/lib"/> - <property name="out.dir" value="${build.dir}/classes"/> + <property name="core.out.dir" value="${build.dir}/core-classes"/> + <property name="legacy.out.dir" value="${build.dir}/legacy-classes"/> <property name="test.out.dir" value="${build.dir}/test-classes"/> <property name="userguide.out.dir" value="${build.dir}/ug-classes"/> <property name="test.report.dir" value="${build.dir}/test-report"/> @@ -53,33 +38,24 @@ <property name="userguide.docs.dir" value="${docs.dir}/userguide"/> <!-- javac properties --> - <property name="javac.source" value="1.3"/> - <property name="javac.target" value="1.3"/> + <property name="javac.source" value="5"/> + <property name="javac.target" value="5"/> <property name="javac.debug" value="true"/> <!-- junit task properties --> <property name="junit.fork" value="yes"/> - <!-- some library paths --> - <!-- where is JAXP? property name="${xmlxsl.lib}" location="."/ --> - <!-- Docbook related properties, macros and targets --> <import file="docbook.xml"/> <target name="-props"> - <available property="jaxp13+" classname="javax.xml.xpath.XPath"/> - <condition property="jaxp13+.impl"> - <and> - <isset property="jaxp13+"/> - <available classname="java.net.Proxy"/> - </and> - </condition> <available property="regexp.present" classname="java.util.regex.Matcher"/> </target> <target name="-init" depends="-props"> <mkdir dir="${lib.dir}"/> - <mkdir dir="${out.dir}"/> + <mkdir dir="${core.out.dir}"/> + <mkdir dir="${legacy.out.dir}"/> <mkdir dir="${test.out.dir}"/> <mkdir dir="${test.report.dir}"/> <mkdir dir="${dist.dir}"/> @@ -91,7 +67,8 @@ description="removes created directories"> <delete includeEmptyDirs="true" quiet="true"> <fileset dir="${lib.dir}"/> - <fileset dir="${out.dir}"/> + <fileset dir="${core.out.dir}"/> + <fileset dir="${legacy.out.dir}"/> <fileset dir="${test.out.dir}"/> <fileset dir="${test.report.dir}"/> <fileset dir="${dist.dir}"/> @@ -101,27 +78,33 @@ </delete> </target> - <target name="compile" depends="-init" - description="compiles sources and tests"> - <javac srcdir="${src.dir}/legacy-java" destdir="${out.dir}" + <target name="compile-core" depends="-init" + description="compiles legacy sources and tests"> + <javac srcdir="${src.dir}/java-core" destdir="${core.out.dir}" + debug="${javac.debug}" target="${javac.target}" + source="${javac.source}"> + </javac> + </target> + + <target name="compile" depends="compile-core" + description="compiles legacy sources and tests"> + <javac srcdir="${src.dir}/legacy-java" destdir="${legacy.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> - <pathelement location="${xmlxsl.lib}"/> + <pathelement location="${core.out.dir}"/> <pathelement path="${java.class.path}"/> <fileset dir="lib" includes="*.jar"/> </classpath> - <exclude name="**/jaxp13/**" unless="jaxp13+"/> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> </javac> <javac srcdir="${test.dir}/legacy-java" destdir="${test.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> - <pathelement location="${out.dir}"/> - <pathelement location="${xmlxsl.lib}"/> + <pathelement location="${core.out.dir}"/> + <pathelement location="${legacy.out.dir}"/> <pathelement path="${java.class.path}"/> <fileset dir="lib" includes="*.jar"/> </classpath> - <exclude name="**/jaxp13/**" unless="jaxp13+"/> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> </javac> </target> @@ -141,9 +124,9 @@ value="org.apache.xalan.processor.TransformerFactoryImpl"/> --> <classpath> - <pathelement location="${out.dir}"/> + <pathelement location="${core.out.dir}"/> + <pathelement location="${legacy.out.dir}"/> <pathelement location="${test.out.dir}"/> - <pathelement location="${xmlxsl.lib}"/> <pathelement path="${java.class.path}"/> <fileset dir="lib" includes="*.jar"/> </classpath> @@ -151,7 +134,6 @@ <batchtest todir="${test.report.dir}"> <fileset dir="${test.dir}/legacy-java"> <include name="**/test_*.java"/> - <exclude name="**/jaxp13/**" unless="jaxp13+.impl"/> </fileset> </batchtest> </junit> @@ -202,9 +184,16 @@ <target name="jar" depends="compile" description="creates jar, Maven2 POM and Ivy file"> - <jar jarfile="${lib.dir}/xmlunit-${xmlunit.version}.jar" - basedir="${out.dir}" + <jar jarfile="${lib.dir}/xmlunit-core-${xmlunit.version}.jar" + basedir="${core.out.dir}" /> + <jar jarfile="${lib.dir}/xmlunit-legacy-${xmlunit.version}.jar" + basedir="${legacy.out.dir}" + /> + <jar jarfile="${lib.dir}/xmlunit-sumo-${xmlunit.version}.jar"> + <fileset dir="${core.out.dir}"/> + <fileset dir="${legacy.out.dir}"/> + </jar> <tstamp> <format property="ivy.publication.datetime" pattern="yyyyMMddHHmmss"/> @@ -282,7 +271,7 @@ <javac srcdir="src/user-guide" includes="org/" destdir="${userguide.out.dir}" source="1.3" target="1.2"> <classpath> - <pathelement location="${out.dir}"/> + <pathelement location="${legacy.out.dir}"/> </classpath> </javac> <delete dir="${userguide.out.dir}"/> Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java 2009-05-04 15:10:48 UTC (rev 309) @@ -0,0 +1,44 @@ +/* + Licensed to the XMLUnit developers under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + 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.builder; + +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import org.w3c.dom.Document; + +public class Input { + + public static interface Builder { + Source build(); + } + + private static class DOMBuilder implements Builder { + private final Source source; + private DOMBuilder(Document d) { + source = new DOMSource(d); + } + public Source build() { + assert source != null; + return source; + } + } + + public static Builder fromDocument(Document d) { + return new DOMBuilder(d); + } +} + \ No newline at end of file Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java ___________________________________________________________________ Added: 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...> - 2009-05-04 15:16:14
|
Revision: 310 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=310&view=rev Author: bodewig Date: 2009-05-04 15:16:06 +0000 (Mon, 04 May 2009) Log Message: ----------- rename legacy directories Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/src/main/java-legacy/ trunk/xmlunit/src/main/net-legacy/ trunk/xmlunit/src/tests/java-legacy/ trunk/xmlunit/src/tests/net-legacy/ Removed Paths: ------------- trunk/xmlunit/src/main/legacy-java/ trunk/xmlunit/src/main/legacy-net/ trunk/xmlunit/src/tests/legacy-java/ trunk/xmlunit/src/tests/legacy-net/ Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2009-05-04 15:10:48 UTC (rev 309) +++ trunk/xmlunit/build.xml 2009-05-04 15:16:06 UTC (rev 310) @@ -88,7 +88,7 @@ <target name="compile" depends="compile-core" description="compiles legacy sources and tests"> - <javac srcdir="${src.dir}/legacy-java" destdir="${legacy.out.dir}" + <javac srcdir="${src.dir}/java-legacy" destdir="${legacy.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${core.out.dir}"/> @@ -97,7 +97,7 @@ </classpath> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> </javac> - <javac srcdir="${test.dir}/legacy-java" destdir="${test.out.dir}" + <javac srcdir="${test.dir}/java-legacy" destdir="${test.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${core.out.dir}"/> @@ -132,7 +132,7 @@ </classpath> <formatter type="xml"/> <batchtest todir="${test.report.dir}"> - <fileset dir="${test.dir}/legacy-java"> + <fileset dir="${test.dir}/java-legacy"> <include name="**/test_*.java"/> </fileset> </batchtest> @@ -156,12 +156,12 @@ description="creates the API documentation"> <delete includeEmptyDirs="true" dir="${docs.dir}/api"/> <javadoc destdir="${docs.dir}/api" - overview="${src.dir}/legacy-java/overview.html" + overview="${src.dir}/java-legacy/overview.html" windowtitle="XMLUnit Documentation" footer="<p><a href="http://xmlunit.sourceforge.net/">XMLUnit</a> is hosted by sourceforge.net</p>"> <group title="XMLUnit v${xmlunit.version}" packages="org.custommonkey.xmlunit*"/> - <fileset dir="${src.dir}/legacy-java"> + <fileset dir="${src.dir}/java-legacy"> <include name="org/custommonkey/**/*.java"/> </fileset> <classpath> Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2009-05-04 15:10:48 UTC (rev 309) +++ trunk/xmlunit/xmlunit.nant.build 2009-05-04 15:16:06 UTC (rev 310) @@ -2,8 +2,8 @@ <property name="project.version" value="0.4" overwrite="false"/> <property name="base.dir" value="${project::get-base-directory()}" overwrite="false"/> - <property name="src.dir" value="${base.dir}/src/main/legacy-net" overwrite="false"/> - <property name="tests.src.dir" value="${base.dir}/src/tests/legacy-net" + <property name="src.dir" value="${base.dir}/src/main/net-legacy" overwrite="false"/> + <property name="tests.src.dir" value="${base.dir}/src/tests/net-legacy" overwrite="false"/> <property name="bin.dir" value="${base.dir}/bin" overwrite="false"/> <property name="csc.verbose" value="false" overwrite="false"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-04 15:43:59
|
Revision: 311 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=311&view=rev Author: bodewig Date: 2009-05-04 15:43:53 +0000 (Mon, 04 May 2009) Log Message: ----------- Placeholder class files for XMLUnit.NET 2, first build system refactorings. Much more to come. Modified Paths: -------------- trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/src/main/net-core/ trunk/xmlunit/src/main/net-core/ISource.cs trunk/xmlunit/src/main/net-core/builder/ trunk/xmlunit/src/main/net-core/builder/Input.cs Added: trunk/xmlunit/src/main/net-core/ISource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/ISource.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/ISource.cs 2009-05-04 15:43:53 UTC (rev 311) @@ -0,0 +1,23 @@ +/* + Licensed to the XMLUnit developers under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + 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 { + public interface ISource { + XmlReader Reader {get;} + } +} Added: trunk/xmlunit/src/main/net-core/builder/Input.cs =================================================================== --- trunk/xmlunit/src/main/net-core/builder/Input.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/builder/Input.cs 2009-05-04 15:43:53 UTC (rev 311) @@ -0,0 +1,51 @@ +/* + Licensed to the XMLUnit developers under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + 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.builder { + public static class Input { + internal class Source : ISource { + private readonly XmlReader reader; + internal Source(XmlReader r) { + reader = r; + } + public XmlReader Reader { + get { + return reader; + } + } + } + + public interface IBuilder { + ISource Build(); + } + + internal class DOMBuilder : IBuilder { + private readonly ISource source; + internal DOMBuilder(XmlDocument d) { + source = new Source(new XmlNodeReader(d)); + } + public ISource Build() { + return source; + } + } + + public static IBuilder FromDocument(XmlDocument d) { + return new DOMBuilder(d); + } + } +} Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2009-05-04 15:16:06 UTC (rev 310) +++ trunk/xmlunit/xmlunit.nant.build 2009-05-04 15:43:53 UTC (rev 311) @@ -1,11 +1,15 @@ <project name="xmlunit" description="XmlUnit for .Net" default="compile"> - <property name="project.version" value="0.4" overwrite="false"/> + <property name="project.version" value="2.0" overwrite="false"/> <property name="base.dir" value="${project::get-base-directory()}" overwrite="false"/> - <property name="src.dir" value="${base.dir}/src/main/net-legacy" overwrite="false"/> + <property name="core.src.dir" value="${base.dir}/src/main/net-core" overwrite="false"/> + <property name="legacy.src.dir" value="${base.dir}/src/main/net-legacy" overwrite="false"/> <property name="tests.src.dir" value="${base.dir}/src/tests/net-legacy" overwrite="false"/> - <property name="bin.dir" value="${base.dir}/bin" overwrite="false"/> + + <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> + <property name="bin.dir" value="${build.dir}/bin" overwrite="false"/> + <property name="csc.verbose" value="false" overwrite="false"/> <property name="deploy.file" overwrite="false" value="${project::get-name()}-${project.version}.zip"/> @@ -24,19 +28,29 @@ <target name="clean" description="clean out compiled files"> <delete failonerror="false"> - <fileset basedir="${bin.dir}"> - <include name="${project::get-name()}.*"/> - </fileset> + <fileset basedir="${build.dir}"/> </delete> </target> - <target name="compile" description="compile all source files" depends="init"> - <csc target="library" output="${bin.dir}/${project::get-name()}.dll" + <target name="compile-core" + description="compile core source files" depends="init"> + <csc target="library" output="${bin.dir}/${project::get-name()}-core.dll" + debug="true" verbose="${csc.verbose}"> + <sources basedir="${core.src.dir}"> + <include name="**/*.cs"/> + </sources> + </csc> + </target> + + <target name="compile" description="compile all source files" + depends="compile-core"> + <csc target="library" output="${bin.dir}/${project::get-name()}-legacy.dll" debug="true" verbose="${csc.verbose}"> <references basedir="${bin.dir}"> + <include name="${project::get-name()}-core.dll"/> <include name="${nunit.v2.assembly}"/> </references> - <sources basedir="${src.dir}"> + <sources basedir="${legacy.src.dir}"> <include name="*.cs"/> </sources> </csc> @@ -45,7 +59,8 @@ output="${bin.dir}/${project::get-name()}.tests.dll" debug="true" verbose="${csc.verbose}"> <references basedir="${bin.dir}"> - <include name="${project::get-name()}.dll"/> + <include name="${project::get-name()}-core.dll"/> + <include name="${project::get-name()}-legacy.dll"/> <include name="${nunit.v2.assembly}"/> </references> <sources basedir="${tests.src.dir}"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-20 14:09:49
|
Revision: 328 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=328&view=rev Author: bodewig Date: 2009-05-20 14:09:41 +0000 (Wed, 20 May 2009) Log Message: ----------- Java tests for input builder Modified Paths: -------------- trunk/xmlunit/build.xml Added Paths: ----------- trunk/xmlunit/lib/junit-4.6.jar trunk/xmlunit/src/tests/java-core/ trunk/xmlunit/src/tests/java-core/net/ trunk/xmlunit/src/tests/java-core/net/sf/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2009-05-18 16:03:06 UTC (rev 327) +++ trunk/xmlunit/build.xml 2009-05-20 14:09:41 UTC (rev 328) @@ -30,7 +30,8 @@ <property name="lib.dir" value="${build.dir}/lib"/> <property name="core.out.dir" value="${build.dir}/core-classes"/> <property name="legacy.out.dir" value="${build.dir}/legacy-classes"/> - <property name="test.out.dir" value="${build.dir}/test-classes"/> + <property name="coretest.out.dir" value="${build.dir}/core-test-classes"/> + <property name="legacytest.out.dir" value="${build.dir}/legacy-test-classes"/> <property name="userguide.out.dir" value="${build.dir}/ug-classes"/> <property name="test.report.dir" value="${build.dir}/test-report"/> <property name="dist.dir" value="${build.dir}/dist"/> @@ -56,7 +57,8 @@ <mkdir dir="${lib.dir}"/> <mkdir dir="${core.out.dir}"/> <mkdir dir="${legacy.out.dir}"/> - <mkdir dir="${test.out.dir}"/> + <mkdir dir="${coretest.out.dir}"/> + <mkdir dir="${legacytest.out.dir}"/> <mkdir dir="${test.report.dir}"/> <mkdir dir="${dist.dir}"/> <mkdir dir="${docs.dir}"/> @@ -69,7 +71,8 @@ <fileset dir="${lib.dir}"/> <fileset dir="${core.out.dir}"/> <fileset dir="${legacy.out.dir}"/> - <fileset dir="${test.out.dir}"/> + <fileset dir="${coretest.out.dir}"/> + <fileset dir="${legacytest.out.dir}"/> <fileset dir="${test.report.dir}"/> <fileset dir="${dist.dir}"/> <fileset dir="${docs.dir}"/> @@ -86,55 +89,71 @@ </javac> </target> - <target name="compile" depends="compile-core" + <target name="compile-legacy" depends="compile-core" description="compiles legacy sources and tests"> <javac srcdir="${src.dir}/java-legacy" destdir="${legacy.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${core.out.dir}"/> <pathelement path="${java.class.path}"/> - <fileset dir="lib" includes="*.jar"/> + <fileset dir="lib" includes="junit-3*.jar"/> </classpath> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> </javac> - <javac srcdir="${test.dir}/java-legacy" destdir="${test.out.dir}" + </target> + + <target name="compile-legacy-tests" depends="compile-legacy" + description="Compiles the test for XMLUnit 1.x"> + <javac srcdir="${test.dir}/java-legacy" destdir="${legacytest.out.dir}" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> <classpath> <pathelement location="${core.out.dir}"/> <pathelement location="${legacy.out.dir}"/> <pathelement path="${java.class.path}"/> - <fileset dir="lib" includes="*.jar"/> + <fileset dir="lib" includes="junit-3*.jar"/> </classpath> <exclude name="**/*XPathRegexAssert.java" unless="regexp.present"/> </javac> </target> - <target name="test" depends="compile" - description="runs the tests"> + <target name="compile-core-tests" depends="compile-core" + description="Compiles the test for XMLUnit2"> + <javac srcdir="${test.dir}/java-core" destdir="${coretest.out.dir}" + debug="${javac.debug}" target="${javac.target}" + source="${javac.source}"> + <classpath> + <pathelement location="${core.out.dir}"/> + <pathelement path="${java.class.path}"/> + <fileset dir="lib" includes="junit-4*.jar"/> + </classpath> + </javac> + </target> + + <target name="compile" depends="compile-core,compile-legacy"/> + <target name="compile-tests" + depends="compile-core-tests,compile-legacy-tests"/> + + <target name="test" depends="compile-tests" description="runs the tests"> <junit printsummary="yes" haltonfailure="no" fork="${junit.fork}" forkMode="perBatch" failureproperty="tests.failed"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="user.dir" value="${basedir}"/> - <!-- - <sysproperty key="javax.xml.parsers.DocumentBuilderFactory" - value="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/> - <sysproperty key="javax.xml.parsers.SAXParserFactory" - value="org.apache.xerces.jaxp.SAXParserFactoryImpl"/> - <sysproperty key="javax.xml.transform.TransformerFactory" - value="org.apache.xalan.processor.TransformerFactoryImpl"/> - --> <classpath> <pathelement location="${core.out.dir}"/> <pathelement location="${legacy.out.dir}"/> - <pathelement location="${test.out.dir}"/> + <pathelement location="${legacytest.out.dir}"/> + <pathelement location="${coretest.out.dir}"/> <pathelement path="${java.class.path}"/> - <fileset dir="lib" includes="*.jar"/> + <fileset dir="lib" includes="junit-4*.jar"/> </classpath> <formatter type="xml"/> <batchtest todir="${test.report.dir}"> <fileset dir="${test.dir}/java-legacy"> <include name="**/test_*.java"/> </fileset> + <fileset dir="${test.dir}/java-core"> + <include name="**/*Test.java"/> + </fileset> </batchtest> </junit> Added: trunk/xmlunit/lib/junit-4.6.jar =================================================================== (Binary files differ) Property changes on: trunk/xmlunit/lib/junit-4.6.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2009-05-20 14:09:41 UTC (rev 328) @@ -0,0 +1,144 @@ +/* + 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.builder; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.net.URL; +import java.net.URI; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import org.w3c.dom.Document; +import static org.hamcrest.core.Is.*; +import static org.hamcrest.core.IsNull.*; +import static org.junit.Assert.*; +import org.junit.Test; + +public class InputTest { + + private static final String TEST_FILE = "src/tests/resources/test1.xml"; + + private static Document parse(Source s) throws Exception { + DocumentBuilder b = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + return b.parse(SAXSource.sourceToInputSource(s)); + } + + @Test public void shouldParseADocument() throws Exception { + Document d = parse(Input.fromFile(TEST_FILE).build()); + // it looks as if SAXSource.sourceToInputSource cannot deal + // with a DOMSource, so we cannot use the parse method + Source s = Input.fromDocument(d).build(); + assertThat(s, is(DOMSource.class)); + Object o = ((DOMSource) s).getNode(); + assertThat(o, is(Document.class)); + Document d2 = (Document) o; + assertThat(d2, notNullValue()); + assertThat(d2.getDocumentElement().getTagName(), is("animal")); + } + + @Test public void shouldParseAnExistingFileByName() throws Exception { + allIsWellFor(Input.fromFile(TEST_FILE).build()); + } + + @Test public void shouldParseAnExistingFileByFile() throws Exception { + allIsWellFor(Input.fromFile(new File(TEST_FILE)).build()); + } + + @Test public void shouldParseAnExistingFileFromStream() throws Exception { + FileInputStream is = null; + try { + is = new FileInputStream(TEST_FILE); + allIsWellFor(Input.fromStream(is).build()); + } finally { + if (is != null) { + is.close(); + } + } + } + + @Test public void shouldParseAnExistingFileFromReader() throws Exception { + FileReader r = null; + try { + r = new FileReader(TEST_FILE); + allIsWellFor(Input.fromReader(r).build()); + } finally { + if (r != null) { + r.close(); + } + } + } + + @Test public void shouldParseString() throws Exception { + allIsWellFor(Input.fromMemory(new String(readTestFile(), "UTF-8")) + .build()); + } + + @Test public void shouldParseBytes() throws Exception { + allIsWellFor(Input.fromMemory(readTestFile()).build()); + } + + @Test public void shouldParseFileFromURIString() throws Exception { + allIsWellFor(Input.fromURI("file:" + TEST_FILE).build()); + } + + @Test public void shouldParseFileFromURI() throws Exception { + allIsWellFor(Input.fromURI(new URI("file:" + TEST_FILE)).build()); + } + + @Test public void shouldParseFileFromURL() throws Exception { + allIsWellFor(Input.fromURL(new URL("file:" + TEST_FILE)).build()); + } + + @Test public void shouldParseATransformation() throws Exception { + Source input = Input.fromMemory("<animal>furry</animal>").build(); + Source s = Input.byTransforming(input) + .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl") + .build()) + .build(); + // again, transformed is a DOMSource, cannot use parse() + assertThat(s, is(DOMSource.class)); + Object o = ((DOMSource) s).getNode(); + assertThat(o, is(Document.class)); + Document d2 = (Document) o; + assertThat(d2, notNullValue()); + assertThat(d2.getDocumentElement().getTagName(), is("furry")); + } + + private static void allIsWellFor(Source s) throws Exception { + assertThat(s, notNullValue()); + Document d = parse(s); + assertThat(d, notNullValue()); + assertThat(d.getDocumentElement().getTagName(), is("animal")); + } + + private static byte[] readTestFile() throws Exception { + FileInputStream is = new FileInputStream(TEST_FILE); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int read = -1; + while ((read = is.read(buffer)) >= 0) { + if (read > 0) { + bos.write(buffer, 0, read); + } + } + is.close(); + return bos.toByteArray(); + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java ___________________________________________________________________ Added: 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...> - 2009-05-20 15:24:55
|
Revision: 330 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=330&view=rev Author: bodewig Date: 2009-05-20 15:24:44 +0000 (Wed, 20 May 2009) Log Message: ----------- upgrade to NUnit 2.5 Modified Paths: -------------- trunk/xmlunit/lib/nunit.framework.dll trunk/xmlunit/src/main/net-legacy/XmlAssertion.cs trunk/xmlunit/src/tests/net-legacy/DiffConfigurationTests.cs trunk/xmlunit/src/tests/net-legacy/ValidatorTests.cs trunk/xmlunit/src/tests/net-legacy/XmlAssertionTests.cs Modified: trunk/xmlunit/lib/nunit.framework.dll =================================================================== (Binary files differ) Modified: trunk/xmlunit/src/main/net-legacy/XmlAssertion.cs =================================================================== --- trunk/xmlunit/src/main/net-legacy/XmlAssertion.cs 2009-05-20 14:12:07 UTC (rev 329) +++ trunk/xmlunit/src/main/net-legacy/XmlAssertion.cs 2009-05-20 15:24:44 UTC (rev 330) @@ -2,7 +2,7 @@ using NUnit.Framework; using System.IO; - public class XmlAssertion : Assertion { + public class XmlAssertion : Assert { public static void AssertXmlEquals(TextReader controlTextReader, TextReader testTextReader) { AssertXmlEquals(new XmlDiff(controlTextReader, testTextReader)); } Modified: trunk/xmlunit/src/tests/net-legacy/DiffConfigurationTests.cs =================================================================== --- trunk/xmlunit/src/tests/net-legacy/DiffConfigurationTests.cs 2009-05-20 14:12:07 UTC (rev 329) +++ trunk/xmlunit/src/tests/net-legacy/DiffConfigurationTests.cs 2009-05-20 15:24:44 UTC (rev 330) @@ -21,7 +21,7 @@ new XmlDiff("", "").OptionalDescription); } - [Test] + [Test][Ignore("seems to fail because of schema location")] public void DefaultConfiguredToUseValidatingParser() { DiffConfiguration diffConfiguration = new DiffConfiguration(); Assert.AreEqual(DiffConfiguration.DEFAULT_USE_VALIDATING_PARSER, Modified: trunk/xmlunit/src/tests/net-legacy/ValidatorTests.cs =================================================================== --- trunk/xmlunit/src/tests/net-legacy/ValidatorTests.cs 2009-05-20 14:12:07 UTC (rev 329) +++ trunk/xmlunit/src/tests/net-legacy/ValidatorTests.cs 2009-05-20 15:24:44 UTC (rev 330) @@ -8,10 +8,11 @@ [TestFixture] public class ValidatorTests { - public static readonly string VALID_FILE = ".\\..\\src\\tests\\resources\\BookXsdGenerated.xml"; - public static readonly string INVALID_FILE = ".\\..\\src\\tests\\resources\\invalidBook.xml"; + public static readonly string VALID_FILE = "..\\..\\..\\src\\tests\\resources\\BookXsdGenerated.xml"; + public static readonly string INVALID_FILE = "..\\..\\..\\src\\tests\\resources\\invalidBook.xml"; - [Test] public void XsdValidFileIsValid() { + [Test][Ignore("seems to fail because of schema location")] + public void XsdValidFileIsValid() { PerformAssertion(VALID_FILE, true); } @@ -26,6 +27,7 @@ } } + [Ignore("validation seems to return the last error on .Net 2.0, need to double check")] [Test] public void XsdInvalidFileIsNotValid() { Validator validator = PerformAssertion(INVALID_FILE, false); Assert.IsFalse(validator.IsValid); Modified: trunk/xmlunit/src/tests/net-legacy/XmlAssertionTests.cs =================================================================== --- trunk/xmlunit/src/tests/net-legacy/XmlAssertionTests.cs 2009-05-20 14:12:07 UTC (rev 329) +++ trunk/xmlunit/src/tests/net-legacy/XmlAssertionTests.cs 2009-05-20 15:24:44 UTC (rev 330) @@ -48,6 +48,7 @@ Assert.IsTrue(caughtException); } + [Ignore("validation seems to return the last error on .Net 2.0, need to double check")] [Test] public void AssertXmlValidTrueForValidFile() { StreamReader reader = GetStreamReader(ValidatorTests.VALID_FILE); try { @@ -123,18 +124,18 @@ } [Test] public void AssertXslTransformResultsWorksWithXmlInput() { - StreamReader xsl = GetStreamReader(".\\..\\src\\tests\\resources\\animal.xsl"); + StreamReader xsl = GetStreamReader("..\\..\\..\\src\\tests\\resources\\animal.xsl"); XmlInput xslt = new XmlInput(xsl); - StreamReader xml = GetStreamReader(".\\..\\src\\tests\\resources\\testAnimal.xml"); + StreamReader xml = GetStreamReader("..\\..\\..\\src\\tests\\resources\\testAnimal.xml"); XmlInput xmlToTransform = new XmlInput(xml); XmlInput expectedXml = new XmlInput("<dog/>"); XmlAssertion.AssertXslTransformResults(xslt, xmlToTransform, expectedXml); } [Test] public void AssertXslTransformResultsCatchesFalsePositive() { - StreamReader xsl = GetStreamReader(".\\..\\src\\tests\\resources\\animal.xsl"); + StreamReader xsl = GetStreamReader("..\\..\\..\\src\\tests\\resources\\animal.xsl"); XmlInput xslt = new XmlInput(xsl); - StreamReader xml = GetStreamReader(".\\..\\src\\tests\\resources\\testAnimal.xml"); + StreamReader xml = GetStreamReader("..\\..\\..\\src\\tests\\resources\\testAnimal.xml"); XmlInput xmlToTransform = new XmlInput(xml); XmlInput expectedXml = new XmlInput("<cat/>"); bool caughtException = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-20 15:47:31
|
Revision: 331 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=331&view=rev Author: bodewig Date: 2009-05-20 15:47:19 +0000 (Wed, 20 May 2009) Log Message: ----------- port input builder test to .NET Modified Paths: -------------- trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/src/tests/net-core/ trunk/xmlunit/src/tests/net-core/builder/ trunk/xmlunit/src/tests/net-core/builder/InputTest.cs Copied: trunk/xmlunit/src/tests/net-core/builder/InputTest.cs (from rev 329, trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java) =================================================================== --- trunk/xmlunit/src/tests/net-core/builder/InputTest.cs (rev 0) +++ trunk/xmlunit/src/tests/net-core/builder/InputTest.cs 2009-05-20 15:47:19 UTC (rev 331) @@ -0,0 +1,106 @@ +/* + 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; +using System.IO; +using System.Text; +using System.Xml; +using NUnit.Framework; + +namespace net.sf.xmlunit.builder { + +[TestFixture] +public class InputTest { + + private const string TEST_FILE = "../../../src/tests/resources/test1.xml"; + + private static XmlDocument Parse(ISource s) { + XmlDocument d = new XmlDocument(); + d.Load(s.Reader); + return d; + } + + [Test] public void ShouldParseADocument() { + XmlDocument d = Parse(Input.FromFile(TEST_FILE).Build()); + AllIsWellFor(Input.FromDocument(d).Build()); + } + + [Test] public void ShouldParseAnExistingFileByName() { + AllIsWellFor(Input.FromFile(TEST_FILE).Build()); + } + + [Test] public void ShouldParseAnExistingFileFromStream() { + using (FileStream fs = new FileStream(TEST_FILE, FileMode.Open, + FileAccess.Read)) { + AllIsWellFor(Input.FromStream(fs).Build()); + } + } + + [Test] public void ShouldParseAnExistingFileFromReader() { + using (StreamReader r = new StreamReader(TEST_FILE)) { + AllIsWellFor(Input.FromReader(r).Build()); + } + } + + [Test] public void ShouldParseString() { + AllIsWellFor(Input.FromMemory(Encoding.UTF8.GetString(ReadTestFile())) + .Build()); + } + + [Test] public void ShouldParseBytes() { + AllIsWellFor(Input.FromMemory(ReadTestFile()).Build()); + } + + [Ignore("looks as if file-URIs didn't work, revisit")] + [Test] public void ShouldParseFileFromURIString() { + AllIsWellFor(Input.FromURI("file:" + TEST_FILE).Build()); + } + + [Ignore("looks as if file-URIs didn't work, revisit")] + [Test] public void ShouldParseFileFromURI() { + AllIsWellFor(Input.FromURI(new Uri("file:" + TEST_FILE)).Build()); + } + + [Test] public void ShouldParseATransformation() { + ISource input = Input.FromMemory("<animal>furry</animal>").Build(); + ISource s = Input.ByTransforming(input) + .WithStylesheet(Input.FromFile("../../../src/tests/resources/animal.xsl") + .Build()) + .Build(); + Assert.That(s, Is.Not.Null); + XmlDocument d = Parse(s); + Assert.That(d, Is.Not.Null); + Assert.That(d.DocumentElement.Name, Is.EqualTo("furry")); + } + + private static void AllIsWellFor(ISource s) { + Assert.That(s, Is.Not.Null); + XmlDocument d = Parse(s); + Assert.That(d, Is.Not.Null); + Assert.That(d.DocumentElement.Name, Is.EqualTo("animal")); + } + + private static byte[] ReadTestFile() { + using (FileStream fs = new FileStream(TEST_FILE, FileMode.Open, + FileAccess.Read)) + using (MemoryStream ms = new MemoryStream()) { + byte[] buffer = new byte[1024]; + int read = -1; + while ((read = fs.Read(buffer, 0, buffer.Length)) > 0) { + ms.Write(buffer, 0, read); + } + return ms.ToArray(); + } + } +} +} \ No newline at end of file Property changes on: trunk/xmlunit/src/tests/net-core/builder/InputTest.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: svn:eol-style + native Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2009-05-20 15:24:44 UTC (rev 330) +++ trunk/xmlunit/xmlunit.nant.build 2009-05-20 15:47:19 UTC (rev 331) @@ -4,8 +4,10 @@ overwrite="false"/> <property name="core.src.dir" value="${base.dir}/src/main/net-core" overwrite="false"/> <property name="legacy.src.dir" value="${base.dir}/src/main/net-legacy" overwrite="false"/> - <property name="tests.src.dir" value="${base.dir}/src/tests/net-legacy" + <property name="core.tests.src.dir" value="${base.dir}/src/tests/net-core" overwrite="false"/> + <property name="legacy.tests.src.dir" value="${base.dir}/src/tests/net-legacy" + overwrite="false"/> <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> <property name="bin.dir" value="${build.dir}/bin" overwrite="false"/> @@ -56,14 +58,25 @@ </csc> <csc target="library" - output="${bin.dir}/${project::get-name()}.tests.dll" + output="${bin.dir}/${project::get-name()}-core.tests.dll" debug="true" verbose="${csc.verbose}"> <references basedir="${bin.dir}"> <include name="${project::get-name()}-core.dll"/> + <include name="${nunit.v2.assembly}"/> + </references> + <sources basedir="${core.tests.src.dir}"> + <include name="**/*.cs"/> + </sources> + </csc> + <csc target="library" + output="${bin.dir}/${project::get-name()}-legacy.tests.dll" + debug="true" verbose="${csc.verbose}"> + <references basedir="${bin.dir}"> + <include name="${project::get-name()}-core.dll"/> <include name="${project::get-name()}-legacy.dll"/> <include name="${nunit.v2.assembly}"/> </references> - <sources basedir="${tests.src.dir}"> + <sources basedir="${legacy.tests.src.dir}"> <include name="*.cs"/> <exclude name="AllTests.cs"/> </sources> @@ -73,7 +86,8 @@ <target name="test" description="run all tests" depends="compile"> <nunit2> <formatter type="Plain"/> - <test assemblyname="${bin.dir}/${project::get-name()}.tests.dll"/> + <test assemblyname="${bin.dir}/${project::get-name()}-core.tests.dll"/> + <test assemblyname="${bin.dir}/${project::get-name()}-legacy.tests.dll"/> </nunit2> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-09-21 10:21:27
|
Revision: 356 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=356&view=rev Author: bodewig Date: 2009-09-21 10:21:20 +0000 (Mon, 21 Sep 2009) Log Message: ----------- document compareUnmatched option Modified Paths: -------------- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Property Changed: ---------------- trunk/xmlunit/ trunk/xmlunit/src/user-guide/ Property changes on: trunk/xmlunit ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x:355 Property changes on: trunk/xmlunit/src/user-guide ___________________________________________________________________ Modified: svn:mergeinfo - /branches/xmlunit-1.x/src/user-guide:346 + /branches/xmlunit-1.x/src/user-guide:346,355 Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2009-09-21 10:17:59 UTC (rev 355) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2009-09-21 10:21:20 UTC (rev 356) @@ -39,6 +39,11 @@ <date>June 2008</date> <revremark>Documentation for XMLUnit Java 1.2</revremark> </revision> + <revision> + <revnumber>1.3</revnumber> + <date>September 2009</date> + <revremark>Documentation for XMLUnit Java 1.3</revremark> + </revision> </revhistory> </articleinfo> @@ -2229,7 +2234,7 @@ <literal>DOMSource</literal> overrides when specifying your pieces of XML, XMLUnit will use the configured XML parsers (see <xref linkend="JAXP"/>) and <literal>EntityResolver</literal>s - (see <xref linkend="EntityResolver"/>). There configuration + (see <xref linkend="EntityResolver"/>). There are configuration options to use different settings for the control and test pieces of XML.</para> @@ -2362,9 +2367,46 @@ definitions the parser may expand them or not. Using <literal>XMLUnit.setExpandEntityReferences</literal> you can control the parser's setting.</para> + </section> + + <section id="Comparison of Unmatched Elements"> + <title>Comparison of Unmatched Elements</title> + + <para>When XMLUnit cannot match a control Element to a test + Element (the configured ElementQualifier - see + <xref linkend="ElementQualifier"/> - doesn't return true for + any of the test Elements) it will try to compare it against + the first unmatched test Element (if there is one). + Starting with XMLUnit 1.3 one can + use <literal>XMLUnit.setCompareUnmatched</literal> to + disable this behavior and + generate <literal>CHILD_NODE_NOT_FOUND</literal> differences + instead.</para> + + <para>If the control document is + <programlisting language="XML"><![CDATA[ +<root> + <a/> +</root> +]]></programlisting> + and the test document is + <programlisting language="XML"><![CDATA[ +<root> + <b/> +</root> +]]></programlisting> + + the default setting will create a + single <literal>ELEMENT_TAG_NAME</literal> Difference + ("expected a but found b"). + Setting <literal>XMLUnit.setCompareUnmatched</literal> to + false will create two Differences of + type <literal>CHILD_NODE_NOT_FOUND</literal> (one for "a" and + one for "b") instead.</para> + </section> + </section> - </section> <section id="Validating XML Documents"> @@ -3519,21 +3561,39 @@ <section id="Changes 1.3"> <title>Changes from XMLUnit 1.2 to 1.3</title> - <section id="Breaking Changes 1.2"> + <section id="Breaking Changes 1.3"> <title>Breaking Changes</title> - <itemizedlist> - </itemizedlist> + <!--itemizedlist> + </itemizedlist--> </section> - <section id="New Features 1.2"> + <section id="New Features 1.3"> <title>New Features</title> <itemizedlist> + <listitem> + If XMLUnit doesn't find a matching Element for a control + Element, it will match it against the first unmatched test + Element (if there is one) instead of creating + a <literal>CHILD_NODE_NOT_FOUND</literal> Difference. + There now is a new configuration + option <literal>compareUnmatched</literal> in + the <literal>XMLUnit</literal> class that can be used to + turn off this behavior - as a result + two <literal>CHILD_NODE_NOT_FOUND</literal> Differences + (one for the unmatched control Element and one for an + unmatched test Element) will be created instead of a + single Difference comparing the two likely unrelated + nodes. See <xref linkend="Comparison of Unmatched + Elements"/>. + <ulink + url="https://sourceforge.net/tracker/?func=detail&aid=2758280&group_id=23187&atid=377768">Issue 2758280</ulink>. + </listitem> </itemizedlist> </section> - <section id="Bugfixes 1.2"> + <section id="Bugfixes 1.3"> <title>Important Bug Fixes</title> <itemizedlist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-05-03 10:28:31
|
Revision: 377 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=377&view=rev Author: bodewig Date: 2010-05-03 10:28:25 +0000 (Mon, 03 May 2010) Log Message: ----------- make tests reusable in case there will ever be different implementations Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java trunk/xmlunit/src/tests/net-core/xpath/XPathEngineTest.cs Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/AbstractXPathEngineTest.java trunk/xmlunit/src/tests/net-core/xpath/AbstractXPathEngineTest.cs Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2010-05-03 10:26:23 UTC (rev 376) +++ trunk/xmlunit/build.xml 2010-05-03 10:28:25 UTC (rev 377) @@ -157,6 +157,7 @@ </fileset> <fileset dir="${test.dir}/java-core"> <include name="**/*Test.java"/> + <exclude name="**/Abstract*.java"/> </fileset> </batchtest> </junit> Copied: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/AbstractXPathEngineTest.java (from rev 374, trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java) =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/AbstractXPathEngineTest.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/AbstractXPathEngineTest.java 2010-05-03 10:28:25 UTC (rev 377) @@ -0,0 +1,137 @@ +/* + 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.xpath; + +import java.util.HashMap; +import java.util.Iterator; +import javax.xml.transform.Source; +import net.sf.xmlunit.TestResources; +import net.sf.xmlunit.builder.Input; +import net.sf.xmlunit.exceptions.XMLUnitException; +import org.junit.Before; +import org.junit.Test; +import org.w3c.dom.Node; + +import static org.junit.Assert.*; + +public abstract class AbstractXPathEngineTest { + + protected abstract IXPathEngine getEngine(); + + private Source source; + + @Before public void readSource() throws Exception { + source = Input.fromFile(TestResources.BLAME_FILE).build(); + } + + @Test public void selectNodesWithNoMatches() { + Iterable<Node> i = getEngine().selectNodes("foo", source); + assertNotNull(i); + assertFalse(i.iterator().hasNext()); + } + + @Test public void selectNodesWithSingleMatch() { + Iterable<Node> i = getEngine().selectNodes("//ul", source); + assertNotNull(i); + Iterator<Node> it = i.iterator(); + assertTrue(it.hasNext()); + assertEquals("ul", it.next().getNodeName()); + assertFalse(it.hasNext()); + } + + @Test public void selectNodesWithMultipleMatchs() { + Iterable<Node> i = getEngine().selectNodes("//li", source); + assertNotNull(i); + int count = 0; + for (Iterator<Node> it = i.iterator(); it.hasNext(); ) { + count++; + assertEquals("li", it.next().getNodeName()); + } + assertEquals(4, count); + } + + @Test(expected=XMLUnitException.class) + public void selectNodesWithInvalidXPath() { + getEngine().selectNodes("//li[", source); + } + + @Test public void evaluateWithNoMatches() { + assertEquals("", getEngine().evaluate("foo", source)); + } + + @Test public void evaluateWithSingleMatch() { + assertEquals("Don't blame it on the...", + getEngine().evaluate("//title", source)); + } + + @Test public void evaluateWithSingleMatchTextSelector() { + assertEquals("Don't blame it on the...", + getEngine().evaluate("//title/text()", source)); + } + + @Test public void evaluateWithMultipleMatches() { + assertEquals("sunshine", + getEngine().evaluate("//li", source)); + } + + @Test(expected=XMLUnitException.class) + public void evaluateWithInvalidXPath() { + getEngine().evaluate("//li[", source); + } + + @Test public void selectNodesWithNS() { + IXPathEngine e = getEngine(); + source = Input.fromMemory("<n:d xmlns:n='urn:test:1'><n:e/></n:d>") + .build(); + HashMap<String, String> m = new HashMap<String, String>(); + m.put("x", "urn:test:1"); + e.setNamespaceContext(m); + Iterable<Node> it = e.selectNodes("/x:d/x:e", source); + assertTrue(it.iterator().hasNext()); + } + + @Test public void selectNodesWithDefaultNS() { + IXPathEngine e = getEngine(); + source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") + .build(); + HashMap<String, String> m = new HashMap<String, String>(); + m.put("x", "urn:test:1"); + e.setNamespaceContext(m); + Iterable<Node> it = e.selectNodes("/x:d/x:e", source); + assertTrue(it.iterator().hasNext()); + } + + @Test public void selectNodesWithDefaultNSEmptyPrefix() { + IXPathEngine e = getEngine(); + source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") + .build(); + HashMap<String, String> m = new HashMap<String, String>(); + m.put("", "urn:test:1"); + e.setNamespaceContext(m); + Iterable<Node> it = e.selectNodes("/:d/:e", source); + assertTrue(it.iterator().hasNext()); + } + + // doesn't match + public void selectNodesWithDefaultNSNoPrefix() { + IXPathEngine e = getEngine(); + source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") + .build(); + HashMap<String, String> m = new HashMap<String, String>(); + m.put("", "urn:test:1"); + e.setNamespaceContext(m); + Iterable<Node> it = e.selectNodes("/d/e", source); + assertTrue(it.iterator().hasNext()); + } +} Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java 2010-05-03 10:26:23 UTC (rev 376) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java 2010-05-03 10:28:25 UTC (rev 377) @@ -13,123 +13,8 @@ */ package net.sf.xmlunit.xpath; -import java.util.HashMap; -import java.util.Iterator; -import javax.xml.transform.Source; -import net.sf.xmlunit.TestResources; -import net.sf.xmlunit.builder.Input; -import net.sf.xmlunit.exceptions.XMLUnitException; -import org.junit.Before; -import org.junit.Test; -import org.w3c.dom.Node; - -import static org.junit.Assert.*; - -public class JAXPXPathEngineTest { - - private Source source; - - @Before public void readSource() throws Exception { - source = Input.fromFile(TestResources.BLAME_FILE).build(); +public class JAXPXPathEngineTest extends AbstractXPathEngineTest { + @Override protected IXPathEngine getEngine() { + return new JAXPXPathEngine(); } - - @Test public void selectNodesWithNoMatches() { - Iterable<Node> i = new JAXPXPathEngine().selectNodes("foo", source); - assertNotNull(i); - assertFalse(i.iterator().hasNext()); - } - - @Test public void selectNodesWithSingleMatch() { - Iterable<Node> i = new JAXPXPathEngine().selectNodes("//ul", source); - assertNotNull(i); - Iterator<Node> it = i.iterator(); - assertTrue(it.hasNext()); - assertEquals("ul", it.next().getNodeName()); - assertFalse(it.hasNext()); - } - - @Test public void selectNodesWithMultipleMatchs() { - Iterable<Node> i = new JAXPXPathEngine().selectNodes("//li", source); - assertNotNull(i); - int count = 0; - for (Iterator<Node> it = i.iterator(); it.hasNext(); ) { - count++; - assertEquals("li", it.next().getNodeName()); - } - assertEquals(4, count); - } - - @Test(expected=XMLUnitException.class) - public void selectNodesWithInvalidXPath() { - new JAXPXPathEngine().selectNodes("//li[", source); - } - - @Test public void evaluateWithNoMatches() { - assertEquals("", new JAXPXPathEngine().evaluate("foo", source)); - } - - @Test public void evaluateWithSingleMatch() { - assertEquals("Don't blame it on the...", - new JAXPXPathEngine().evaluate("//title", source)); - } - - @Test public void evaluateWithSingleMatchTextSelector() { - assertEquals("Don't blame it on the...", - new JAXPXPathEngine().evaluate("//title/text()", source)); - } - - @Test public void evaluateWithMultipleMatches() { - assertEquals("sunshine", - new JAXPXPathEngine().evaluate("//li", source)); - } - - @Test(expected=XMLUnitException.class) - public void evaluateWithInvalidXPath() { - new JAXPXPathEngine().evaluate("//li[", source); - } - - @Test public void selectNodesWithNS() { - JAXPXPathEngine e = new JAXPXPathEngine(); - source = Input.fromMemory("<n:d xmlns:n='urn:test:1'><n:e/></n:d>") - .build(); - HashMap<String, String> m = new HashMap<String, String>(); - m.put("x", "urn:test:1"); - e.setNamespaceContext(m); - Iterable<Node> it = e.selectNodes("/x:d/x:e", source); - assertTrue(it.iterator().hasNext()); - } - - @Test public void selectNodesWithDefaultNS() { - JAXPXPathEngine e = new JAXPXPathEngine(); - source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") - .build(); - HashMap<String, String> m = new HashMap<String, String>(); - m.put("x", "urn:test:1"); - e.setNamespaceContext(m); - Iterable<Node> it = e.selectNodes("/x:d/x:e", source); - assertTrue(it.iterator().hasNext()); - } - - @Test public void selectNodesWithDefaultNSEmptyPrefix() { - JAXPXPathEngine e = new JAXPXPathEngine(); - source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") - .build(); - HashMap<String, String> m = new HashMap<String, String>(); - m.put("", "urn:test:1"); - e.setNamespaceContext(m); - Iterable<Node> it = e.selectNodes("/:d/:e", source); - assertTrue(it.iterator().hasNext()); - } - - // doesn't match - public void selectNodesWithDefaultNSNoPrefix() { - JAXPXPathEngine e = new JAXPXPathEngine(); - source = Input.fromMemory("<d xmlns='urn:test:1'><e/></d>") - .build(); - HashMap<String, String> m = new HashMap<String, String>(); - m.put("", "urn:test:1"); - e.setNamespaceContext(m); - Iterable<Node> it = e.selectNodes("/d/e", source); - assertTrue(it.iterator().hasNext()); - } } Copied: trunk/xmlunit/src/tests/net-core/xpath/AbstractXPathEngineTest.cs (from rev 375, trunk/xmlunit/src/tests/net-core/xpath/XPathEngineTest.cs) =================================================================== --- trunk/xmlunit/src/tests/net-core/xpath/AbstractXPathEngineTest.cs (rev 0) +++ trunk/xmlunit/src/tests/net-core/xpath/AbstractXPathEngineTest.cs 2010-05-03 10:28:25 UTC (rev 377) @@ -0,0 +1,145 @@ +/* + 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.Collections.Generic; +using System.Xml; +using NUnit.Framework; +using net.sf.xmlunit.builder; +using net.sf.xmlunit.exceptions; + +namespace net.sf.xmlunit.xpath { + + public abstract class AbstractXPathEngineTest { + + private ISource source; + + protected abstract IXPathEngine Engine { get; } + + [SetUp] public void ReadSource() { + source = Input.FromFile(TestResources.BLAME_FILE).Build(); + } + + [Test] public void SelectNodesWithNoMatches() { + IEnumerable<XmlNode> i = Engine.SelectNodes("foo", + source); + Assert.IsNotNull(i); + Assert.IsFalse(i.GetEnumerator().MoveNext()); + } + + [Test] public void SelectNodesWithSingleMatch() { + IEnumerable<XmlNode> i = Engine.SelectNodes("//ul", source); + Assert.IsNotNull(i); + IEnumerator<XmlNode> it = i.GetEnumerator(); + Assert.IsTrue(it.MoveNext()); + Assert.AreEqual("ul", it.Current.Name); + Assert.IsFalse(it.MoveNext()); + } + + [Test] public void SelectNodesWithMultipleMatchs() { + IEnumerable<XmlNode> i = Engine.SelectNodes("//li", source); + Assert.IsNotNull(i); + int count = 0; + foreach (XmlNode n in i) { + count++; + Assert.AreEqual("li", n.Name); + } + Assert.AreEqual(4, count); + } + + [Test] + public void SelectNodesWithInvalidXPath() { + try { + Engine.SelectNodes("//li[", source); + Assert.Fail("expected an exception"); + } catch (XMLUnitException) { + // expected + } + } + + [Test] public void EvaluateWithNoMatches() { + Assert.AreEqual(string.Empty, Engine.Evaluate("foo", source)); + } + + [Test] public void EvaluateWithSingleMatch() { + Assert.AreEqual("Don't blame it on the...", + Engine.Evaluate("//title", source)); + } + + [Test] public void EvaluateWithSingleMatchTextSelector() { + Assert.AreEqual("Don't blame it on the...", + Engine.Evaluate("//title/text()", source)); + } + + [Test] public void EvaluateWithMultipleMatches() { + Assert.AreEqual("sunshine", + Engine.Evaluate("//li", source)); + } + + [Test] + public void EvaluateWithInvalidXPath() { + try { + Engine.Evaluate("//li[", source); + Assert.Fail("expected an exception"); + } catch (XMLUnitException) { + // expected + } + } + + [Test] public void SelectNodesWithNS() { + IXPathEngine e = Engine; + source = Input.FromMemory("<n:d xmlns:n='urn:test:1'><n:e/></n:d>") + .Build(); + Dictionary<string, string> m = new Dictionary<string, string>(); + m["x"] = "urn:test:1"; + e.NamespaceContext = m; + IEnumerable<XmlNode> it = e.SelectNodes("/x:d/x:e", source); + Assert.IsTrue(it.GetEnumerator().MoveNext()); + } + + [Test] public void SelectNodesWithDefaultNS() { + IXPathEngine e = Engine; + source = Input.FromMemory("<d xmlns='urn:test:1'><e/></d>") + .Build(); + Dictionary<string, string> m = new Dictionary<string, string>(); + m["x"] = "urn:test:1"; + e.NamespaceContext = m; + IEnumerable<XmlNode> it = e.SelectNodes("/x:d/x:e", source); + Assert.IsTrue(it.GetEnumerator().MoveNext()); + } + + // throws an exception "'/:d/:e' has an invalid token." + public void SelectNodesWithDefaultNSEmptyPrefix() { + IXPathEngine e = Engine; + source = Input.FromMemory("<d xmlns='urn:test:1'><e/></d>") + .Build(); + Dictionary<string, string> m = new Dictionary<string, string>(); + m[string.Empty] = "urn:test:1"; + e.NamespaceContext = m; + IEnumerable<XmlNode> it = e.SelectNodes("/:d/:e", source); + Assert.IsTrue(it.GetEnumerator().MoveNext()); + } + + // doesn't match + public void SelectNodesWithDefaultNSNoPrefix() { + IXPathEngine e = Engine; + source = Input.FromMemory("<d xmlns='urn:test:1'><e/></d>") + .Build(); + Dictionary<string, string> m = new Dictionary<string, string>(); + m[string.Empty] = "urn:test:1"; + e.NamespaceContext = m; + IEnumerable<XmlNode> it = e.SelectNodes("/d/e", source); + Assert.IsTrue(it.GetEnumerator().MoveNext()); + } + } +} Modified: trunk/xmlunit/src/tests/net-core/xpath/XPathEngineTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/xpath/XPathEngineTest.cs 2010-05-03 10:26:23 UTC (rev 376) +++ trunk/xmlunit/src/tests/net-core/xpath/XPathEngineTest.cs 2010-05-03 10:28:25 UTC (rev 377) @@ -12,137 +12,16 @@ limitations under the License. */ -using System.Collections.Generic; -using System.Xml; using NUnit.Framework; -using net.sf.xmlunit.builder; -using net.sf.xmlunit.exceptions; namespace net.sf.xmlunit.xpath { [TestFixture] - public class XPathEngineTest { - - private ISource source; - - [SetUp] public void ReadSource() { - source = Input.FromFile(TestResources.BLAME_FILE).Build(); - } - - [Test] public void SelectNodesWithNoMatches() { - IEnumerable<XmlNode> i = new XPathEngine().SelectNodes("foo", - source); - Assert.IsNotNull(i); - Assert.IsFalse(i.GetEnumerator().MoveNext()); - } - - [Test] public void SelectNodesWithSingleMatch() { - IEnumerable<XmlNode> i = new XPathEngine().SelectNodes("//ul", - source); - Assert.IsNotNull(i); - IEnumerator<XmlNode> it = i.GetEnumerator(); - Assert.IsTrue(it.MoveNext()); - Assert.AreEqual("ul", it.Current.Name); - Assert.IsFalse(it.MoveNext()); - } - - [Test] public void SelectNodesWithMultipleMatchs() { - IEnumerable<XmlNode> i = new XPathEngine().SelectNodes("//li", - source); - Assert.IsNotNull(i); - int count = 0; - foreach (XmlNode n in i) { - count++; - Assert.AreEqual("li", n.Name); + public class XPathEngineTest : AbstractXPathEngineTest { + protected override IXPathEngine Engine { + get { + return new XPathEngine(); } - Assert.AreEqual(4, count); } - - [Test] - public void SelectNodesWithInvalidXPath() { - try { - new XPathEngine().SelectNodes("//li[", source); - Assert.Fail("expected an exception"); - } catch (XMLUnitException) { - // expected - } - } - - [Test] public void EvaluateWithNoMatches() { - Assert.AreEqual(string.Empty, new XPathEngine().Evaluate("foo", - source)); - } - - [Test] public void EvaluateWithSingleMatch() { - Assert.AreEqual("Don't blame it on the...", - new XPathEngine().Evaluate("//title", source)); - } - - [Test] public void EvaluateWithSingleMatchTextSelector() { - Assert.AreEqual("Don't blame it on the...", - new XPathEngine().Evaluate("//title/text()", - source)); - } - - [Test] public void EvaluateWithMultipleMatches() { - Assert.AreEqual("sunshine", - new XPathEngine().Evaluate("//li", source)); - } - - [Test] - public void EvaluateWithInvalidXPath() { - try { - new XPathEngine().Evaluate("//li[", source); - Assert.Fail("expected an exception"); - } catch (XMLUnitException) { - // expected - } - } - - [Test] public void SelectNodesWithNS() { - XPathEngine e = new XPathEngine(); - source = Input.FromMemory("<n:d xmlns:n='urn:test:1'><n:e/></n:d>") - .Build(); - Dictionary<string, string> m = new Dictionary<string, string>(); - m["x"] = "urn:test:1"; - e.NamespaceContext = m; - IEnumerable<XmlNode> it = e.SelectNodes("/x:d/x:e", source); - Assert.IsTrue(it.GetEnumerator().MoveNext()); - } - - [Test] public void SelectNodesWithDefaultNS() { - XPathEngine e = new XPathEngine(); - source = Input.FromMemory("<d xmlns='urn:test:1'><e/></d>") - .Build(); - Dictionary<string, string> m = new Dictionary<string, string>(); - m["x"] = "urn:test:1"; - e.NamespaceContext = m; - IEnumerable<XmlNode> it = e.SelectNodes("/x:d/x:e", source); - Assert.IsTrue(it.GetEnumerator().MoveNext()); - } - - // throws an exception "'/:d/:e' has an invalid token." - public void SelectNodesWithDefaultNSEmptyPrefix() { - XPathEngine e = new XPathEngine(); - source = Input.FromMemory("<d xmlns='urn:test:1'><e/></d>") - .Build(); - Dictionary<string, string> m = new Dictionary<string, string>(); - m[string.Empty] = "urn:test:1"; - e.NamespaceContext = m; - IEnumerable<XmlNode> it = e.SelectNodes("/:d/:e", source); - Assert.IsTrue(it.GetEnumerator().MoveNext()); - } - - // doesn't match - public void SelectNodesWithDefaultNSNoPrefix() { - XPathEngine e = new XPathEngine(); - source = Input.FromMemory("<d xmlns='urn:test:1'><e/></d>") - .Build(); - Dictionary<string, string> m = new Dictionary<string, string>(); - m[string.Empty] = "urn:test:1"; - e.NamespaceContext = m; - IEnumerable<XmlNode> it = e.SelectNodes("/d/e", source); - Assert.IsTrue(it.GetEnumerator().MoveNext()); - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-05-21 15:16:19
|
Revision: 399 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=399&view=rev Author: bodewig Date: 2010-05-21 15:16:13 +0000 (Fri, 21 May 2010) Log Message: ----------- fix/add license Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/xmlunit.nant.build Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2010-05-21 15:12:49 UTC (rev 398) +++ trunk/xmlunit/build.xml 2010-05-21 15:16:13 UTC (rev 399) @@ -1,19 +1,16 @@ <?xml version="1.0"?> <!-- - Licensed to the XMLUnit developers under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - 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 + 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 + 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. + 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. --> <project name="xmlunit" default="test" basedir="."> Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2010-05-21 15:12:49 UTC (rev 398) +++ trunk/xmlunit/xmlunit.nant.build 2010-05-21 15:16:13 UTC (rev 399) @@ -1,3 +1,17 @@ +<?xml version="1.0"?> +<!-- + 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. +--> <project name="xmlunit" description="XmlUnit for .Net" default="compile"> <property name="project.version" value="2.0" overwrite="false"/> <property name="base.dir" value="${project::get-base-directory()}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-05-21 15:19:21
|
Revision: 400 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=400&view=rev Author: bodewig Date: 2010-05-21 15:19:15 +0000 (Fri, 21 May 2010) Log Message: ----------- remove .NET legacy codebase Modified Paths: -------------- trunk/xmlunit/xmlunit.nant.build Removed Paths: ------------- trunk/xmlunit/src/main/net-legacy/ trunk/xmlunit/src/tests/net-legacy/ Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2010-05-21 15:16:13 UTC (rev 399) +++ trunk/xmlunit/xmlunit.nant.build 2010-05-21 15:19:15 UTC (rev 400) @@ -17,11 +17,8 @@ <property name="base.dir" value="${project::get-base-directory()}" overwrite="false"/> <property name="core.src.dir" value="${base.dir}/src/main/net-core" overwrite="false"/> - <property name="legacy.src.dir" value="${base.dir}/src/main/net-legacy" overwrite="false"/> <property name="core.tests.src.dir" value="${base.dir}/src/tests/net-core" overwrite="false"/> - <property name="legacy.tests.src.dir" value="${base.dir}/src/tests/net-legacy" - overwrite="false"/> <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> <property name="bin.dir" value="${build.dir}/bin" overwrite="false"/> @@ -43,9 +40,7 @@ </target> <target name="clean" description="clean out compiled files"> - <delete failonerror="false"> - <fileset basedir="${build.dir}"/> - </delete> + <delete dir="${build.dir}"/> </target> <target name="compile-core" @@ -60,17 +55,6 @@ <target name="compile" description="compile all source files" depends="compile-core"> - <csc target="library" output="${bin.dir}/${project::get-name()}-legacy.dll" - debug="true" verbose="${csc.verbose}"> - <references basedir="${bin.dir}"> - <include name="${project::get-name()}-core.dll"/> - <include name="${nunit.v2.assembly}"/> - </references> - <sources basedir="${legacy.src.dir}"> - <include name="*.cs"/> - </sources> - </csc> - <csc target="library" output="${bin.dir}/${project::get-name()}-core.tests.dll" debug="true" verbose="${csc.verbose}"> @@ -82,26 +66,12 @@ <include name="**/*.cs"/> </sources> </csc> - <csc target="library" - output="${bin.dir}/${project::get-name()}-legacy.tests.dll" - debug="true" verbose="${csc.verbose}"> - <references basedir="${bin.dir}"> - <include name="${project::get-name()}-core.dll"/> - <include name="${project::get-name()}-legacy.dll"/> - <include name="${nunit.v2.assembly}"/> - </references> - <sources basedir="${legacy.tests.src.dir}"> - <include name="*.cs"/> - <exclude name="AllTests.cs"/> - </sources> - </csc> </target> <target name="test" description="run all tests" depends="compile"> <nunit2> <formatter type="Plain"/> <test assemblyname="${bin.dir}/${project::get-name()}-core.tests.dll"/> - <test assemblyname="${bin.dir}/${project::get-name()}-legacy.tests.dll"/> </nunit2> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-06-21 09:03:06
|
Revision: 403 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=403&view=rev Author: bodewig Date: 2010-06-21 09:02:59 +0000 (Mon, 21 Jun 2010) Log Message: ----------- allow tests to access internal methods, reduce method visibility Modified Paths: -------------- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs trunk/xmlunit/xmlunit.nant.build Modified: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-06-18 15:21:25 UTC (rev 402) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-06-21 09:02:59 UTC (rev 403) @@ -66,7 +66,7 @@ /// difference evaluator evaluate the result, notifies all /// listeners and returns the outcome. /// </summary> - public ComparisonResult Compare(Comparison comp) { + internal ComparisonResult Compare(Comparison comp) { object controlValue = comp.ControlNodeDetails.Value; object testValue = comp.TestNodeDetails.Value; bool equal = controlValue == null @@ -78,8 +78,8 @@ return altered; } - public void FireComparisonPerformed(Comparison comp, - ComparisonResult outcome) { + private void FireComparisonPerformed(Comparison comp, + ComparisonResult outcome) { if (ComparisonListener != null) { ComparisonListener(comp, outcome); } Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2010-06-18 15:21:25 UTC (rev 402) +++ trunk/xmlunit/xmlunit.nant.build 2010-06-21 09:02:59 UTC (rev 403) @@ -12,14 +12,18 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project name="xmlunit" description="XmlUnit for .Net" default="compile"> +<project name="xmlunit" description="XMLUnit for .Net" default="compile"> <property name="project.version" value="2.0" overwrite="false"/> + <property name="project.version4" value="${project.version}.0.0" + overwrite="false"/> <property name="base.dir" value="${project::get-base-directory()}" overwrite="false"/> <property name="core.src.dir" value="${base.dir}/src/main/net-core" overwrite="false"/> <property name="core.tests.src.dir" value="${base.dir}/src/tests/net-core" overwrite="false"/> + <property name="gen.src.dir" value="${base.dir}/build/generated/net" + overwrite="false"/> <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> <property name="bin.dir" value="${build.dir}/bin" overwrite="false"/> @@ -34,6 +38,7 @@ value="lib" /> <target name="init" description="prepare for other targets"> + <mkdir dir="${gen.src.dir}"/> <mkdir dir="${bin.dir}"/> <copy file="${nunit.v2.bin.dir}/${nunit.v2.assembly}" tofile="${bin.dir}/${nunit.v2.assembly}"/> @@ -45,9 +50,32 @@ <target name="compile-core" description="compile core source files" depends="init"> + <asminfo output="${gen.src.dir}/AssemblyInfo.cs" language="CSharp"> + <imports> + <import namespace="System" /> + <import namespace="System.Reflection" /> + <import namespace="System.Runtime.InteropServices" /> + <import namespace="System.Runtime.CompilerServices" /> + </imports> + <attributes> + <attribute type="ComVisibleAttribute" value="false"/> + <attribute type="CLSCompliantAttribute" value="true"/> + <attribute type="AssemblyVersionAttribute" value="${project.version4}"/> + <attribute type="AssemblyTitleAttribute" value="XMLUnit Core" /> + <attribute type="AssemblyDescriptionAttribute" + value="Core Classes of XMLUnit for .NET" /> + <attribute type="InternalsVisibleToAttribute" + value="${project::get-name()}-core.tests"/> + </attributes> + </asminfo> + <copy todir="${gen.src.dir}"> + <fileset basedir="${core.src.dir}"> + <include name="**/*.cs"/> + </fileset> + </copy> <csc target="library" output="${bin.dir}/${project::get-name()}-core.dll" debug="true" verbose="${csc.verbose}"> - <sources basedir="${core.src.dir}"> + <sources basedir="${gen.src.dir}"> <include name="**/*.cs"/> </sources> </csc> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-06-21 14:37:58
|
Revision: 404 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=404&view=rev Author: bodewig Date: 2010-06-21 14:37:51 +0000 (Mon, 21 Jun 2010) Log Message: ----------- node type independent comparisons Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluators.java trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/lib/NUnitSummary.xsl trunk/xmlunit/lib/toolkit.xsl Added: trunk/xmlunit/lib/NUnitSummary.xsl =================================================================== --- trunk/xmlunit/lib/NUnitSummary.xsl (rev 0) +++ trunk/xmlunit/lib/NUnitSummary.xsl 2010-06-21 14:37:51 UTC (rev 404) @@ -0,0 +1,214 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- +The goal of the NUnit2Report task is to merge the individual XML files generated by the NUnit2 task and apply a stylesheet on the resulting merged document to provide a browsable report of the testcases results. + +This project is host on Sourceforge http://sourceforge.net/projects/nunit2report/ + +NUnit2Report is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. +--> +<!-- + This XSL File is based on the NUnitSummary.xsl + template created by Tomas Restrepo fot NAnt's NUnitReport. + + Modified by Gilles Bayon (gil...@la...) for use + with NUnit2Report. + +--> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:html="http://www.w3.org/Profiles/XHTML-transitional"> + + <xsl:output method="html" indent="yes"/> + <xsl:include href="toolkit.xsl"/> + <xsl:preserve-space elements="a root"/> + + +<!-- + ==================================================== + Create the page structure + ==================================================== +--> +<xsl:template match="test-results"> + <HTML> + <HEAD> + <style type="text/css"> + BODY { + font:normal 68% verdana,arial,helvetica; + color:#000000; + } + TD { + FONT-SIZE: 68% + } + P { + line-height:1.5em; + margin-top:0.5em; margin-bottom:1.0em; + } + H1 { + MARGIN: 0px 0px 5px; FONT: 165% verdana,arial,helvetica + } + H2 { + MARGIN-TOP: 1em; MARGIN-BOTTOM: 0.5em; FONT: bold 125% verdana,arial,helvetica + } + H3 { + MARGIN-BOTTOM: 0.5em; FONT: bold 115% verdana,arial,helvetica + } + H4 { + MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica + } + H5 { + MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica + } + H6 { + MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica + } + .Error { + font-weight:bold; background:#EEEEE0; color:purple; + } + .Failure { + font-weight:bold; background:#EEEEE0; color:red; + } + .FailureDetail { + font-size: -1; + padding-left: 2.0em; + } + .Pass { + background:#EEEEE0; + } + .TableHeader { + background: #6699cc; + color: white; + font-weight: bold; + horizontal-align: center; + } + .EnvInfoHeader { + background: #ff0000; + color: white; + font-weight: bold; + horizontal-align: center; + } + .EnvInfoRow { + background:#EEEEE0 + } + + A:visited { + color: #0000ff; + } + A { + color: #0000ff; + } + A:active { + color: #800000; + } + </style> + <script language="JavaScript"><![CDATA[ + function toggle (field) + { + field.style.display = (field.style.display == "block") ? "none" : "block"; + } ]]> + </script> + </HEAD> + <body text="#000000" bgColor="#ffffff"> + <a name="#top"/> + <xsl:call-template name="header"/> + + <!-- Summary part --> + <xsl:call-template name="summary"/> + <hr size="1" width="95%" align="left"/> + + <!-- Package List part --> + <xsl:call-template name="packagelist"/> + <hr size="1" width="95%" align="left"/> + + <!-- For each testsuite create the part --> + <xsl:call-template name="testsuites"/> + <hr size="1" width="95%" align="left"/> + + <!-- Environment info part --> + + <xsl:call-template name="envinfo"/> + + </body> + </HTML> +</xsl:template> + + + + <!-- ================================================================== --> + <!-- Write a list of all packages with an hyperlink to the anchor of --> + <!-- of the package name. --> + <!-- ================================================================== --> + <xsl:template name="packagelist"> + <h2 id=":i18n:TestSuiteSummary">TestSuite Summary</h2> + <table border="0" cellpadding="5" cellspacing="2" width="95%"> + <xsl:call-template name="packageSummaryHeader"/> + <!-- list all packages recursively --> + <xsl:for-each select="//test-suite[(child::results/test-case)]"> + <xsl:sort select="@name"/> + <xsl:variable name="testCount" select="count(child::results/test-case)"/> + <xsl:variable name="errorCount" select="count(child::results/test-case[@executed='False'])"/> + <xsl:variable name="failureCount" select="count(child::results/test-case[@success='False'])"/> + <xsl:variable name="timeCount" select="concat(substring-before(@time,','),'.',substring-after(@time,','))"/> + + <!-- write a summary for the package --> + <tr valign="top"> + <!-- set a nice color depending if there is an error/failure --> + <xsl:attribute name="class"> + <xsl:choose> + <xsl:when test="$failureCount > 0">Failure</xsl:when> + <xsl:when test="$errorCount > 0"> Error</xsl:when> + <xsl:otherwise>Pass</xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <td><a href="#{generate-id(@name)}"><xsl:value-of select="@name"/></a></td> + <td><xsl:value-of select="$testCount"/> + </td> + <td><xsl:value-of select="$errorCount"/></td> + <td><xsl:value-of select="$failureCount"/></td> + <td> + <xsl:call-template name="display-time"> + <xsl:with-param name="value" select="$timeCount"/> + </xsl:call-template> + </td> + </tr> + </xsl:for-each> + </table> + </xsl:template> + + + <xsl:template name="testsuites"> + <script language="JScript"><![CDATA[ + function ToggleRow(id) { + if ( id.style.display == "none" ) + id.style.display = "block"; + else + id.style.display = "none"; + } + ]]></script> + + <xsl:for-each select="//test-suite[(child::results/test-case)]"> + <xsl:sort select="@name"/> + <!-- create an anchor to this class name --> + <a name="#{generate-id(@name)}"/> + <h3>TestSuite <xsl:value-of select="@name"/></h3> + + <table border="0" cellpadding="5" cellspacing="2" width="95%"> + <!-- Header --> + <xsl:call-template name="classesSummaryHeader"/> + + <!-- match the testcases of this package --> + <xsl:apply-templates select="results/test-case"> + <xsl:sort select="@name"/> + </xsl:apply-templates> + </table> + <a href="#top" id=":i18n:Backtotop">Back to top</a> + </xsl:for-each> + </xsl:template> + + + <xsl:template name="dot-replace"> + <xsl:param name="package"/> + <xsl:choose> + <xsl:when test="contains($package,'.')"><xsl:value-of select="substring-before($package,'.')"/>_<xsl:call-template name="dot-replace"><xsl:with-param name="package" select="substring-after($package,'.')"/></xsl:call-template></xsl:when> + <xsl:otherwise><xsl:value-of select="$package"/></xsl:otherwise> + </xsl:choose> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file Property changes on: trunk/xmlunit/lib/NUnitSummary.xsl ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/xmlunit/lib/toolkit.xsl =================================================================== --- trunk/xmlunit/lib/toolkit.xsl (rev 0) +++ trunk/xmlunit/lib/toolkit.xsl 2010-06-21 14:37:51 UTC (rev 404) @@ -0,0 +1,420 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- +The goal of the NUnit2Report task is to merge the individual XML files generated by the NUnit2 task and apply a stylesheet on the resulting merged document to provide a browsable report of the testcases results. + +This project is host on Sourceforge http://sourceforge.net/projects/nunit2report/ + +NUnit2Report is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. +--> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:nunit2report="urn:my-scripts"> +<xsl:param name="nant.filename"/> +<xsl:param name="nant.version"/> +<xsl:param name="nant.project.name"/> +<xsl:param name="nant.project.buildfile"/> +<xsl:param name="nant.project.basedir"/> +<xsl:param name="nant.project.default"/> +<xsl:param name="sys.os"/> +<xsl:param name="sys.os.platform"/> +<xsl:param name="sys.os.version"/> +<xsl:param name="sys.clr.version"/> + +<msxsl:script language="C#" implements-prefix="nunit2report"> + + public string TestCaseName(string path) { + + string[] a = path.Split('.'); + + return(a[a.Length-1]); + } + +</msxsl:script> + +<!-- + TO DO + Corriger les alignement sur error + Couleur http://nanning.sourceforge.net/junit-report.html +--> + + +<!-- + format a number in to display its value in percent + @param value the number to format +--> +<xsl:template name="display-time"> + <xsl:param name="value"/> + <xsl:value-of select="format-number($value,'0.000')"/> +</xsl:template> + +<!-- + format a number in to display its value in percent + @param value the number to format +--> +<xsl:template name="display-percent"> + <xsl:param name="value"/> + <xsl:value-of select="format-number($value,'0.00 %')"/> +</xsl:template> + +<!-- + transform string like a.b.c to ../../../ + @param path the path to transform into a descending directory path +--> +<xsl:template name="path"> + <xsl:param name="path"/> + <xsl:if test="contains($path,'.')"> + <xsl:text>../</xsl:text> + <xsl:call-template name="path"> + <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param> + </xsl:call-template> + </xsl:if> + <xsl:if test="not(contains($path,'.')) and not($path = '')"> + <xsl:text>../</xsl:text> + </xsl:if> +</xsl:template> + +<!-- + template that will convert a carriage return into a br tag + @param word the text from which to convert CR to BR tag +--> +<xsl:template name="br-replace"> + <xsl:param name="word"/> + <xsl:choose> + <xsl:when test="contains($word,' +')"> + <xsl:value-of select="substring-before($word,' +')"/> + <br/> + <xsl:call-template name="br-replace"> + <xsl:with-param name="word" select="substring-after($word,' +')"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$word"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- + ===================================================================== + classes summary header + ===================================================================== +--> +<xsl:template name="header"> + <xsl:param name="path"/> + <h1><span id=":i18n:UnitTestsResults">Unit Tests Results</span> - <xsl:value-of select="$nant.project.name"/></h1> + <table width="100%"> + <tr> + <td align="left"> + <span id=":i18n:GeneratedBy">Generated by</span>\xA0<a target="_blank" href="http://sourceforge.net/projects/nunit2report/">NUnit2Report</a> : <xsl:value-of select="@date"/> - <xsl:value-of select="concat(@time,' ')"/>\xA0<a href="#envinfo" id=":i18n:EnvironmentInformation">Environment Information</a> + </td> + <td align="right"><span id=":i18n:Designed">Designed for use with</span>\xA0<a href="http://nunit.sourceforge.net/">NUnit</a>\xA0<span id=":i18n:and">and</span>\xA0<a href="http://nant.sourceforge.net/">NAnt</a>. + </td> + </tr> + </table> + <hr size="1"/> +</xsl:template> + +<xsl:template name="summaryHeader"> + <tr valign="top" class="TableHeader"> + <td width="50px"><b id=":i18n:Tests">Tests</b></td> + <td width="70px"><b id=":i18n:Failures">Failures</b></td> + <td width="70px"><b id=":i18n:Errors">Errors</b></td> + <td colspan="2"><b id=":i18n:SuccessRate">Success Rate</b></td> + <td width="70px" nowrap="nowrap"><b id=":i18n:Time">Time(s)</b></td> + </tr> +</xsl:template> + +<!-- + ===================================================================== + package summary header + ===================================================================== +--> +<xsl:template name="packageSummaryHeader"> + <tr class="TableHeader" valign="top"> + <td width="75%" colspan="3"><b id=":i18n:Name">Name</b></td> + <td width="5%"><b id=":i18n:Tests">Tests</b></td> + <td width="5%"><b id=":i18n:Errors">Errors</b></td> + <td width="5%"><b id=":i18n:Failures">Failures</b></td> + <td width="10%" nowrap="nowrap"><b id=":i18n:Time">Time(s)</b></td> + </tr> +</xsl:template> + + +<!-- + ===================================================================== + classes summary header + ===================================================================== +--> +<xsl:template name="classesSummaryHeader"> + <tr class="TableHeader" valign="top"> + <td width="85%" colspan="2"><b id=":i18n:Name">Name</b></td> + <td width="10%"><b id=":i18n:Status">Status</b></td> + <td width="5%" nowrap="nowrap"><b id=":i18n:Time">Time(s)</b></td> + </tr> +</xsl:template> + +<!-- + ===================================================================== + Write the summary report + It creates a table with computed values from the document: + User | Date | Environment | Tests | Failures | Errors | Rate | Time + Note : this template must call at the testsuites level + ===================================================================== +--> + <xsl:template name="summary"> + <h2 id=":i18n:Summary">Summary</h2> + <xsl:variable name="runCount" select="@total"/> + <xsl:variable name="failureCount" select="@failures"/> + <xsl:variable name="ignoreCount" select="@not-run"/> + <xsl:variable name="total" select="$runCount + $ignoreCount + $failureCount"/> + + <xsl:variable name="timeCount" select="translate(test-suite/@time,',','.')"/> + + <xsl:variable name="successRate" select="$runCount div $total"/> + <table border="0" cellpadding="2" cellspacing="0" width="95%" style="border: #dcdcdc 1px solid;"> + <xsl:call-template name="summaryHeader"/> + <tr valign="top"> + <xsl:attribute name="class"> + <xsl:choose> + <xsl:when test="$failureCount > 0">Failure</xsl:when> + <xsl:when test="$ignoreCount > 0">Error</xsl:when> + <xsl:otherwise>Pass</xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <td><xsl:value-of select="$runCount"/></td> + <td><xsl:value-of select="$failureCount"/></td> + <td><xsl:value-of select="$ignoreCount"/></td> + <td nowrap="nowrap" width="70px"> + <xsl:call-template name="display-percent"> + <xsl:with-param name="value" select="$successRate"/> + </xsl:call-template> + </td> + <td> + <xsl:if test="round($runCount * 200 div $total )!=0"> + <span class="covered"> + <xsl:attribute name="style">width:<xsl:value-of select="round($runCount * 200 div $total )"/>px</xsl:attribute> + </span> + </xsl:if> + <xsl:if test="round($ignoreCount * 200 div $total )!=0"> + <span class="ignored"> + <xsl:attribute name="style">width:<xsl:value-of select="round($ignoreCount * 200 div $total )"/>px</xsl:attribute> + </span> + </xsl:if> + <xsl:if test="round($failureCount * 200 div $total )!=0"> + <span class="uncovered"> + <xsl:attribute name="style">width:<xsl:value-of select="round($failureCount * 200 div $total )"/>px</xsl:attribute> + </span> + </xsl:if> + </td> + <td> + <xsl:call-template name="display-time"> + <xsl:with-param name="value" select="$timeCount"/> + </xsl:call-template> + </td> + </tr> + </table> + <span id=":i18n:Note">Note</span>: <i id=":i18n:failures">failures</i>\xA0<span id=":i18n:anticipated">are anticipated and checked for with assertions while</span>\xA0<i id=":i18n:errors">errors</i>\xA0<span id=":i18n:unanticipated">are unanticipated.</span> + </xsl:template> + +<!-- + ===================================================================== + testcase report + ===================================================================== +--> +<xsl:template match="test-case"> + <xsl:param name="summary.xml"/> + <xsl:param name="open.description"/> + + <xsl:variable name="summaries" select="document($summary.xml)"/> + + <xsl:variable name="Mname" select="concat('M:',./@name)"/> + + <xsl:variable name="result"> + <xsl:choose> + <xsl:when test="./failure"><span id=":i18n:Failure">Failure</span></xsl:when> + <xsl:when test="./error"><span id=":i18n:Error">Error</span></xsl:when> + <xsl:when test="@executed='False'"><span id=":i18n:Ignored">Ignored</span></xsl:when> + <xsl:otherwise><span id=":i18n:Pass">Pass</span></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="newid" select="generate-id(@name)"/> + <tr valign="top"> + <xsl:attribute name="class"><xsl:value-of select="$result"/></xsl:attribute> + + <td width="20%"> + <xsl:choose> + <xsl:when test="$summary.xml != ''"> + <!-- Triangle image --> + <a title="Show/Hide XML Comment" class="summarie"><xsl:attribute name="href">javascript:Toggle('<xsl:value-of select="concat('M:',$newid)"/>');ToggleImage('<xsl:value-of select="concat('I:',$newid)"/>')</xsl:attribute><xsl:attribute name="id"><xsl:value-of select="concat('I:',$newid)"/></xsl:attribute> + <!-- Set the good triangle image 6/4 font-family:Webdings--> + <xsl:choose> + <xsl:when test="$result != "Pass"">-</xsl:when> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$open.description='yes'">-</xsl:when> + <xsl:otherwise>+</xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </a> + </xsl:when> + </xsl:choose> + <!-- If failure, add click on the test method name and color red --> + <xsl:choose> + <xsl:when test="$result = 'Failure' or $result = 'Error'">\xA0<a title="Show/Hide message error"> + <xsl:attribute name="href">javascript:Toggle('<xsl:value-of select="$newid"/>')</xsl:attribute> + <xsl:attribute name="class">error</xsl:attribute> + <xsl:value-of select="nunit2report:TestCaseName(./@name)"/> + </a> + </xsl:when> + <xsl:when test="$result = 'Ignored'">\xA0<a title="Show/Hide message error"> + <xsl:attribute name="href">javascript:Toggle('<xsl:value-of select="$newid"/>')</xsl:attribute> + <xsl:attribute name="class">ignored</xsl:attribute> + <xsl:value-of select="nunit2report:TestCaseName(./@name)"/> + </a> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="class">method</xsl:attribute>\xA0<xsl:value-of select="nunit2report:TestCaseName(./@name)"/> + </xsl:otherwise> + </xsl:choose> + </td> + <td width="65%" style="padding-left:3px" height="9px"> + <xsl:choose> + <xsl:when test="$result = 'Pass'"> + <span class="covered" style="width:200px"/> + </xsl:when> + <xsl:when test="$result = 'Ignored'"> + <span class="ignored" style="width:200px"/> + </xsl:when> + <xsl:when test="$result = 'Failure' or $result = 'Error'"> + <span class="uncovered" style="width:200px"/> + </xsl:when> + </xsl:choose> + <!-- The test method description--> + <xsl:choose> + <xsl:when test="$summary.xml != ''"> + <div class="description" style="display:block"> + <!-- Attribute id --> + <xsl:attribute name="id"><xsl:value-of select="concat('M:',$newid)"/></xsl:attribute> + <!-- Open method description if failure --> + <xsl:choose> + <xsl:when test="$result != "Pass""> + <xsl:attribute name="style">display:block</xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$open.description = 'yes'"> + <xsl:attribute name="style">display:block</xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="style">display:none</xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + <!-- The description of the test method --> + <xsl:value-of select="normalize-space($summaries//member[@name=$Mname]/summary/text())"/> + </div> + </xsl:when> + </xsl:choose> + </td> + <td><xsl:attribute name="id">:i18n:<xsl:value-of select="$result"/></xsl:attribute><xsl:value-of select="$result"/></td> + <td> + <xsl:call-template name="display-time"> + <xsl:with-param name="value" select="@time"/> + </xsl:call-template> + </td> + </tr> + + <xsl:if test="$result != "Pass""> + <tr style="display: block;"> + <xsl:attribute name="id"> + <xsl:value-of select="$newid"/> + </xsl:attribute> + <td colspan="4" class="FailureDetail"> + <xsl:apply-templates select="./failure"/> + <xsl:apply-templates select="./error"/> + <xsl:apply-templates select="./reason"/> + </td> + </tr> + </xsl:if> +</xsl:template> + +<!-- Note : the below template error and failure are the same style + so just call the same style store in the toolkit template --> +<!-- <xsl:template match="failure"> + <xsl:call-template name="display-failures"/> +</xsl:template> + +<xsl:template match="error"> + <xsl:call-template name="display-failures"/> +</xsl:template> --> + +<!-- Style for the error and failure in the tescase template --> +<!-- <xsl:template name="display-failures"> + <xsl:choose> + <xsl:when test="not(@message)">N/A</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@message"/> + </xsl:otherwise> + </xsl:choose> --> + <!-- display the stacktrace --> +<!-- <code> + <p/> + <xsl:call-template name="br-replace"> + <xsl:with-param name="word" select="."/> + </xsl:call-template> + </code> --> + <!-- the later is better but might be problematic for non-21" monitors... --> + <!--pre><xsl:value-of select="."/></pre--> +<!-- </xsl:template> + --> + +<!-- + ===================================================================== + Environtment Info Report + ===================================================================== +--> +<xsl:template name="envinfo"> + <a name="envinfo"/> + <h2 id=":i18n:EnvironmentInformation">Environment Information</h2> + <table border="0" cellpadding="5" cellspacing="2" width="95%"> + <tr class="TableHeader"> + <td id=":i18n:Property">Property</td> + <td id=":i18n:Value">Value</td> + </tr> + <tr> + <td id=":i18n:NAntLocation">NAnt Location</td> + <td><xsl:value-of select="$nant.filename"/></td> + </tr> + <tr> + <td id=":i18n:NAntVersion">NAnt Version</td> + <td><xsl:value-of select="$nant.version"/></td> + </tr> + <tr> + <td id=":i18n:Buildfile">Buildfile</td> + <td><xsl:value-of select="$nant.project.buildfile"/></td> + </tr> + <tr> + <td id=":i18n:BaseDirectory">Base Directory</td> + <td><xsl:value-of select="$nant.project.basedir"/></td> + </tr> + <tr> + <td id=":i18n:OperatingSystem">Operating System</td> + <td><xsl:value-of select="$sys.os"/></td> + </tr> + <tr> + <td id=":i18n:NETCLRVersion">.NET CLR Version</td> + <td><xsl:value-of select="$sys.clr.version"/></td> + </tr> + </table> + <a href="#top" id=":i18n:Backtotop">Back to top</a> +</xsl:template> + +<!-- I am sure that all nodes are called --> +<xsl:template match="*"> + <xsl:apply-templates/> +</xsl:template> + +</xsl:stylesheet> \ No newline at end of file Property changes on: trunk/xmlunit/lib/toolkit.xsl ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2010-06-21 09:02:59 UTC (rev 403) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2010-06-21 14:37:51 UTC (rev 404) @@ -16,6 +16,7 @@ import net.sf.xmlunit.util.Convert; import javax.xml.transform.Source; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.w3c.dom.Document; /** @@ -74,7 +75,54 @@ compareNodes(Convert.toNode(control), Convert.toNode(test)); } - private ComparisonResult compareNodes(Node control, Node test) { + /** + * Recursively compares two XML nodes. + * + * <p>Performs comparisons common to all node types, the performs + * the node type specific comparisons and finally recures into + * the node's child lists.</p> + * + * <p>Stops as soon as any comparison returns + * ComparisonResult.CRITICAL.</p> + * + * <p>package private to support tests.</p> + */ + ComparisonResult compareNodes(Node control, Node test) { + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.NODE_TYPE, control, + null, control.getNodeType(), + test, null, test.getNodeType())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + lastResult = + compare(new Comparison(ComparisonType.NAMESPACE_URI, control, + null, control.getNamespaceURI(), + test, null, test.getNamespaceURI())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + lastResult = + compare(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, + null, control.getPrefix(), + test, null, test.getPrefix())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + NodeList controlChildren = control.getChildNodes(); + NodeList testChildren = test.getChildNodes(); + lastResult = + compare(new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, + control, null, controlChildren.getLength(), + test, null, testChildren.getLength())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + /* TODO node type specific stuff */ + return compareNodeLists(controlChildren, testChildren); + } + + ComparisonResult compareNodeLists(NodeList control, NodeList test) { return ComparisonResult.EQUAL; } 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-06-21 09:02:59 UTC (rev 403) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DifferenceEvaluators.java 2010-06-21 14:37:51 UTC (rev 404) @@ -67,7 +67,7 @@ * evaluator to decide which differences leave the documents * simlar. */ - public static final DifferenceEvaluator defaultStopWhenDifferent + public static final DifferenceEvaluator DefaultStopWhenDifferent = stopWhenDifferent(Default); /** Modified: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-06-21 09:02:59 UTC (rev 403) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-06-21 14:37:51 UTC (rev 404) @@ -57,7 +57,53 @@ net.sf.xmlunit.util.Convert.ToNode(test)); } - private ComparisonResult CompareNodes(XmlNode control, XmlNode test) { + /// <summary> + /// Recursively compares two XML nodes. + /// </summary> + /// <remarks> + /// Performs comparisons common to all node types, the performs + /// the node type specific comparisons and finally recures into + /// the node's child lists. + /// + /// Stops as soon as any comparison returns ComparisonResult.CRITICAL. + /// </remarks> + internal ComparisonResult CompareNodes(XmlNode control, XmlNode test) { + ComparisonResult lastResult = + Compare(new Comparison(ComparisonType.NODE_TYPE, control, + null, control.NodeType, + test, null, test.NodeType)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + lastResult = + Compare(new Comparison(ComparisonType.NAMESPACE_URI, control, + null, control.NamespaceURI, + test, null, test.NamespaceURI)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + lastResult = + Compare(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, + null, control.Prefix, + test, null, test.Prefix)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + XmlNodeList controlChildren = control.ChildNodes; + XmlNodeList testChildren = test.ChildNodes; + lastResult = + Compare(new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, + control, null, controlChildren.Count, + test, null, testChildren.Count)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + /* TODO node type specific stuff */ + return CompareNodeLists(controlChildren, testChildren); + } + + ComparisonResult CompareNodeLists(XmlNodeList control, + XmlNodeList test) { return ComparisonResult.EQUAL; } 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-06-21 09:02:59 UTC (rev 403) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java 2010-06-21 14:37:51 UTC (rev 404) @@ -13,7 +13,12 @@ */ package net.sf.xmlunit.diff; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.junit.Before; import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; import static org.junit.Assert.*; public class DOMDifferenceEngineTest { @@ -111,4 +116,106 @@ null, null, new Short("2")))); assertEquals(1, l.getInvocations()); } + + private static class DiffExpecter implements ComparisonListener { + private int invoked = 0; + private final int expectedInvocations; + private final ComparisonType type; + private DiffExpecter(ComparisonType type) { + this(type, 1); + } + private DiffExpecter(ComparisonType type, int expected) { + this.type = type; + this.expectedInvocations = expected; + } + public void comparisonPerformed(Comparison comparison, + ComparisonResult outcome) { + assertTrue(invoked < expectedInvocations); + invoked++; + assertEquals(type, comparison.getType()); + assertEquals(ComparisonResult.CRITICAL, outcome); + } + } + + private Document doc; + + @Before public void createDoc() throws Exception { + doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .newDocument(); + } + + @Test public void compareNodesOfDifferentType() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.NODE_TYPE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(doc.createElement("x"), + doc.createComment("x"))); + assertEquals(1, ex.invoked); + } + + @Test public void compareNodesWithoutNS() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.NODE_TYPE, 0); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(doc.createElement("x"), + doc.createElement("x"))); + assertEquals(0, ex.invoked); + } + + @Test public void compareNodesDifferentNS() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.NAMESPACE_URI); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(doc.createElementNS("x", "y"), + doc.createElementNS("z", "y"))); + assertEquals(1, ex.invoked); + } + + @Test public void compareNodesDifferentPrefix() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.NAMESPACE_PREFIX); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(new DifferenceEvaluator() { + public ComparisonResult evaluate(Comparison comparison, + ComparisonResult outcome) { + if (comparison.getType() + == ComparisonType.NAMESPACE_PREFIX) { + assertEquals(ComparisonResult.DIFFERENT, outcome); + return ComparisonResult.CRITICAL; + } + assertEquals(ComparisonResult.EQUAL, outcome); + return ComparisonResult.EQUAL; + } + }); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(doc.createElementNS("x", "x:y"), + doc.createElementNS("x", "z:y"))); + assertEquals(1, ex.invoked); + } + + @Test public void compareNodesDifferentNumberOfChildren() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = + new DiffExpecter(ComparisonType.CHILD_NODELIST_LENGTH, 2); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + Element e1 = doc.createElement("x"); + Element e2 = doc.createElement("x"); + assertEquals(ComparisonResult.EQUAL, d.compareNodes(e1, e2)); + e1.appendChild(doc.createElement("x")); + assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e2)); + assertEquals(1, ex.invoked); + e2.appendChild(doc.createElement("x")); + assertEquals(ComparisonResult.EQUAL, d.compareNodes(e1, e2)); + e2.appendChild(doc.createElement("x")); + assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e2)); + assertEquals(2, ex.invoked); + } + } Modified: trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs 2010-06-21 09:02:59 UTC (rev 403) +++ trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs 2010-06-21 14:37:51 UTC (rev 404) @@ -12,6 +12,7 @@ limitations under the License. */ using System; +using System.Xml; using NUnit.Framework; namespace net.sf.xmlunit.diff { @@ -124,5 +125,117 @@ Convert.ToInt16("2")))); Assert.AreEqual(1, invocations); } + + private XmlDocument doc; + + [SetUp] + public void CreateDoc() { + doc = new XmlDocument(); + } + + [Test] + public void CompareNodesOfDifferentType() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + int invocations = 0; + d.DifferenceListener += delegate(Comparison comp, + ComparisonResult r) { + Assert.AreEqual(0, invocations); + invocations++; + Assert.AreEqual(ComparisonType.NODE_TYPE, comp.Type); + Assert.AreEqual(ComparisonResult.CRITICAL, r); + }; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.CRITICAL, + d.CompareNodes(doc.CreateElement("x"), + doc.CreateComment("x"))); + Assert.AreEqual(1, invocations); + } + + [Test] + public void CompareNodesWithoutNS() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + d.DifferenceListener += delegate(Comparison comp, + ComparisonResult r) { + Assert.Fail("unexpected invocation"); + }; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.EQUAL, + d.CompareNodes(doc.CreateElement("x"), + doc.CreateElement("x"))); + } + + [Test] + public void CompareNodesDifferentNS() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + int invocations = 0; + d.DifferenceListener += delegate(Comparison comp, + ComparisonResult r) { + Assert.AreEqual(0, invocations); + invocations++; + Assert.AreEqual(ComparisonType.NAMESPACE_URI, comp.Type); + Assert.AreEqual(ComparisonResult.CRITICAL, r); + }; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.CRITICAL, + d.CompareNodes(doc.CreateElement("y", "x"), + doc.CreateElement("y", "z"))); + Assert.AreEqual(1, invocations); + } + + [Test] + public void CompareNodesDifferentPrefix() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + int invocations = 0; + d.DifferenceListener += delegate(Comparison comp, + ComparisonResult r) { + Assert.AreEqual(0, invocations); + invocations++; + Assert.AreEqual(ComparisonType.NAMESPACE_PREFIX, comp.Type); + Assert.AreEqual(ComparisonResult.CRITICAL, r); + }; + d.DifferenceEvaluator = delegate(Comparison comparison, + ComparisonResult outcome) { + if (comparison.Type == ComparisonType.NAMESPACE_PREFIX) { + Assert.AreEqual(ComparisonResult.DIFFERENT, outcome); + return ComparisonResult.CRITICAL; + } + Assert.AreEqual(ComparisonResult.EQUAL, outcome); + return ComparisonResult.EQUAL; + }; + Assert.AreEqual(ComparisonResult.CRITICAL, + d.CompareNodes(doc.CreateElement("x:y", "x"), + doc.CreateElement("z:y", "x"))); + Assert.AreEqual(1, invocations); + } + + [Test] + public void CompareNodesDifferentNumberOfChildren() { + DOMDifferenceEngine d = new DOMDifferenceEngine(); + int invocations = 0; + d.DifferenceListener += delegate(Comparison comp, + ComparisonResult r) { + Assert.Greater(2, invocations); + invocations++; + Assert.AreEqual(ComparisonType.CHILD_NODELIST_LENGTH, + comp.Type); + Assert.AreEqual(ComparisonResult.CRITICAL, r); + }; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + XmlElement e1 = doc.CreateElement("x"); + XmlElement e2 = doc.CreateElement("x"); + Assert.AreEqual(ComparisonResult.EQUAL, d.CompareNodes(e1, e2)); + e1.AppendChild(doc.CreateElement("x")); + Assert.AreEqual(ComparisonResult.CRITICAL, d.CompareNodes(e1, e2)); + Assert.AreEqual(1, invocations); + e2.AppendChild(doc.CreateElement("x")); + Assert.AreEqual(ComparisonResult.EQUAL, d.CompareNodes(e1, e2)); + e2.AppendChild(doc.CreateElement("x")); + Assert.AreEqual(ComparisonResult.CRITICAL, d.CompareNodes(e1, e2)); + Assert.AreEqual(2, invocations); + } } } Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2010-06-21 09:02:59 UTC (rev 403) +++ trunk/xmlunit/xmlunit.nant.build 2010-06-21 14:37:51 UTC (rev 404) @@ -25,6 +25,7 @@ <property name="gen.src.dir" value="${base.dir}/build/generated/net" overwrite="false"/> <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> + <property name="test.report.dir" value="${build.dir}/test-report"/> <property name="bin.dir" value="${build.dir}/bin" overwrite="false"/> <property name="csc.verbose" value="false" overwrite="false"/> @@ -99,8 +100,12 @@ <target name="test" description="run all tests" depends="compile"> <nunit2> <formatter type="Plain"/> + <formatter type="Xml" usefile="true" outputdir="${test.report.dir}"/> <test assemblyname="${bin.dir}/${project::get-name()}-core.tests.dll"/> </nunit2> + <style style="lib/NUnitSummary.xsl" + in="${test.report.dir}/${project::get-name()}-core.tests.dll-results" + out="${test.report.dir}/html/index.html"/> </target> <target name="deploy" description="zip all code for deployment" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-06-28 15:25:50
|
Revision: 408 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=408&view=rev Author: bodewig Date: 2010-06-28 15:25:39 +0000 (Mon, 28 Jun 2010) Log Message: ----------- XSLT as poor man's code generator to get rid of the repetitive 'if last comparison resulted in a CRITICAL difference, break out of the method' logic Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/src/buildtools/ trunk/xmlunit/src/buildtools/codegen.xslt trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml Removed Paths: ------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2010-06-28 11:49:08 UTC (rev 407) +++ trunk/xmlunit/build.xml 2010-06-28 15:25:39 UTC (rev 408) @@ -24,6 +24,7 @@ <property name="src.dir" value="src/main"/> <property name="test.dir" value="src/tests"/> <property name="build.dir" location="build/java"/> + <property name="gen.src.dir" value="${build.dir}/generated"/> <property name="lib.dir" value="${build.dir}/lib"/> <property name="core.out.dir" value="${build.dir}/core-classes"/> <property name="legacy.out.dir" value="${build.dir}/legacy-classes"/> @@ -60,6 +61,7 @@ <mkdir dir="${dist.dir}"/> <mkdir dir="${docs.dir}"/> <mkdir dir="${userguide.docs.dir}"/> + <mkdir dir="${gen.src.dir}"/> </target> <target name="clean" @@ -78,9 +80,30 @@ </delete> </target> - <target name="compile-core" depends="-init" - description="compiles legacy sources and tests"> - <javac srcdir="${src.dir}/java-core" destdir="${core.out.dir}" + <target name="-generate-sources" depends="-init"> + <xslt destdir="${gen.src.dir}" + useImplicitFileset="false" + style="src/buildtools/codegen.xslt"> + <fileset dir="${src.dir}/java-core" includes="**/*.java.xml"/> + <globmapper from="*.java.xml" to="*.java"/> + + <param name="nsQualifier" expression="package"/> + <param name="nsStart" expression=";"/> + <param name="nsEnd" expression=""/> + <param name="import" expression="import"/> + <param name="extends" expression="extends"/> + <param name="implements" expression="implements"/> + <param name="summaryStart" expression="/** "/> + <param name="summaryEnd" expression="*/"/> + + <param name="compareMethod" expression="compare"/> + </xslt> + </target> + + <target name="compile-core" depends="-init,-generate-sources" + description="compiles core sources"> + <javac srcdir="${src.dir}/java-core:${gen.src.dir}" + destdir="${core.out.dir}" includeantruntime="false" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> @@ -88,7 +111,7 @@ </target> <target name="compile-legacy" depends="compile-core" - description="compiles legacy sources and tests"> + description="compiles legacy sources"> <javac srcdir="${src.dir}/java-legacy" destdir="${legacy.out.dir}" includeantruntime="false" debug="${javac.debug}" target="${javac.target}" source="${javac.source}"> Added: trunk/xmlunit/src/buildtools/codegen.xslt =================================================================== --- trunk/xmlunit/src/buildtools/codegen.xslt (rev 0) +++ trunk/xmlunit/src/buildtools/codegen.xslt 2010-06-28 15:25:39 UTC (rev 408) @@ -0,0 +1,130 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0" + xmlns:html="http://www.w3.org/Profiles/XHTML-transitional"> + + <xsl:output method="text" indent="no"/> + + <xsl:param name="compareMethod"/> + <xsl:param name="nsQualifier"/> + <xsl:param name="nsStart"/> + <xsl:param name="nsEnd"/> + <xsl:param name="import"/> + <xsl:param name="extends"/> + <xsl:param name="implements"/> + <xsl:param name="summaryStart"/> + <xsl:param name="summaryEnd"/> + + <xsl:template match="class"> +/* + 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. +*/ + <xsl:value-of select="$nsQualifier"/> + <xsl:text> </xsl:text> + <xsl:value-of select="@ns"/> + <xsl:value-of select="$nsStart"/> + <xsl:text> + </xsl:text> + + <xsl:apply-templates mode="imports" select="import"/> + + <xsl:value-of select="$summaryStart"/> + <xsl:value-of select="@summary"/> + <xsl:text> + </xsl:text> + <xsl:value-of select="$summaryEnd"/> + <xsl:text> +</xsl:text> + + <xsl:value-of select="@qualifiers"/> + <xsl:text> </xsl:text> + class + <xsl:value-of select="@name"/> + <xsl:if test="@extends"> + <xsl:text> </xsl:text> + <xsl:value-of select="$extends"/> + <xsl:text> </xsl:text> + <xsl:value-of select="@extends"/> + </xsl:if> + <xsl:if test="@implements"> + <xsl:text> </xsl:text> + <xsl:value-of select="$implements"/> + <xsl:text> </xsl:text> + <xsl:value-of select="@implements"/> + </xsl:if> + + { + <xsl:apply-templates/> + } + <xsl:value-of select="$nsEnd"/> + </xsl:template> + + <xsl:template match="import" mode="imports"> + <xsl:value-of select="$import"/> + <xsl:text> </xsl:text> + <xsl:value-of select="@reference"/>; + </xsl:template> + + <xsl:template match="lastResultDef"> + ComparisonResult lastResult = ComparisonResult.CRITICAL; + </xsl:template> + + <xsl:template match="compare"> + lastResult = + <xsl:value-of select="$compareMethod"/>(new Comparison(ComparisonType.<xsl:value-of select="@type"/>, + control, null, + control.<xsl:value-of select="@property"/>, + test, null, + test.<xsl:value-of select="@property"/>)); + <xsl:call-template name="if-return-boilerplate"/> + </xsl:template> + + <xsl:template match="compareExpr"> + lastResult = + <xsl:value-of select="$compareMethod"/>(new Comparison(ComparisonType.<xsl:value-of select="@type"/>, + control, null, + <xsl:value-of select="@controlExpr"/>, + test, null, + <xsl:value-of select="@testExpr"/>)); + <xsl:call-template name="if-return-boilerplate"/> + </xsl:template> + + <xsl:template match="compareMethod"> + lastResult = <xsl:value-of select="@method"/>(control, test); + <xsl:call-template name="if-return-boilerplate"/> + </xsl:template> + + <xsl:template match="compareMethodExpr"> + lastResult = <xsl:value-of select="@method"/>(<xsl:value-of select="@controlExpr"/>, <xsl:value-of select="@testExpr"/>); + <xsl:call-template name="if-return-boilerplate"/> + </xsl:template> + + <xsl:template name="if-return-boilerplate"> + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + </xsl:template> +</xsl:stylesheet> Property changes on: trunk/xmlunit/src/buildtools/codegen.xslt ___________________________________________________________________ Added: svn:eol-style + native Deleted: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2010-06-28 11:49:08 UTC (rev 407) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2010-06-28 15:25:39 UTC (rev 408) @@ -1,219 +0,0 @@ -/* - 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; -import net.sf.xmlunit.util.Convert; -import org.w3c.dom.CharacterData; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.ProcessingInstruction; - -/** - * Difference engine based on DOM. - */ -public final class DOMDifferenceEngine extends AbstractDifferenceEngine { - - public void compare(Source control, Source test) { - if (control == null) { - throw new IllegalArgumentException("control must not be null"); - } - if (test == null) { - throw new IllegalArgumentException("test must not be null"); - } - compareNodes(Convert.toNode(control), Convert.toNode(test)); - } - - /** - * Recursively compares two XML nodes. - * - * <p>Performs comparisons common to all node types, the performs - * the node type specific comparisons and finally recures into - * the node's child lists.</p> - * - * <p>Stops as soon as any comparison returns - * ComparisonResult.CRITICAL.</p> - * - * <p>package private to support tests.</p> - */ - ComparisonResult compareNodes(Node control, Node test) { - ComparisonResult lastResult = - compare(new Comparison(ComparisonType.NODE_TYPE, control, - null, control.getNodeType(), - test, null, test.getNodeType())); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - lastResult = - compare(new Comparison(ComparisonType.NAMESPACE_URI, control, - null, control.getNamespaceURI(), - test, null, test.getNamespaceURI())); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - lastResult = - compare(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, - null, control.getPrefix(), - test, null, test.getPrefix())); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - NodeList controlChildren = control.getChildNodes(); - NodeList testChildren = test.getChildNodes(); - lastResult = - compare(new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, - control, null, controlChildren.getLength(), - test, null, testChildren.getLength())); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - lastResult = nodeTypeSpecificComparison(control, test); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - return compareNodeLists(controlChildren, testChildren); - } - - /** - * Dispatches to the node type specific comparison if one is - * defined for the given combination of nodes. - * - * <p>package private to support tests.</p> - */ - ComparisonResult nodeTypeSpecificComparison(Node control, Node test) { - switch (control.getNodeType()) { - case Node.CDATA_SECTION_NODE: - case Node.COMMENT_NODE: - case Node.TEXT_NODE: - if (test instanceof CharacterData) { - return compareCharacterData((CharacterData) control, - (CharacterData) test); - } - break; - case Node.DOCUMENT_NODE: - if (test instanceof Document) { - return compareDocuments((Document) control, - (Document) test); - } - break; - case Node.ELEMENT_NODE: - if (test instanceof Element) { - return compareElements((Element) control, - (Element) test); - } - break; - case Node.PROCESSING_INSTRUCTION_NODE: - if (test instanceof ProcessingInstruction) { - return - compareProcessingInstructions((ProcessingInstruction) control, - (ProcessingInstruction) test); - } - break; - } - return ComparisonResult.EQUAL; - } - - /** - * Compares textual content. - */ - private ComparisonResult compareCharacterData(CharacterData control, - CharacterData test) { - return compare(new Comparison(ComparisonType.TEXT_VALUE, control, - null, control.getData(), - test, null, test.getData())); - } - - ComparisonResult compareDocuments(Document control, - Document test) { - DocumentType controlDt = control.getDoctype(); - DocumentType testDt = test.getDoctype(); - ComparisonResult r = - compare(new Comparison(ComparisonType.HAS_DOCTYPE_DECLARATION, - control, null, - Boolean.valueOf(controlDt != null), - test, null, - Boolean.valueOf(testDt != null))); - if (r == ComparisonResult.CRITICAL) { - return r; - } - if (controlDt != null && testDt != null) { - r = compareDocTypes(controlDt, testDt); - } - if (r == ComparisonResult.CRITICAL) { - return r; - } - r = compare(new Comparison(ComparisonType.XML_VERSION, - control, null, control.getXmlVersion(), - test, null, test.getXmlVersion())); - if (r == ComparisonResult.CRITICAL) { - return r; - } - r = compare(new Comparison(ComparisonType.XML_STANDALONE, - control, null, control.getXmlStandalone(), - test, null, test.getXmlStandalone())); - if (r == ComparisonResult.CRITICAL) { - return r; - } - return compare(new Comparison(ComparisonType.XML_ENCODING, - control, null, control.getXmlEncoding(), - test, null, test.getXmlEncoding())); - } - - ComparisonResult compareDocTypes(DocumentType control, - DocumentType test) { - ComparisonResult r = - compare(new Comparison(ComparisonType.DOCTYPE_NAME, - control, null, control.getName(), - test, null, test.getName())); - if (r == ComparisonResult.CRITICAL) { - return r; - } - r = compare(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, - control, null, control.getPublicId(), - test, null, test.getPublicId())); - if (r == ComparisonResult.CRITICAL) { - return r; - } - return compare(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, - control, null, control.getSystemId(), - test, null, test.getSystemId())); - } - - ComparisonResult compareElements(Element control, - Element test) { - return ComparisonResult.EQUAL; - } - - ComparisonResult - compareProcessingInstructions(ProcessingInstruction control, - ProcessingInstruction test) { - ComparisonResult r = - compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_TARGET, - control, null, control.getTarget(), - test, null, test.getTarget())); - if (r == ComparisonResult.CRITICAL) { - return r; - } - return compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, - control, null, control.getData(), - test, null, test.getData())); - } - - ComparisonResult compareNodeLists(NodeList control, NodeList test) { - return ComparisonResult.EQUAL; - } -} Copied: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml (from rev 407, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java) =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml 2010-06-28 15:25:39 UTC (rev 408) @@ -0,0 +1,179 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<class ns="net.sf.xmlunit.diff" qualifiers="public final" + name="DOMDifferenceEngine" + summary="Difference engine based on DOM." + extends="AbstractDifferenceEngine"> + + <import reference="javax.xml.transform.Source"/> + <import reference="net.sf.xmlunit.util.Convert"/> + <import reference="org.w3c.dom.CharacterData"/> + <import reference="org.w3c.dom.Document"/> + <import reference="org.w3c.dom.DocumentType"/> + <import reference="org.w3c.dom.Element"/> + <import reference="org.w3c.dom.Node"/> + <import reference="org.w3c.dom.NodeList"/> + <import reference="org.w3c.dom.ProcessingInstruction"/> + + <literal><![CDATA[ + public void compare(Source control, Source test) { + if (control == null) { + throw new IllegalArgumentException("control must not be null"); + } + if (test == null) { + throw new IllegalArgumentException("test must not be null"); + } + compareNodes(Convert.toNode(control), Convert.toNode(test)); + } + + /** + * Recursively compares two XML nodes. + * + * <p>Performs comparisons common to all node types, the performs + * the node type specific comparisons and finally recures into + * the node's child lists.</p> + * + * <p>Stops as soon as any comparison returns + * ComparisonResult.CRITICAL.</p> + * + * <p>package private to support tests.</p> + */ + ComparisonResult compareNodes(Node control, Node test) { +]]></literal> + <lastResultDef/> + <compare type="NODE_TYPE" property="getNodeType()"/> + <compare type="NAMESPACE_URI" property="getNamespaceURI()"/> + <compare type="NAMESPACE_PREFIX" property="getPrefix()"/> + <literal><![CDATA[ + NodeList controlChildren = control.getChildNodes(); + NodeList testChildren = test.getChildNodes(); +]]></literal> + <compareExpr type="CHILD_NODELIST_LENGTH" + controlExpr="controlChildren.getLength()" + testExpr="testChildren.getLength()"/> + <compareMethod method="nodeTypeSpecificComparison"/> + <literal><![CDATA[ + return compareNodeLists(controlChildren, testChildren); + } + + /** + * Dispatches to the node type specific comparison if one is + * defined for the given combination of nodes. + * + * <p>package private to support tests.</p> + */ + ComparisonResult nodeTypeSpecificComparison(Node control, Node test) { + switch (control.getNodeType()) { + case Node.CDATA_SECTION_NODE: + case Node.COMMENT_NODE: + case Node.TEXT_NODE: + if (test instanceof CharacterData) { + return compareCharacterData((CharacterData) control, + (CharacterData) test); + } + break; + case Node.DOCUMENT_NODE: + if (test instanceof Document) { + return compareDocuments((Document) control, + (Document) test); + } + break; + case Node.ELEMENT_NODE: + if (test instanceof Element) { + return compareElements((Element) control, + (Element) test); + } + break; + case Node.PROCESSING_INSTRUCTION_NODE: + if (test instanceof ProcessingInstruction) { + return + compareProcessingInstructions((ProcessingInstruction) control, + (ProcessingInstruction) test); + } + break; + } + return ComparisonResult.EQUAL; + } + + /** + * Compares textual content. + */ + private ComparisonResult compareCharacterData(CharacterData control, + CharacterData test) { + return compare(new Comparison(ComparisonType.TEXT_VALUE, control, + null, control.getData(), + test, null, test.getData())); + } + + ComparisonResult compareDocuments(Document control, + Document test) { + DocumentType controlDt = control.getDoctype(); + DocumentType testDt = test.getDoctype(); +]]></literal> + <lastResultDef/> + <compareExpr type="HAS_DOCTYPE_DECLARATION" + controlExpr="Boolean.valueOf(controlDt != null)" + testExpr="Boolean.valueOf(testDt != null)"/> + <literal><![CDATA[ + if (controlDt != null && testDt != null) { +]]></literal> + <compareMethodExpr method="compareDocTypes" + controlExpr="controlDt" + testExpr="testDt"/> + <literal><![CDATA[ + } +]]></literal> + <compare type="XML_VERSION" property="getXmlVersion()"/> + <compare type="XML_STANDALONE" property="getXmlStandalone()"/> + <literal><![CDATA[ + return compare(new Comparison(ComparisonType.XML_ENCODING, + control, null, control.getXmlEncoding(), + test, null, test.getXmlEncoding())); + } + + ComparisonResult compareDocTypes(DocumentType control, + DocumentType test) { +]]></literal> + <lastResultDef/> + <compare type="DOCTYPE_NAME" property="getName()"/> + <compare type="DOCTYPE_PUBLIC_ID" property="getPublicId()"/> + <literal><![CDATA[ + return compare(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, + control, null, control.getSystemId(), + test, null, test.getSystemId())); + } + + ComparisonResult compareElements(Element control, + Element test) { + return ComparisonResult.EQUAL; + } + + ComparisonResult + compareProcessingInstructions(ProcessingInstruction control, + ProcessingInstruction test) { +]]></literal> + <lastResultDef/> + <compare type="PROCESSING_INSTRUCTION_TARGET" property="getTarget()"/> + <literal><![CDATA[ + return compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, + control, null, control.getData(), + test, null, test.getData())); + } + + ComparisonResult compareNodeLists(NodeList control, NodeList test) { + return ComparisonResult.EQUAL; + } +]]></literal> +</class> \ No newline at end of file Deleted: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-06-28 11:49:08 UTC (rev 407) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-06-28 15:25:39 UTC (rev 408) @@ -1,158 +0,0 @@ -/* - 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; -using System.Xml; - -namespace net.sf.xmlunit.diff { - - /// <summary> - /// Difference engine based on DOM. - /// </summary> - public sealed class DOMDifferenceEngine : AbstractDifferenceEngine { - - public override void Compare(ISource control, ISource test) { - if (control == null) { - throw new ArgumentNullException("control"); - } - if (test == null) { - throw new ArgumentNullException("test"); - } - - CompareNodes(net.sf.xmlunit.util.Convert.ToNode(control), - net.sf.xmlunit.util.Convert.ToNode(test)); - } - - /// <summary> - /// Recursively compares two XML nodes. - /// </summary> - /// <remarks> - /// Performs comparisons common to all node types, the performs - /// the node type specific comparisons and finally recures into - /// the node's child lists. - /// - /// Stops as soon as any comparison returns ComparisonResult.CRITICAL. - /// </remarks> - internal ComparisonResult CompareNodes(XmlNode control, XmlNode test) { - ComparisonResult lastResult = - Compare(new Comparison(ComparisonType.NODE_TYPE, control, - null, control.NodeType, - test, null, test.NodeType)); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - lastResult = - Compare(new Comparison(ComparisonType.NAMESPACE_URI, control, - null, control.NamespaceURI, - test, null, test.NamespaceURI)); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - lastResult = - Compare(new Comparison(ComparisonType.NAMESPACE_PREFIX, control, - null, control.Prefix, - test, null, test.Prefix)); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - XmlNodeList controlChildren = control.ChildNodes; - XmlNodeList testChildren = test.ChildNodes; - lastResult = - Compare(new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, - control, null, controlChildren.Count, - test, null, testChildren.Count)); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - lastResult = NodeTypeSpecificComparison(control, test); - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - return CompareNodeLists(controlChildren, testChildren); - } - - /// <summary> - /// Dispatches to the node type specific comparison if one is - /// defined for the given combination of nodes. - /// </summary> - internal ComparisonResult NodeTypeSpecificComparison(XmlNode control, - XmlNode test) { - switch (control.NodeType) { - case XmlNodeType.CDATA: - case XmlNodeType.Comment: - case XmlNodeType.Text: - if (test is XmlCharacterData) { - return CompareCharacterData((XmlCharacterData) control, - (XmlCharacterData) test); - } - break; - case XmlNodeType.Document: -#if false - if (test instanceof Document) { - return compareDocuments((Document) control, - (Document) test); - } -#endif - break; - case XmlNodeType.Element: -#if false - if (test instanceof Element) { - return compareElements((Element) control, - (Element) test); - } -#endif - break; - case XmlNodeType.ProcessingInstruction: - if (test is XmlProcessingInstruction) { - return - CompareProcessingInstructions((XmlProcessingInstruction) control, - (XmlProcessingInstruction) test); - } - break; - } - return ComparisonResult.EQUAL; - } - - /// <summary> - /// Compares textual content. - /// </summary> - private ComparisonResult CompareCharacterData(XmlCharacterData control, - XmlCharacterData test) { - return Compare(new Comparison(ComparisonType.TEXT_VALUE, control, - null, control.Data, - test, null, test.Data)); - } - - private ComparisonResult - CompareProcessingInstructions(XmlProcessingInstruction control, - XmlProcessingInstruction test) { - ComparisonResult r = - Compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_TARGET, - control, null, control.Target, - test, null, test.Target)); - if (r == ComparisonResult.CRITICAL) { - return r; - } - return Compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, - control, null, control.Data, - test, null, test.Data)); - } - - ComparisonResult CompareNodeLists(XmlNodeList control, - XmlNodeList test) { - return ComparisonResult.EQUAL; - } - - } -} Copied: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml (from rev 407, trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs) =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml 2010-06-28 15:25:39 UTC (rev 408) @@ -0,0 +1,135 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<class ns="net.sf.xmlunit.diff" qualifiers="public sealed" + name="DOMDifferenceEngine" + summary="Difference engine based on DOM." + extends="AbstractDifferenceEngine"> + + <import reference="System"/> + <import reference="System.Xml"/> + + <literal><![CDATA[ + + public override void Compare(ISource control, ISource test) { + if (control == null) { + throw new ArgumentNullException("control"); + } + if (test == null) { + throw new ArgumentNullException("test"); + } + + CompareNodes(net.sf.xmlunit.util.Convert.ToNode(control), + net.sf.xmlunit.util.Convert.ToNode(test)); + } + + /// <summary> + /// Recursively compares two XML nodes. + /// </summary> + /// <remarks> + /// Performs comparisons common to all node types, the performs + /// the node type specific comparisons and finally recures into + /// the node's child lists. + /// + /// Stops as soon as any comparison returns ComparisonResult.CRITICAL. + /// </remarks> + internal ComparisonResult CompareNodes(XmlNode control, XmlNode test) { +]]></literal> + <lastResultDef/> + <compare type="NODE_TYPE" property="NodeType"/> + <compare type="NAMESPACE_URI" property="NamespaceURI"/> + <compare type="NAMESPACE_PREFIX" property="Prefix"/> + <literal><![CDATA[ + XmlNodeList controlChildren = control.ChildNodes; + XmlNodeList testChildren = test.ChildNodes; +]]></literal> + <compareExpr type="CHILD_NODELIST_LENGTH" + controlExpr="controlChildren.Count" + testExpr="testChildren.Count"/> + <compareMethod method="NodeTypeSpecificComparison"/> + <literal><![CDATA[ + return CompareNodeLists(controlChildren, testChildren); + } + + /// <summary> + /// Dispatches to the node type specific comparison if one is + /// defined for the given combination of nodes. + /// </summary> + internal ComparisonResult NodeTypeSpecificComparison(XmlNode control, + XmlNode test) { + switch (control.NodeType) { + case XmlNodeType.CDATA: + case XmlNodeType.Comment: + case XmlNodeType.Text: + if (test is XmlCharacterData) { + return CompareCharacterData((XmlCharacterData) control, + (XmlCharacterData) test); + } + break; + case XmlNodeType.Document: +#if false + if (test instanceof Document) { + return compareDocuments((Document) control, + (Document) test); + } +#endif + break; + case XmlNodeType.Element: +#if false + if (test instanceof Element) { + return compareElements((Element) control, + (Element) test); + } +#endif + break; + case XmlNodeType.ProcessingInstruction: + if (test is XmlProcessingInstruction) { + return + CompareProcessingInstructions((XmlProcessingInstruction) control, + (XmlProcessingInstruction) test); + } + break; + } + return ComparisonResult.EQUAL; + } + + /// <summary> + /// Compares textual content. + /// </summary> + private ComparisonResult CompareCharacterData(XmlCharacterData control, + XmlCharacterData test) { + return Compare(new Comparison(ComparisonType.TEXT_VALUE, control, + null, control.Data, + test, null, test.Data)); + } + + private ComparisonResult + CompareProcessingInstructions(XmlProcessingInstruction control, + XmlProcessingInstruction test) { +]]></literal> + <lastResultDef/> + <compare type="PROCESSING_INSTRUCTION_TARGET" property="Target"/> + <literal><![CDATA[ + return Compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, + control, null, control.Data, + test, null, test.Data)); + } + + ComparisonResult CompareNodeLists(XmlNodeList control, + XmlNodeList test) { + return ComparisonResult.EQUAL; + } + +]]></literal> +</class> \ No newline at end of file Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2010-06-28 11:49:08 UTC (rev 407) +++ trunk/xmlunit/xmlunit.nant.build 2010-06-28 15:25:39 UTC (rev 408) @@ -22,9 +22,9 @@ <property name="core.tests.src.dir" value="${base.dir}/src/tests/net-core" overwrite="false"/> - <property name="gen.src.dir" value="${base.dir}/build/generated/net" + <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> + <property name="gen.src.dir" value="${build.dir}/generated" overwrite="false"/> - <property name="build.dir" value="${base.dir}/build/net" overwrite="false"/> <property name="test.report.dir" value="${build.dir}/test-report"/> <property name="bin.dir" value="${build.dir}/bin" overwrite="false"/> @@ -74,6 +74,26 @@ <include name="**/*.cs"/> </fileset> </copy> + <style destdir="${gen.src.dir}" + extension="cs" + style="src/buildtools/codegen.xslt"> + <infiles basedir="${core.src.dir}"> + <include name="**/*.xml"/> + </infiles> + <parameters> + + <parameter name="nsQualifier" value="namespace"/> + <parameter name="nsStart" value="{"/> + <parameter name="nsEnd" value="}"/> + <parameter name="import" value="using"/> + <parameter name="extends" value=":"/> + <parameter name="implements" value=":"/> + <parameter name="summaryStart" value="/// <summary>"/> + <parameter name="summaryEnd" value="/// </summary>"/> + + <parameter name="compareMethod" value="Compare"/> + </parameters> + </style> <csc target="library" output="${bin.dir}/${project::get-name()}-core.dll" debug="true" verbose="${csc.verbose}"> <sources basedir="${gen.src.dir}"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-08-27 15:42:09
|
Revision: 438 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=438&view=rev Author: bodewig Date: 2010-08-27 15:42:01 +0000 (Fri, 27 Aug 2010) Log Message: ----------- track XPath information in DifferenceEngine Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/src/buildtools/codegen.xslt trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/AbstractDifferenceEngine.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml trunk/xmlunit/src/main/net-core/util/Linqy.cs trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs trunk/xmlunit/xmlunit.nant.build Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/build.xml 2010-08-27 15:42:01 UTC (rev 438) @@ -95,6 +95,7 @@ <param name="implements" expression="implements"/> <param name="summaryStart" expression="/** "/> <param name="summaryEnd" expression="*/"/> + <param name="getXPath" expression="getXPath"/> <param name="compareMethod" expression="compare"/> </xslt> Modified: trunk/xmlunit/src/buildtools/codegen.xslt =================================================================== --- trunk/xmlunit/src/buildtools/codegen.xslt 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/buildtools/codegen.xslt 2010-08-27 15:42:01 UTC (rev 438) @@ -27,6 +27,7 @@ <xsl:param name="implements"/> <xsl:param name="summaryStart"/> <xsl:param name="summaryEnd"/> + <xsl:param name="getXPath"/> <xsl:template match="class"> /* @@ -95,9 +96,9 @@ <xsl:template match="compare"> lastResult = <xsl:value-of select="$compareMethod"/>(new Comparison(ComparisonType.<xsl:value-of select="@type"/>, - control, null, + control, <xsl:value-of select="$getXPath"/>(controlContext), control.<xsl:value-of select="@property"/>, - test, null, + test, <xsl:value-of select="$getXPath"/>(testContext), test.<xsl:value-of select="@property"/>)); <xsl:call-template name="if-return-boilerplate"/> </xsl:template> @@ -105,20 +106,22 @@ <xsl:template match="compareExpr"> lastResult = <xsl:value-of select="$compareMethod"/>(new Comparison(ComparisonType.<xsl:value-of select="@type"/>, - control, null, + control, <xsl:value-of select="$getXPath"/>(controlContext), <xsl:value-of select="@controlExpr"/>, - test, null, + test, <xsl:value-of select="$getXPath"/>(testContext), <xsl:value-of select="@testExpr"/>)); <xsl:call-template name="if-return-boilerplate"/> </xsl:template> <xsl:template match="compareMethod"> - lastResult = <xsl:value-of select="@method"/>(control, test); + lastResult = <xsl:value-of select="@method"/>(control, controlContext, + test, testContext); <xsl:call-template name="if-return-boilerplate"/> </xsl:template> <xsl:template match="compareMethodExpr"> - lastResult = <xsl:value-of select="@method"/>(<xsl:value-of select="@controlExpr"/>, <xsl:value-of select="@testExpr"/>); + lastResult = <xsl:value-of select="@method"/>(<xsl:value-of select="@controlExpr"/>, controlContext, + <xsl:value-of select="@testExpr"/>, testContext); <xsl:call-template name="if-return-boilerplate"/> </xsl:template> 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-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/AbstractDifferenceEngine.java 2010-08-27 15:42:01 UTC (rev 438) @@ -93,4 +93,8 @@ listeners.fireComparisonPerformed(comp, altered); return altered; } + + protected static String getXPath(XPathContext ctx) { + return ctx == null ? null : ctx.getXPath(); + } } Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml 2010-08-27 15:42:01 UTC (rev 438) @@ -23,9 +23,12 @@ <import reference="java.util.Set"/> <import reference="java.util.TreeSet"/> <import reference="javax.xml.XMLConstants"/> + <import reference="javax.xml.namespace.QName"/> <import reference="javax.xml.transform.Source"/> <import reference="net.sf.xmlunit.util.Convert"/> <import reference="net.sf.xmlunit.util.IterableNodeList"/> + <import reference="net.sf.xmlunit.util.Linqy"/> + <import reference="net.sf.xmlunit.util.Nodes"/> <import reference="org.w3c.dom.Attr"/> <import reference="org.w3c.dom.CharacterData"/> <import reference="org.w3c.dom.Document"/> @@ -44,7 +47,8 @@ if (test == null) { throw new IllegalArgumentException("test must not be null"); } - compareNodes(Convert.toNode(control), Convert.toNode(test)); + compareNodes(Convert.toNode(control), new XPathContext(), + Convert.toNode(test), new XPathContext()); } /** @@ -59,7 +63,8 @@ * * <p>package private to support tests.</p> */ - ComparisonResult compareNodes(Node control, Node test) { + ComparisonResult compareNodes(Node control, XPathContext controlContext, + Node test, XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="NODE_TYPE" property="getNodeType()"/> @@ -74,7 +79,14 @@ testExpr="testChildren.getLength()"/> <compareMethod method="nodeTypeSpecificComparison"/> <literal><![CDATA[ - return compareNodeLists(controlChildren, testChildren); + controlContext + .setChildren(Linqy.map(new IterableNodeList(controlChildren), + TO_NODE_INFO)); + testContext + .setChildren(Linqy.map(new IterableNodeList(testChildren), + TO_NODE_INFO)); + return compareNodeLists(controlChildren, controlContext, + testChildren, testContext); } /** @@ -84,45 +96,50 @@ * <p>package private to support tests.</p> */ private ComparisonResult nodeTypeSpecificComparison(Node control, - Node test) { + XPathContext controlContext, + Node test, + XPathContext testContext) { switch (control.getNodeType()) { case Node.CDATA_SECTION_NODE: case Node.COMMENT_NODE: case Node.TEXT_NODE: if (test instanceof CharacterData) { return compareCharacterData((CharacterData) control, - (CharacterData) test); + controlContext, + (CharacterData) test, testContext); } break; case Node.DOCUMENT_NODE: if (test instanceof Document) { - return compareDocuments((Document) control, - (Document) test); + return compareDocuments((Document) control, controlContext, + (Document) test, testContext); } break; case Node.ELEMENT_NODE: if (test instanceof Element) { - return compareElements((Element) control, - (Element) test); + return compareElements((Element) control, controlContext, + (Element) test, testContext); } break; case Node.PROCESSING_INSTRUCTION_NODE: if (test instanceof ProcessingInstruction) { return compareProcessingInstructions((ProcessingInstruction) control, - (ProcessingInstruction) test); + controlContext, + (ProcessingInstruction) test, + testContext); } break; case Node.DOCUMENT_TYPE_NODE: if (test instanceof DocumentType) { - return compareDocTypes((DocumentType) control, - (DocumentType) test); + return compareDocTypes((DocumentType) control, controlContext, + (DocumentType) test, testContext); } break; case Node.ATTRIBUTE_NODE: if (test instanceof Attr) { - return compareAttributes((Attr) control, - (Attr) test); + return compareAttributes((Attr) control, controlContext, + (Attr) test, testContext); } break; } @@ -133,14 +150,20 @@ * Compares textual content. */ private ComparisonResult compareCharacterData(CharacterData control, - CharacterData test) { + XPathContext controlContext, + CharacterData test, + XPathContext testContext) { return compare(new Comparison(ComparisonType.TEXT_VALUE, control, - null, control.getData(), - test, null, test.getData())); + getXPath(controlContext), + control.getData(), + test, getXPath(testContext), + test.getData())); } private ComparisonResult compareDocuments(Document control, - Document test) { + XPathContext controlContext, + Document test, + XPathContext testContext) { DocumentType controlDt = control.getDoctype(); DocumentType testDt = test.getDoctype(); ]]></literal> @@ -161,12 +184,16 @@ <compare type="XML_STANDALONE" property="getXmlStandalone()"/> <literal><![CDATA[ return compare(new Comparison(ComparisonType.XML_ENCODING, - control, null, control.getXmlEncoding(), - test, null, test.getXmlEncoding())); + control, getXPath(controlContext), + control.getXmlEncoding(), + test, getXPath(testContext), + test.getXmlEncoding())); } private ComparisonResult compareDocTypes(DocumentType control, - DocumentType test) { + XPathContext controlContext, + DocumentType test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="DOCTYPE_NAME" property="getName()"/> @@ -178,13 +205,21 @@ } private ComparisonResult compareElements(Element control, - Element test) { + XPathContext controlContext, + Element test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="ELEMENT_TAG_NAME" property="getTagName()"/> <literal><![CDATA[ Attributes controlAttributes = splitAttributes(control.getAttributes()); + controlContext + .addAttributes(Linqy.map(controlAttributes.remainingAttributes, + QNAME_MAPPER)); Attributes testAttributes = splitAttributes(test.getAttributes()); + testContext + .addAttributes(Linqy.map(testAttributes.remainingAttributes, + QNAME_MAPPER)); Set<Attr> foundTestAttributes = new HashSet<Attr>(); ]]></literal> <compareExpr type="ELEMENT_NUM_ATTRIBUTES" @@ -196,27 +231,42 @@ findMatchingAttr(testAttributes.remainingAttributes, controlAttr); ]]></literal> + controlContext.navigateToAttribute(Nodes.getQName(controlAttr)); + try { <compareExpr type="ATTR_NAME_LOOKUP" controlExpr="Boolean.TRUE" testExpr="Boolean.valueOf(testAttr != null)"/> <literal><![CDATA[ - if (testAttr != null) { + if (testAttr != null) { + testContext.navigateToAttribute(Nodes.getQName(testAttr)); + try { ]]></literal> <compareMethodExpr method="compareNodes" controlExpr="controlAttr" testExpr="testAttr"/> <literal><![CDATA[ - foundTestAttributes.add(testAttr); + foundTestAttributes.add(testAttr); + } finally { + testContext.navigateToParent(); + } + } + } finally { + controlContext.navigateToParent(); } } ]]></literal> <literal><![CDATA[ for (Attr testAttr : testAttributes.remainingAttributes) { + testContext.navigateToAttribute(Nodes.getQName(testAttr)); + try { ]]></literal> <compareExpr type="ATTR_NAME_LOOKUP" controlExpr="Boolean.valueOf(foundTestAttributes.contains(testAttr))" testExpr="Boolean.TRUE"/> <literal><![CDATA[ + } finally { + testContext.navigateToParent(); + } } ]]></literal> <compareExpr type="SCHEMA_LOCATION" @@ -233,17 +283,24 @@ private ComparisonResult compareProcessingInstructions(ProcessingInstruction control, - ProcessingInstruction test) { + XPathContext controlContext, + ProcessingInstruction test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="PROCESSING_INSTRUCTION_TARGET" property="getTarget()"/> <literal><![CDATA[ return compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, - control, null, control.getData(), - test, null, test.getData())); + control, getXPath(controlContext), + control.getData(), + test, getXPath(testContext), + test.getData())); } - private ComparisonResult compareNodeLists(NodeList control, NodeList test) { + private ComparisonResult compareNodeLists(NodeList control, + XPathContext controlContext, + NodeList test, + XPathContext testContext) { List<Node> controlList = IterableNodeList.asList(control); List<Node> testList = IterableNodeList.asList(test); final int testSize = testList.size(); @@ -259,48 +316,72 @@ final int controlSize = controlList.size(); Match lastMatch = new Match(null, -1); for (int i = 0; i < controlSize; i++) { - Match testMatch = findMatchingNode(controlList.get(i), testList, - lastMatch.index); - if (testMatch != null) { + controlContext.navigateToChild(i); + try { + Match testMatch = findMatchingNode(controlList.get(i), testList, + lastMatch.index); + if (testMatch != null) { ]]></literal> + testContext.navigateToChild(testMatch.index); + try { <compareMethodExpr method="compareNodes" controlExpr="controlList.get(i)" testExpr="testMatch.node"/> <literal><![CDATA[ - unmatchedTestIndexes.remove(Integer.valueOf(testMatch.index)); - lastMatch = testMatch; - } else { - lastResult = - compare(new Comparison(ComparisonType.CHILD_LOOKUP, - controlList.get(i), null, - controlList.get(i), - null, null, null)); + unmatchedTestIndexes + .remove(Integer.valueOf(testMatch.index)); + lastMatch = testMatch; + } finally { + testContext.navigateToParent(); + } + } else { + lastResult = + compare(new Comparison(ComparisonType.CHILD_LOOKUP, + controlList.get(i), + getXPath(controlContext), + controlList.get(i), + null, null, null)); ]]></literal> <if-return-boilerplate/> <literal><![CDATA[ + } + } finally { + controlContext.navigateToParent(); } } for (Integer I : unmatchedTestIndexes) { int i = I.intValue(); - lastResult = - compare(new Comparison(ComparisonType.CHILD_LOOKUP, - null, null, null, - testList.get(i), null, testList.get(i))); + testContext.navigateToChild(i); + try { + lastResult = + compare(new Comparison(ComparisonType.CHILD_LOOKUP, + null, null, null, + testList.get(i), + getXPath(testContext), + testList.get(i))); ]]></literal> <if-return-boilerplate/> <literal><![CDATA[ + } finally { + testContext.navigateToParent(); + } } return lastResult; } - private ComparisonResult compareAttributes(Attr control, Attr test) { + private ComparisonResult compareAttributes(Attr control, + XPathContext controlContext, + Attr test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="ATTR_VALUE_EXPLICITLY_SPECIFIED" property="getSpecified()"/> <literal><![CDATA[ return compare(new Comparison(ComparisonType.ATTR_VALUE, - control, null, control.getValue(), - test, null, test.getValue())); + control, getXPath(controlContext), + control.getValue(), + test, getXPath(testContext), + test.getValue())); } private static Attributes splitAttributes(final NamedNodeMap map) { @@ -395,5 +476,16 @@ } } + private static final Linqy.Mapper<Node, QName> QNAME_MAPPER = + new Linqy.Mapper<Node, QName>() { + public QName map(Node n) { return Nodes.getQName(n); } + }; + + private static final Linqy.Mapper<Node, XPathContext.NodeInfo> TO_NODE_INFO = + new Linqy.Mapper<Node, XPathContext.NodeInfo>() { + public XPathContext.NodeInfo map(Node n) { + return new XPathContext.DOMNodeInfo(n); + } + }; ]]></literal> </class> \ No newline at end of file Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Linqy.java 2010-08-27 15:42:01 UTC (rev 438) @@ -46,6 +46,19 @@ }; } + public static <F, T> Iterable<T> map(final Iterable<F> from, + final Mapper<? super F, T> mapper) { + return new Iterable<T>() { + public Iterator<T> iterator() { + return new MappingIterator<F, T>(from.iterator(), mapper); + } + }; + } + + public interface Mapper<F, T> { + T map(F from); + } + private static class CastingIterator<E> implements Iterator<E> { private final Iterator i; private CastingIterator(Iterator i) { @@ -82,4 +95,23 @@ return !iterated; } } + + private static class MappingIterator<F, T> implements Iterator<T> { + private final Iterator<F> i; + private final Mapper<? super F, T> mapper; + private MappingIterator(Iterator<F> i, Mapper<? super F, T> mapper) { + this.i = i; + this.mapper = mapper; + } + public void remove() { + i.remove(); + } + public T next() { + return mapper.map(i.next()); + } + public boolean hasNext() { + return i.hasNext(); + } + } + } \ No newline at end of file Modified: trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/main/net-core/diff/AbstractDifferenceEngine.cs 2010-08-27 15:42:01 UTC (rev 438) @@ -91,5 +91,9 @@ DifferenceListener(comp, outcome); } } + + protected static string GetXPath(XPathContext ctx) { + return ctx == null ? null : ctx.XPath; + } } } Modified: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml 2010-08-27 15:42:01 UTC (rev 438) @@ -36,7 +36,9 @@ } CompareNodes(net.sf.xmlunit.util.Convert.ToNode(control), - net.sf.xmlunit.util.Convert.ToNode(test)); + new XPathContext(), + net.sf.xmlunit.util.Convert.ToNode(test), + new XPathContext()); } /// <summary> @@ -49,7 +51,10 @@ /// /// Stops as soon as any comparison returns ComparisonResult.CRITICAL. /// </remarks> - internal ComparisonResult CompareNodes(XmlNode control, XmlNode test) { + internal ComparisonResult CompareNodes(XmlNode control, + XPathContext controlContext, + XmlNode test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="NODE_TYPE" property="NodeType"/> @@ -64,7 +69,18 @@ testExpr="testChildren.Count"/> <compareMethod method="NodeTypeSpecificComparison"/> <literal><![CDATA[ - return CompareNodeLists(controlChildren, testChildren); + IEnumerable<XmlNode> cc = Linqy.Cast<XmlNode>(controlChildren); + controlContext + .SetChildren(Linqy.Map<XmlNode, + XPathContext.INodeInfo>(cc, + TO_NODE_INFO)); + IEnumerable<XmlNode> tc = Linqy.Cast<XmlNode>(testChildren); + testContext + .SetChildren(Linqy.Map<XmlNode, + XPathContext.INodeInfo>(tc, + TO_NODE_INFO)); + return CompareNodeLists(controlChildren, controlContext, + testChildren, testContext); } /// <summary> @@ -72,45 +88,56 @@ /// defined for the given combination of nodes. /// </summary> private ComparisonResult NodeTypeSpecificComparison(XmlNode control, - XmlNode test) { + XPathContext controlContext, + XmlNode test, + XPathContext testContext) { switch (control.NodeType) { case XmlNodeType.CDATA: case XmlNodeType.Comment: case XmlNodeType.Text: if (test is XmlCharacterData) { return CompareCharacterData((XmlCharacterData) control, - (XmlCharacterData) test); + controlContext, + (XmlCharacterData) test, + testContext); } break; case XmlNodeType.Document: if (test is XmlDocument) { return CompareDocuments((XmlDocument) control, - (XmlDocument) test); + controlContext, + (XmlDocument) test, testContext); } break; case XmlNodeType.Element: if (test is XmlElement) { return CompareElements((XmlElement) control, - (XmlElement) test); + controlContext, + (XmlElement) test, + testContext); } break; case XmlNodeType.ProcessingInstruction: if (test is XmlProcessingInstruction) { return CompareProcessingInstructions((XmlProcessingInstruction) control, - (XmlProcessingInstruction) test); + controlContext, + (XmlProcessingInstruction) test, + testContext); } break; case XmlNodeType.DocumentType: if (test is XmlDocumentType) { return CompareDocTypes((XmlDocumentType) control, - (XmlDocumentType) test); + controlContext, + (XmlDocumentType) test, testContext); } break; case XmlNodeType.Attribute: if (test is XmlAttribute) { return CompareAttributes((XmlAttribute) control, - (XmlAttribute) test); + controlContext, + (XmlAttribute) test, testContext); } break; } @@ -121,14 +148,20 @@ /// Compares textual content. /// </summary> private ComparisonResult CompareCharacterData(XmlCharacterData control, - XmlCharacterData test) { + XPathContext controlContext, + XmlCharacterData test, + XPathContext testContext) { return Compare(new Comparison(ComparisonType.TEXT_VALUE, control, - null, control.Data, - test, null, test.Data)); + GetXPath(controlContext), + control.Data, + test, GetXPath(testContext), + test.Data)); } private ComparisonResult CompareDocuments(XmlDocument control, - XmlDocument test) { + XPathContext controlContext, + XmlDocument test, + XPathContext testContext) { XmlDocumentType controlDt = control.DocumentType; XmlDocumentType testDt = test.DocumentType; ]]></literal> @@ -155,19 +188,25 @@ } private ComparisonResult CompareDocTypes(XmlDocumentType control, - XmlDocumentType test) { + XPathContext controlContext, + XmlDocumentType test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="DOCTYPE_NAME" property="Name"/> <compare type="DOCTYPE_PUBLIC_ID" property="PublicId"/> <literal><![CDATA[ return Compare(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, - control, null, control.SystemId, - test, null, test.SystemId)); + control, GetXPath(controlContext), + control.SystemId, + test, GetXPath(testContext), + test.SystemId)); } private ComparisonResult CompareDeclarations(XmlDeclaration control, - XmlDeclaration test) { + XPathContext controlContext, + XmlDeclaration test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <literal><![CDATA[ @@ -193,18 +232,32 @@ control != null ? control.Encoding : string.Empty; string testEncoding = test != null ? test.Encoding : string.Empty; return Compare(new Comparison(ComparisonType.XML_ENCODING, - control, null, controlEncoding, - test, null, testEncoding)); + control, GetXPath(controlContext), + controlEncoding, + test, GetXPath(testContext), + testEncoding)); } private ComparisonResult CompareElements(XmlElement control, - XmlElement test) { + XPathContext controlContext, + XmlElement test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="ELEMENT_TAG_NAME" property="Name"/> <literal><![CDATA[ Attributes controlAttributes = SplitAttributes(control.Attributes); + controlContext + .AddAttributes(Linqy.Map<XmlAttribute, + XmlQualifiedName>(controlAttributes + .RemainingAttributes, + Nodes.GetQName)); Attributes testAttributes = SplitAttributes(test.Attributes); + testContext + .AddAttributes(Linqy.Map<XmlAttribute, + XmlQualifiedName>(testAttributes + .RemainingAttributes, + Nodes.GetQName)); IDictionary<XmlAttribute, object> foundTestAttributes = new Dictionary<XmlAttribute, object>(); ]]></literal> @@ -216,28 +269,44 @@ XmlAttribute testAttr = FindMatchingAttr(testAttributes.RemainingAttributes, controlAttr); + controlContext.NavigateToAttribute(Nodes.GetQName(controlAttr)); + try { ]]></literal> <compareExpr type="ATTR_NAME_LOOKUP" controlExpr="true" testExpr="testAttr != null"/> <literal><![CDATA[ - if (testAttr != null) { + if (testAttr != null) { + testContext.NavigateToAttribute(Nodes + .GetQName(testAttr)); + try { ]]></literal> <compareMethodExpr method="CompareNodes" controlExpr="controlAttr" testExpr="testAttr"/> <literal><![CDATA[ - foundTestAttributes[testAttr] = DUMMY; + foundTestAttributes[testAttr] = DUMMY; + } finally { + testContext.NavigateToParent(); + } + } + } finally { + controlContext.NavigateToParent(); } } ]]></literal> <literal><![CDATA[ foreach (XmlAttribute testAttr in testAttributes.RemainingAttributes) { + testContext.NavigateToAttribute(Nodes.GetQName(testAttr)); + try { ]]></literal> <compareExpr type="ATTR_NAME_LOOKUP" controlExpr="foundTestAttributes.ContainsKey(testAttr)" testExpr="true"/> <literal><![CDATA[ + } finally { + testContext.NavigateToParent(); + } } ]]></literal> <compareExpr type="SCHEMA_LOCATION" @@ -254,18 +323,24 @@ private ComparisonResult CompareProcessingInstructions(XmlProcessingInstruction control, - XmlProcessingInstruction test) { + XPathContext controlContext, + XmlProcessingInstruction test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="PROCESSING_INSTRUCTION_TARGET" property="Target"/> <literal><![CDATA[ return Compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, - control, null, control.Data, - test, null, test.Data)); + control, GetXPath(controlContext), + control.Data, + test, GetXPath(testContext), + test.Data)); } private ComparisonResult CompareNodeLists(XmlNodeList control, - XmlNodeList test) { + XPathContext controlContext, + XmlNodeList test, + XPathContext testContext) { IList<XmlNode> controlList = new List<XmlNode>(Linqy.Cast<XmlNode>(control)); IList<XmlNode> testList = @@ -284,46 +359,67 @@ for (int i = 0; i < controlList.Count; i++) { Match testMatch = FindMatchingNode(controlList[i], testList, lastMatch.Index); - if (testMatch != null) { + controlContext.NavigateToChild(i); + try { + if (testMatch != null) { + testContext.NavigateToChild(testMatch.Index); + try { ]]></literal> <compareMethodExpr method="CompareNodes" controlExpr="controlList[i]" testExpr="testMatch.Node"/> <literal><![CDATA[ - unmatchedTestIndexes.Remove(testMatch.Index); - lastMatch = testMatch; - } else { - lastResult = - Compare(new Comparison(ComparisonType.CHILD_LOOKUP, - controlList[i], null, - controlList[i], - null, null, null)); + unmatchedTestIndexes.Remove(testMatch.Index); + lastMatch = testMatch; + } finally { + testContext.NavigateToParent(); + } + } else { + lastResult = + Compare(new Comparison(ComparisonType.CHILD_LOOKUP, + controlList[i], + GetXPath(controlContext), + controlList[i], + null, null, null)); ]]></literal> <if-return-boilerplate/> <literal><![CDATA[ + } + } finally { + controlContext.NavigateToParent(); } } foreach (int i in unmatchedTestIndexes.Keys) { - lastResult = - Compare(new Comparison(ComparisonType.CHILD_LOOKUP, - null, null, null, - testList[i], null, testList[i])); + testContext.NavigateToChild(i); + try { + lastResult = + Compare(new Comparison(ComparisonType.CHILD_LOOKUP, + null, null, null, + testList[i], GetXPath(testContext), + testList[i])); ]]></literal> <if-return-boilerplate/> <literal><![CDATA[ + } finally { + testContext.NavigateToParent(); + } } return lastResult; } private ComparisonResult CompareAttributes(XmlAttribute control, - XmlAttribute test) { + XPathContext controlContext, + XmlAttribute test, + XPathContext testContext) { ]]></literal> <lastResultDef/> <compare type="ATTR_VALUE_EXPLICITLY_SPECIFIED" property="Specified"/> <literal><![CDATA[ return Compare(new Comparison(ComparisonType.ATTR_VALUE, - control, null, control.Value, - test, null, test.Value)); + control, GetXPath(controlContext), + control.Value, + test, GetXPath(testContext), + test.Value)); } private static Attributes SplitAttributes(XmlAttributeCollection map) { @@ -414,5 +510,9 @@ Index = index; } } + + private static XPathContext.INodeInfo TO_NODE_INFO(XmlNode n) { + return new XPathContext.DOMNodeInfo(n); + } ]]></literal> </class> \ No newline at end of file Modified: trunk/xmlunit/src/main/net-core/util/Linqy.cs =================================================================== --- trunk/xmlunit/src/main/net-core/util/Linqy.cs 2010-08-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/main/net-core/util/Linqy.cs 2010-08-27 15:42:01 UTC (rev 438) @@ -30,5 +30,13 @@ yield return t; } + public delegate T Mapper<F, T>(F from); + + public static IEnumerable<T> Map<F, T>(IEnumerable<F> from, + Mapper<F, T> mapper) { + foreach (F f in from) { + yield return mapper(f); + } + } } } \ No newline at end of file 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-27 10:54:58 UTC (rev 437) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java 2010-08-27 15:42:01 UTC (rev 438) @@ -44,12 +44,27 @@ private int invoked = 0; private final int expectedInvocations; private final ComparisonType type; + private final boolean withXPath; + private final String controlXPath; + private final String testXPath; private DiffExpecter(ComparisonType type) { this(type, 1); } private DiffExpecter(ComparisonType type, int expected) { + this(type, expected, false, null, null); + } + private DiffExpecter(ComparisonType type, String controlXPath, + String testXPath) { + this(type, 1, true, controlXPath, testXPath); + } + private DiffExpecter(ComparisonType type, int expected, + boolean withXPath, String controlXPath, + String testXPath) { this.type = type; this.expectedInvocations = expected; + this.withXPath = withXPath; + this.controlXPath = controlXPath; + this.testXPath = testXPath; } public void comparisonPerformed(Comparison comparison, ComparisonResult outcome) { @@ -58,6 +73,12 @@ invoked++; assertEquals(type, comparison.getType()); assertEquals(ComparisonResult.CRITICAL, outcome); + if (withXPath) { + assertEquals("Control XPath", controlXPath, + comparison.getControlDetails().getXPath()); + assertEquals("Test XPath", testXPath, + comparison.getTestDetails().getXPath()); + } } } @@ -74,8 +95,8 @@ d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(doc.createElement("x"), - doc.createComment("x"))); + d.compareNodes(doc.createElement("x"), new XPathContext(), + doc.createComment("x"), new XPathContext())); assertEquals(1, ex.invoked); } @@ -85,8 +106,8 @@ d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(doc.createElement("x"), - doc.createElement("x"))); + d.compareNodes(doc.createElement("x"), new XPathContext(), + doc.createElement("x"), new XPathContext())); assertEquals(0, ex.invoked); } @@ -97,7 +118,9 @@ d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); assertEquals(ComparisonResult.CRITICAL, d.compareNodes(doc.createElementNS("x", "y"), - doc.createElementNS("z", "y"))); + new XPathContext(), + doc.createElementNS("z", "y"), + new XPathContext())); assertEquals(1, ex.invoked); } @@ -119,7 +142,9 @@ }); assertEquals(ComparisonResult.CRITICAL, d.compareNodes(doc.createElementNS("x", "x:y"), - doc.createElementNS("x", "z:y"))); + new XPathContext(), + doc.createElementNS("x", "z:y"), + new XPathContext())); assertEquals(1, ex.invoked); } @@ -131,14 +156,22 @@ d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); Element e1 = doc.createElement("x"); Element e2 = doc.createElement("x"); - assertEquals(ComparisonResult.EQUAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); e1.appendChild(doc.createElement("x")); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); assertEquals(1, ex.invoked); e2.appendChild(doc.createElement("x")); - assertEquals(ComparisonResult.EQUAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); e2.appendChild(doc.createElement("x")); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); assertEquals(2, ex.invoked); } @@ -174,42 +207,60 @@ CDATASection barCDATASection = doc.createCDATASection("bar"); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooComment, fooComment)); + d.compareNodes(fooComment, new XPathContext(), + fooComment, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooComment, barComment)); + d.compareNodes(fooComment, new XPathContext(), + barComment, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooText, fooText)); + d.compareNodes(fooText, new XPathContext(), + fooText, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooText, barText)); + d.compareNodes(fooText, new XPathContext(), + barText, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooCDATASection, fooCDATASection)); + d.compareNodes(fooCDATASection, new XPathContext(), + fooCDATASection, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooCDATASection, barCDATASection)); + d.compareNodes(fooCDATASection, new XPathContext(), + barCDATASection, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooComment, fooText)); + d.compareNodes(fooComment, new XPathContext(), + fooText, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooComment, barText)); + d.compareNodes(fooComment, new XPathContext(), + barText, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooComment, fooCDATASection)); + d.compareNodes(fooComment, new XPathContext(), + fooCDATASection, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooComment, barCDATASection)); + d.compareNodes(fooComment, new XPathContext(), + barCDATASection, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooText, fooComment)); + d.compareNodes(fooText, new XPathContext(), + fooComment, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooText, barComment)); + d.compareNodes(fooText, new XPathContext(), + barComment, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooText, fooCDATASection)); + d.compareNodes(fooText, new XPathContext(), + fooCDATASection, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooText, barCDATASection)); + d.compareNodes(fooText, new XPathContext(), + barCDATASection, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooCDATASection, fooText)); + d.compareNodes(fooCDATASection, new XPathContext(), + fooText, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooCDATASection, barText)); + d.compareNodes(fooCDATASection, new XPathContext(), + barText, new XPathContext())); assertEquals(ComparisonResult.EQUAL, - d.compareNodes(fooCDATASection, fooComment)); + d.compareNodes(fooCDATASection, new XPathContext(), + fooComment, new XPathContext())); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(fooCDATASection, barComment)); + d.compareNodes(fooCDATASection, new XPathContext(), + barComment, new XPathContext())); assertEquals(9, ex.invoked); } @@ -221,8 +272,12 @@ ProcessingInstruction foo1 = doc.createProcessingInstruction("foo", "1"); ProcessingInstruction bar1 = doc.createProcessingInstruction("bar", "1"); - assertEquals(ComparisonResult.EQUAL, d.compareNodes(foo1, foo1)); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(foo1, bar1)); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(foo1, new XPathContext(), + foo1, new XPathContext())); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(foo1, new XPathContext(), + bar1, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -230,8 +285,12 @@ d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); ProcessingInstruction foo2 = doc.createProcessingInstruction("foo", "2"); - assertEquals(ComparisonResult.EQUAL, d.compareNodes(foo1, foo1)); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(foo1, foo2)); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(foo1, new XPathContext(), + foo1, new XPathContext())); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(foo1, new XPathContext(), + foo2, new XPathContext())); assertEquals(1, ex.invoked); } @@ -266,7 +325,9 @@ + "\">" + "<Book/>") .build()); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(d1, d2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -281,7 +342,8 @@ + " encoding=\"UTF-8\"?>" + "<Book/>").build()); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(d1, d2)); + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -296,7 +358,8 @@ + " standalone=\"no\"?>" + "<Book/>").build()); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(d1, d2)); + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -322,7 +385,8 @@ + " encoding=\"UTF-16\"?>" + "<Book/>").build()); assertEquals(ComparisonResult.CRITICAL, - d.compareNodes(d1, d2)); + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); assertEquals(1, ex.invoked); } @@ -363,7 +427,9 @@ d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); DocumentType dt1 = new DocType("name", "pub", "system"); DocumentType dt2 = new DocType("name2", "pub", "system"); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(dt1, dt2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(dt1, new XPathContext(), + dt2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -371,7 +437,9 @@ d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); dt2 = new DocType("name", "pub2", "system"); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(dt1, dt2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(dt1, new XPathContext(), + dt2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -390,7 +458,9 @@ } }); dt2 = new DocType("name", "pub", "system2"); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(dt1, dt2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(dt1, new XPathContext(), + dt2, new XPathContext())); assertEquals(1, ex.invoked); } @@ -402,8 +472,12 @@ Element e1 = doc.createElement("foo"); Element e2 = doc.createElement("foo"); Element e3 = doc.createElement("bar"); - assertEquals(ComparisonResult.EQUAL, d.compareNodes(e1, e2)); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e3)); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(e1, new XPathContext(), + e3, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); @@ -411,15 +485,20 @@ e1.setAttribute("attr1", "value1"); d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); assertEquals(1, ex.invoked); d = new DOMDifferenceEngine(); - ex = new DiffExpecter(ComparisonType.ATTR_NAME_LOOKUP); + ex = new DiffExpecter(ComparisonType.ATTR_NAME_LOOKUP, + "/@attr1", "/"); e2.setAttributeNS("urn:xmlunit:test", "attr1", "value1"); d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); - assertEquals(ComparisonResult.CRITICAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); assertEquals(1, ex.invoked); @@ -438,7 +517,9 @@ e2.setAttributeNS(null, "attr1", "value1"); d.addDifferenceListener(ex); d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); - assertEquals(ComparisonResult.EQUAL, d.compareNodes(e1, e2)); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(e1, new XPathContext(), + e2, new XPathContext())); } @Test public void compareAttributes() { @@ -451,7 +532,9 @@ ... [truncated message content] |
From: <bo...@us...> - 2010-09-24 10:42:56
|
Revision: 484 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=484&view=rev Author: bodewig Date: 2010-09-24 10:42:48 +0000 (Fri, 24 Sep 2010) Log Message: ----------- revert code-generation experiment, it didn't help reducing duplicate code as much as I had hoped Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs Removed Paths: ------------- trunk/xmlunit/src/buildtools/codegen.xslt trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2010-09-24 09:54:53 UTC (rev 483) +++ trunk/xmlunit/build.xml 2010-09-24 10:42:48 UTC (rev 484) @@ -80,28 +80,7 @@ </delete> </target> - <target name="-generate-sources" depends="-init"> - <xslt destdir="${gen.src.dir}" - useImplicitFileset="false" - style="src/buildtools/codegen.xslt"> - <fileset dir="${src.dir}/java-core" includes="**/*.java.xml"/> - <globmapper from="*.java.xml" to="*.java"/> - - <param name="nsQualifier" expression="package"/> - <param name="nsStart" expression=";"/> - <param name="nsEnd" expression=""/> - <param name="import" expression="import"/> - <param name="extends" expression="extends"/> - <param name="implements" expression="implements"/> - <param name="summaryStart" expression="/** "/> - <param name="summaryEnd" expression="*/"/> - <param name="getXPath" expression="getXPath"/> - - <param name="compareMethod" expression="compare"/> - </xslt> - </target> - - <target name="compile-core" depends="-init,-generate-sources" + <target name="compile-core" depends="-init" description="compiles core sources"> <javac srcdir="${src.dir}/java-core:${gen.src.dir}" destdir="${core.out.dir}" Deleted: trunk/xmlunit/src/buildtools/codegen.xslt =================================================================== --- trunk/xmlunit/src/buildtools/codegen.xslt 2010-09-24 09:54:53 UTC (rev 483) +++ trunk/xmlunit/src/buildtools/codegen.xslt 2010-09-24 10:42:48 UTC (rev 484) @@ -1,137 +0,0 @@ -<?xml version="1.0"?> -<!-- - 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. ---> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - version="1.0" - xmlns:html="http://www.w3.org/Profiles/XHTML-transitional"> - - <xsl:output method="text" indent="no"/> - - <xsl:param name="compareMethod"/> - <xsl:param name="nsQualifier"/> - <xsl:param name="nsStart"/> - <xsl:param name="nsEnd"/> - <xsl:param name="import"/> - <xsl:param name="extends"/> - <xsl:param name="implements"/> - <xsl:param name="summaryStart"/> - <xsl:param name="summaryEnd"/> - <xsl:param name="getXPath"/> - - <xsl:template match="class"> -/* - 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. -*/ - <xsl:value-of select="$nsQualifier"/> - <xsl:text> </xsl:text> - <xsl:value-of select="@ns"/> - <xsl:value-of select="$nsStart"/> - <xsl:text> - </xsl:text> - - <xsl:apply-templates mode="imports" select="import"/> - - <xsl:value-of select="$summaryStart"/> - <xsl:value-of select="@summary"/> - <xsl:text> - </xsl:text> - <xsl:value-of select="$summaryEnd"/> - <xsl:text> -</xsl:text> - - <xsl:value-of select="@qualifiers"/> - <xsl:text> </xsl:text> - class - <xsl:value-of select="@name"/> - <xsl:if test="@extends"> - <xsl:text> </xsl:text> - <xsl:value-of select="$extends"/> - <xsl:text> </xsl:text> - <xsl:value-of select="@extends"/> - </xsl:if> - <xsl:if test="@implements"> - <xsl:text> </xsl:text> - <xsl:value-of select="$implements"/> - <xsl:text> </xsl:text> - <xsl:value-of select="@implements"/> - </xsl:if> - - { - <xsl:apply-templates/> - } - <xsl:value-of select="$nsEnd"/> - </xsl:template> - - <xsl:template match="import" mode="imports"> - <xsl:value-of select="$import"/> - <xsl:text> </xsl:text> - <xsl:value-of select="@reference"/>; - </xsl:template> - - <xsl:template match="lastResultDef"> - ComparisonResult lastResult = ComparisonResult.CRITICAL; - </xsl:template> - - <xsl:template match="compare"> - lastResult = - <xsl:value-of select="$compareMethod"/>(new Comparison(ComparisonType.<xsl:value-of select="@type"/>, - control, <xsl:value-of select="$getXPath"/>(controlContext), - control.<xsl:value-of select="@property"/>, - test, <xsl:value-of select="$getXPath"/>(testContext), - test.<xsl:value-of select="@property"/>)); - <xsl:call-template name="if-return-boilerplate"/> - </xsl:template> - - <xsl:template match="compareExpr"> - lastResult = - <xsl:value-of select="$compareMethod"/>(new Comparison(ComparisonType.<xsl:value-of select="@type"/>, - control, <xsl:value-of select="$getXPath"/>(controlContext), - <xsl:value-of select="@controlExpr"/>, - test, <xsl:value-of select="$getXPath"/>(testContext), - <xsl:value-of select="@testExpr"/>)); - <xsl:call-template name="if-return-boilerplate"/> - </xsl:template> - - <xsl:template match="compareMethod"> - lastResult = <xsl:value-of select="@method"/>(control, controlContext, - test, testContext); - <xsl:call-template name="if-return-boilerplate"/> - </xsl:template> - - <xsl:template match="compareMethodExpr"> - lastResult = <xsl:value-of select="@method"/>(<xsl:value-of select="@controlExpr"/>, controlContext, - <xsl:value-of select="@testExpr"/>, testContext); - <xsl:call-template name="if-return-boilerplate"/> - </xsl:template> - - <xsl:template match="if-return-boilerplate"> - <xsl:call-template name="if-return-boilerplate"/> - </xsl:template> - - <xsl:template name="if-return-boilerplate"> - if (lastResult == ComparisonResult.CRITICAL) { - return lastResult; - } - </xsl:template> -</xsl:stylesheet> Copied: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java (from rev 483, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml) =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2010-09-24 10:42:48 UTC (rev 484) @@ -0,0 +1,645 @@ +/* + 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 java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import javax.xml.XMLConstants; +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import net.sf.xmlunit.util.Convert; +import net.sf.xmlunit.util.IterableNodeList; +import net.sf.xmlunit.util.Linqy; +import net.sf.xmlunit.util.Nodes; +import net.sf.xmlunit.util.Predicate; +import org.w3c.dom.Attr; +import org.w3c.dom.CharacterData; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.ProcessingInstruction; +/** + * Difference engine based on DOM. + */ +public final class DOMDifferenceEngine extends AbstractDifferenceEngine { + + public void compare(Source control, Source test) { + if (control == null) { + throw new IllegalArgumentException("control must not be null"); + } + if (test == null) { + throw new IllegalArgumentException("test must not be null"); + } + compareNodes(Convert.toNode(control), new XPathContext(), + Convert.toNode(test), new XPathContext()); + } + + /** + * Recursively compares two XML nodes. + * + * <p>Performs comparisons common to all node types, then performs + * the node type specific comparisons and finally recurses into + * the node's child lists.</p> + * + * <p>Stops as soon as any comparison returns + * ComparisonResult.CRITICAL.</p> + * + * <p>package private to support tests.</p> + */ + ComparisonResult compareNodes(Node control, XPathContext controlContext, + Node test, XPathContext testContext) { + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.NODE_TYPE, + control, getXPath(controlContext), + control.getNodeType(), + test, getXPath(testContext), + test.getNodeType())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + lastResult = + compare(new Comparison(ComparisonType.NAMESPACE_URI, + control, getXPath(controlContext), + control.getNamespaceURI(), + test, getXPath(testContext), + test.getNamespaceURI())); + + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + lastResult = + compare(new Comparison(ComparisonType.NAMESPACE_PREFIX, + control, getXPath(controlContext), + control.getPrefix(), + test, getXPath(testContext), + test.getPrefix())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + + Iterable<Node> controlChildren = + Linqy.filter(new IterableNodeList(control.getChildNodes()), + INTERESTING_NODES); + Iterable<Node> testChildren = + Linqy.filter(new IterableNodeList(test.getChildNodes()), + INTERESTING_NODES); + if (control.getNodeType() != Node.ATTRIBUTE_NODE) { + lastResult = + compare(new Comparison(ComparisonType.CHILD_NODELIST_LENGTH, + control, getXPath(controlContext), + Linqy.count(controlChildren), + test, getXPath(testContext), + Linqy.count(testChildren))); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } + + lastResult = nodeTypeSpecificComparison(control, controlContext, + test, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + if (control.getNodeType() != Node.ATTRIBUTE_NODE) { + controlContext + .setChildren(Linqy.map(controlChildren, TO_NODE_INFO)); + testContext + .setChildren(Linqy.map(testChildren, TO_NODE_INFO)); + + lastResult = compareNodeLists(controlChildren, controlContext, + testChildren, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } + return lastResult; + } + + /** + * Dispatches to the node type specific comparison if one is + * defined for the given combination of nodes. + */ + private ComparisonResult + nodeTypeSpecificComparison(Node control, + XPathContext controlContext, + Node test, XPathContext testContext) { + switch (control.getNodeType()) { + case Node.CDATA_SECTION_NODE: + case Node.COMMENT_NODE: + case Node.TEXT_NODE: + if (test instanceof CharacterData) { + return compareCharacterData((CharacterData) control, + controlContext, + (CharacterData) test, testContext); + } + break; + case Node.DOCUMENT_NODE: + if (test instanceof Document) { + return compareDocuments((Document) control, controlContext, + (Document) test, testContext); + } + break; + case Node.ELEMENT_NODE: + if (test instanceof Element) { + return compareElements((Element) control, controlContext, + (Element) test, testContext); + } + break; + case Node.PROCESSING_INSTRUCTION_NODE: + if (test instanceof ProcessingInstruction) { + return + compareProcessingInstructions((ProcessingInstruction) control, + controlContext, + (ProcessingInstruction) test, + testContext); + } + break; + case Node.DOCUMENT_TYPE_NODE: + if (test instanceof DocumentType) { + return compareDocTypes((DocumentType) control, controlContext, + (DocumentType) test, testContext); + } + break; + case Node.ATTRIBUTE_NODE: + if (test instanceof Attr) { + return compareAttributes((Attr) control, controlContext, + (Attr) test, testContext); + } + break; + } + return ComparisonResult.EQUAL; + } + + /** + * Compares textual content. + */ + private ComparisonResult compareCharacterData(CharacterData control, + XPathContext controlContext, + CharacterData test, + XPathContext testContext) { + return compare(new Comparison(ComparisonType.TEXT_VALUE, control, + getXPath(controlContext), + control.getData(), + test, getXPath(testContext), + test.getData())); + } + + /** + * Compares document node, doctype and XML declaration properties + */ + private ComparisonResult compareDocuments(Document control, + XPathContext controlContext, + Document test, + XPathContext testContext) { + DocumentType controlDt = control.getDoctype(); + DocumentType testDt = test.getDoctype(); + + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.HAS_DOCTYPE_DECLARATION, + control, getXPath(controlContext), + Boolean.valueOf(controlDt != null), + test, getXPath(testContext), + Boolean.valueOf(testDt != null))); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + if (controlDt != null && testDt != null) { + lastResult = compareNodes(controlDt, controlContext, + testDt, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } + + lastResult = + compare(new Comparison(ComparisonType.XML_VERSION, + control, getXPath(controlContext), + control.getXmlVersion(), + test, getXPath(testContext), + test.getXmlVersion())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + + lastResult = + compare(new Comparison(ComparisonType.XML_STANDALONE, + control, getXPath(controlContext), + control.getXmlStandalone(), + test, getXPath(testContext), + test.getXmlStandalone())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + return compare(new Comparison(ComparisonType.XML_ENCODING, + control, getXPath(controlContext), + control.getXmlEncoding(), + test, getXPath(testContext), + test.getXmlEncoding())); + } + + /** + * Compares properties of the doctype declaration. + */ + private ComparisonResult compareDocTypes(DocumentType control, + XPathContext controlContext, + DocumentType test, + XPathContext testContext) { + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.DOCTYPE_NAME, + control, getXPath(controlContext), + control.getName(), + test, getXPath(testContext), + test.getName())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + lastResult = + compare(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID, + control, getXPath(controlContext), + control.getPublicId(), + test, getXPath(testContext), + test.getPublicId())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + return compare(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, + control, null, control.getSystemId(), + test, null, test.getSystemId())); + } + + /** + * Compares elements node properties, in particular the element's + * name and its attributes. + */ + private ComparisonResult compareElements(Element control, + XPathContext controlContext, + Element test, + XPathContext testContext) { + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.ELEMENT_TAG_NAME, + control, getXPath(controlContext), + Nodes.getQName(control).getLocalPart(), + test, getXPath(testContext), + Nodes.getQName(test).getLocalPart())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + Attributes controlAttributes = splitAttributes(control.getAttributes()); + controlContext + .addAttributes(Linqy.map(controlAttributes.remainingAttributes, + QNAME_MAPPER)); + Attributes testAttributes = splitAttributes(test.getAttributes()); + testContext + .addAttributes(Linqy.map(testAttributes.remainingAttributes, + QNAME_MAPPER)); + Set<Attr> foundTestAttributes = new HashSet<Attr>(); + + lastResult = + compare(new Comparison(ComparisonType.ELEMENT_NUM_ATTRIBUTES, + control, getXPath(controlContext), + controlAttributes.remainingAttributes.size(), + test, getXPath(testContext), + testAttributes.remainingAttributes.size())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + for (Attr controlAttr : controlAttributes.remainingAttributes) { + final Attr testAttr = + findMatchingAttr(testAttributes.remainingAttributes, + controlAttr); + + controlContext.navigateToAttribute(Nodes.getQName(controlAttr)); + try { + lastResult = + compare(new Comparison(ComparisonType.ATTR_NAME_LOOKUP, + control, getXPath(controlContext), + Boolean.TRUE, + test, getXPath(testContext), + Boolean.valueOf(testAttr != null))); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + if (testAttr != null) { + testContext.navigateToAttribute(Nodes.getQName(testAttr)); + try { + lastResult = compareNodes(controlAttr, controlContext, + testAttr, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + foundTestAttributes.add(testAttr); + } finally { + testContext.navigateToParent(); + } + } + } finally { + controlContext.navigateToParent(); + } + } + + for (Attr testAttr : testAttributes.remainingAttributes) { + testContext.navigateToAttribute(Nodes.getQName(testAttr)); + try { + lastResult = + compare(new Comparison(ComparisonType.ATTR_NAME_LOOKUP, + control, getXPath(controlContext), + Boolean.valueOf(foundTestAttributes.contains(testAttr)), + test, getXPath(testContext), + Boolean.TRUE)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } finally { + testContext.navigateToParent(); + } + } + + lastResult = + compare(new Comparison(ComparisonType.SCHEMA_LOCATION, + control, getXPath(controlContext), + controlAttributes.schemaLocation != null + ? controlAttributes.schemaLocation.getValue() + : null, + test, getXPath(testContext), + testAttributes.schemaLocation != null + ? testAttributes.schemaLocation.getValue() + : null)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + return + compare(new Comparison(ComparisonType.NO_NAMESPACE_SCHEMA_LOCATION, + control, getXPath(controlContext), + controlAttributes.noNamespaceSchemaLocation != null ? + controlAttributes.noNamespaceSchemaLocation.getValue() + : null, + test, getXPath(testContext), + testAttributes.noNamespaceSchemaLocation != null + ? testAttributes.noNamespaceSchemaLocation.getValue() + : null)); + } + + /** + * Compares properties of a processing instruction. + */ + private ComparisonResult + compareProcessingInstructions(ProcessingInstruction control, + XPathContext controlContext, + ProcessingInstruction test, + XPathContext testContext) { + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_TARGET, + control, getXPath(controlContext), + control.getTarget(), + test, getXPath(testContext), + test.getTarget())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + return compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, + control, getXPath(controlContext), + control.getData(), + test, getXPath(testContext), + test.getData())); + } + + /** + * Matches nodes of two node lists and invokes compareNode on each pair. + * + * <p>Also performs CHILD_LOOKUP comparisons for each node that + * couldn't be matched to one of the "other" list.</p> + */ + private ComparisonResult compareNodeLists(Iterable<Node> controlSeq, + XPathContext controlContext, + Iterable<Node> testSeq, + XPathContext testContext) { + // if there are no children on either Node, the result is equal + ComparisonResult lastResult = ComparisonResult.EQUAL; + + Iterable<Map.Entry<Node, Node>> matches = + getNodeMatcher().match(controlSeq, testSeq); + List<Node> controlList = Linqy.asList(controlSeq); + List<Node> testList = Linqy.asList(testSeq); + Set<Node> seen = new HashSet<Node>(); + for (Map.Entry<Node, Node> pair : matches) { + Node control = pair.getKey(); + seen.add(control); + Node test = pair.getValue(); + seen.add(test); + int controlIndex = controlList.indexOf(control); + int testIndex = testList.indexOf(test); + + controlContext.navigateToChild(controlIndex); + testContext.navigateToChild(testIndex); + try { + lastResult = + compare(new Comparison(ComparisonType.CHILD_NODELIST_SEQUENCE, + control, getXPath(controlContext), + Integer.valueOf(controlIndex), + test, getXPath(testContext), + Integer.valueOf(testIndex))); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + lastResult = compareNodes(control, controlContext, + test, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } finally { + testContext.navigateToParent(); + controlContext.navigateToParent(); + } + } + + final int controlSize = controlList.size(); + for (int i = 0; i < controlSize; i++) { + if (!seen.contains(controlList.get(i))) { + controlContext.navigateToChild(i); + try { + lastResult = + compare(new Comparison(ComparisonType.CHILD_LOOKUP, + controlList.get(i), + getXPath(controlContext), + controlList.get(i), + null, null, null)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } finally { + controlContext.navigateToParent(); + } + } + } + + final int testSize = testList.size(); + for (int i = 0; i < testSize; i++) { + if (!seen.contains(testList.get(i))) { + testContext.navigateToChild(i); + try { + lastResult = + compare(new Comparison(ComparisonType.CHILD_LOOKUP, + null, null, null, + testList.get(i), + getXPath(testContext), + testList.get(i))); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + } finally { + testContext.navigateToParent(); + } + } + } + return lastResult; + } + + /** + * Compares properties of an attribute. + */ + private ComparisonResult compareAttributes(Attr control, + XPathContext controlContext, + Attr test, + XPathContext testContext) { + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED, + control, getXPath(controlContext), + control.getSpecified(), + test, getXPath(testContext), + test.getSpecified())); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + + return compare(new Comparison(ComparisonType.ATTR_VALUE, + control, getXPath(controlContext), + control.getValue(), + test, getXPath(testContext), + test.getValue())); + } + + /** + * Separates XML namespace related attributes from "normal" attributes.xb + */ + private static Attributes splitAttributes(final NamedNodeMap map) { + Attr sLoc = (Attr) map.getNamedItemNS(XMLConstants + .W3C_XML_SCHEMA_INSTANCE_NS_URI, + "schemaLocation"); + Attr nNsLoc = (Attr) map.getNamedItemNS(XMLConstants + .W3C_XML_SCHEMA_INSTANCE_NS_URI, + "noNamespaceSchemaLocation"); + List<Attr> rest = new LinkedList<Attr>(); + final int len = map.getLength(); + for (int i = 0; i < len; i++) { + Attr a = (Attr) map.item(i); + if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(a.getNamespaceURI()) + && + !XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI + .equals(a.getNamespaceURI())) { + rest.add(a); + } + } + return new Attributes(sLoc, nNsLoc, rest); + } + + private static class Attributes { + private final Attr schemaLocation; + private final Attr noNamespaceSchemaLocation; + private final List<Attr> remainingAttributes; + private Attributes(Attr schemaLocation, Attr noNamespaceSchemaLocation, + List<Attr> remainingAttributes) { + this.schemaLocation = schemaLocation; + this.noNamespaceSchemaLocation = noNamespaceSchemaLocation; + this.remainingAttributes = remainingAttributes; + } + } + + /** + * Find the attribute with the same namespace and local name as a + * given attribute in a list of attributes. + */ + private static Attr findMatchingAttr(final List<Attr> attrs, + final Attr attrToMatch) { + final boolean hasNs = attrToMatch.getNamespaceURI() != null; + final String nsToMatch = attrToMatch.getNamespaceURI(); + final String nameToMatch = hasNs ? attrToMatch.getLocalName() + : attrToMatch.getName(); + for (Attr a : attrs) { + if (((!hasNs && a.getNamespaceURI() == null) + || + (hasNs && nsToMatch.equals(a.getNamespaceURI()))) + && + ((hasNs && nameToMatch.equals(a.getLocalName())) + || + (!hasNs && nameToMatch.equals(a.getName()))) + ) { + return a; + } + } + return null; + } + + /** + * Maps Nodes to their QNames. + */ + private static final Linqy.Mapper<Node, QName> QNAME_MAPPER = + new Linqy.Mapper<Node, QName>() { + public QName map(Node n) { return Nodes.getQName(n); } + }; + + /** + * Maps Nodes to their NodeInfo equivalent. + */ + private static final Linqy.Mapper<Node, XPathContext.NodeInfo> TO_NODE_INFO = + new Linqy.Mapper<Node, XPathContext.NodeInfo>() { + public XPathContext.NodeInfo map(Node n) { + return new XPathContext.DOMNodeInfo(n); + } + }; + + /** + * Suppresses document-type nodes. + */ + private static final Predicate<Node> INTERESTING_NODES = + new Predicate<Node>() { + public boolean matches(Node n) { + return n.getNodeType() != Node.DOCUMENT_TYPE_NODE; + } + }; + +} Deleted: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml 2010-09-24 09:54:53 UTC (rev 483) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java.xml 2010-09-24 10:42:48 UTC (rev 484) @@ -1,484 +0,0 @@ -<?xml version="1.0"?> -<!-- - 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. ---> -<class ns="net.sf.xmlunit.diff" qualifiers="public final" - name="DOMDifferenceEngine" - summary="Difference engine based on DOM." - extends="AbstractDifferenceEngine"> - - <import reference="java.util.HashSet"/> - <import reference="java.util.LinkedList"/> - <import reference="java.util.List"/> - <import reference="java.util.Map"/> - <import reference="java.util.Set"/> - <import reference="java.util.TreeSet"/> - <import reference="javax.xml.XMLConstants"/> - <import reference="javax.xml.namespace.QName"/> - <import reference="javax.xml.transform.Source"/> - <import reference="net.sf.xmlunit.util.Convert"/> - <import reference="net.sf.xmlunit.util.IterableNodeList"/> - <import reference="net.sf.xmlunit.util.Linqy"/> - <import reference="net.sf.xmlunit.util.Nodes"/> - <import reference="net.sf.xmlunit.util.Predicate"/> - <import reference="org.w3c.dom.Attr"/> - <import reference="org.w3c.dom.CharacterData"/> - <import reference="org.w3c.dom.Document"/> - <import reference="org.w3c.dom.DocumentType"/> - <import reference="org.w3c.dom.Element"/> - <import reference="org.w3c.dom.NamedNodeMap"/> - <import reference="org.w3c.dom.Node"/> - <import reference="org.w3c.dom.NodeList"/> - <import reference="org.w3c.dom.ProcessingInstruction"/> - - <literal><![CDATA[ - public void compare(Source control, Source test) { - if (control == null) { - throw new IllegalArgumentException("control must not be null"); - } - if (test == null) { - throw new IllegalArgumentException("test must not be null"); - } - compareNodes(Convert.toNode(control), new XPathContext(), - Convert.toNode(test), new XPathContext()); - } - - /** - * Recursively compares two XML nodes. - * - * <p>Performs comparisons common to all node types, the performs - * the node type specific comparisons and finally recures into - * the node's child lists.</p> - * - * <p>Stops as soon as any comparison returns - * ComparisonResult.CRITICAL.</p> - * - * <p>package private to support tests.</p> - */ - ComparisonResult compareNodes(Node control, XPathContext controlContext, - Node test, XPathContext testContext) { -]]></literal> - <lastResultDef/> - <compare type="NODE_TYPE" property="getNodeType()"/> - <compare type="NAMESPACE_URI" property="getNamespaceURI()"/> - <compare type="NAMESPACE_PREFIX" property="getPrefix()"/> - <literal><![CDATA[ - Iterable<Node> controlChildren = - Linqy.filter(new IterableNodeList(control.getChildNodes()), - INTERESTING_NODES); - Iterable<Node> testChildren = - Linqy.filter(new IterableNodeList(test.getChildNodes()), - INTERESTING_NODES); - if (control.getNodeType() != Node.ATTRIBUTE_NODE) { -]]></literal> - <compareExpr type="CHILD_NODELIST_LENGTH" - controlExpr="Linqy.count(controlChildren)" - testExpr="Linqy.count(testChildren)"/> - <literal><![CDATA[ - } -]]></literal> - <compareMethod method="nodeTypeSpecificComparison"/> - <literal><![CDATA[ - if (control.getNodeType() != Node.ATTRIBUTE_NODE) { - controlContext - .setChildren(Linqy.map(controlChildren, TO_NODE_INFO)); - testContext - .setChildren(Linqy.map(testChildren, TO_NODE_INFO)); -]]></literal> - <compareMethodExpr method="compareNodeLists" - controlExpr="controlChildren" - testExpr="testChildren"/> - <literal><![CDATA[ - } - return lastResult; - } - - /** - * Dispatches to the node type specific comparison if one is - * defined for the given combination of nodes. - * - * <p>package private to support tests.</p> - */ - private ComparisonResult nodeTypeSpecificComparison(Node control, - XPathContext controlContext, - Node test, - XPathContext testContext) { - switch (control.getNodeType()) { - case Node.CDATA_SECTION_NODE: - case Node.COMMENT_NODE: - case Node.TEXT_NODE: - if (test instanceof CharacterData) { - return compareCharacterData((CharacterData) control, - controlContext, - (CharacterData) test, testContext); - } - break; - case Node.DOCUMENT_NODE: - if (test instanceof Document) { - return compareDocuments((Document) control, controlContext, - (Document) test, testContext); - } - break; - case Node.ELEMENT_NODE: - if (test instanceof Element) { - return compareElements((Element) control, controlContext, - (Element) test, testContext); - } - break; - case Node.PROCESSING_INSTRUCTION_NODE: - if (test instanceof ProcessingInstruction) { - return - compareProcessingInstructions((ProcessingInstruction) control, - controlContext, - (ProcessingInstruction) test, - testContext); - } - break; - case Node.DOCUMENT_TYPE_NODE: - if (test instanceof DocumentType) { - return compareDocTypes((DocumentType) control, controlContext, - (DocumentType) test, testContext); - } - break; - case Node.ATTRIBUTE_NODE: - if (test instanceof Attr) { - return compareAttributes((Attr) control, controlContext, - (Attr) test, testContext); - } - break; - } - return ComparisonResult.EQUAL; - } - - /** - * Compares textual content. - */ - private ComparisonResult compareCharacterData(CharacterData control, - XPathContext controlContext, - CharacterData test, - XPathContext testContext) { - return compare(new Comparison(ComparisonType.TEXT_VALUE, control, - getXPath(controlContext), - control.getData(), - test, getXPath(testContext), - test.getData())); - } - - private ComparisonResult compareDocuments(Document control, - XPathContext controlContext, - Document test, - XPathContext testContext) { - DocumentType controlDt = control.getDoctype(); - DocumentType testDt = test.getDoctype(); -]]></literal> - <lastResultDef/> - <compareExpr type="HAS_DOCTYPE_DECLARATION" - controlExpr="Boolean.valueOf(controlDt != null)" - testExpr="Boolean.valueOf(testDt != null)"/> - <literal><![CDATA[ - if (controlDt != null && testDt != null) { -]]></literal> - <compareMethodExpr method="compareNodes" - controlExpr="controlDt" - testExpr="testDt"/> - <literal><![CDATA[ - } -]]></literal> - <compare type="XML_VERSION" property="getXmlVersion()"/> - <compare type="XML_STANDALONE" property="getXmlStandalone()"/> - <literal><![CDATA[ - return compare(new Comparison(ComparisonType.XML_ENCODING, - control, getXPath(controlContext), - control.getXmlEncoding(), - test, getXPath(testContext), - test.getXmlEncoding())); - } - - private ComparisonResult compareDocTypes(DocumentType control, - XPathContext controlContext, - DocumentType test, - XPathContext testContext) { -]]></literal> - <lastResultDef/> - <compare type="DOCTYPE_NAME" property="getName()"/> - <compare type="DOCTYPE_PUBLIC_ID" property="getPublicId()"/> - <literal><![CDATA[ - return compare(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID, - control, null, control.getSystemId(), - test, null, test.getSystemId())); - } - - private ComparisonResult compareElements(Element control, - XPathContext controlContext, - Element test, - XPathContext testContext) { -]]></literal> - <lastResultDef/> - <compareExpr type="ELEMENT_TAG_NAME" - controlExpr="Nodes.getQName(control).getLocalPart()" - testExpr="Nodes.getQName(test).getLocalPart()"/> - <literal><![CDATA[ - Attributes controlAttributes = splitAttributes(control.getAttributes()); - controlContext - .addAttributes(Linqy.map(controlAttributes.remainingAttributes, - QNAME_MAPPER)); - Attributes testAttributes = splitAttributes(test.getAttributes()); - testContext - .addAttributes(Linqy.map(testAttributes.remainingAttributes, - QNAME_MAPPER)); - Set<Attr> foundTestAttributes = new HashSet<Attr>(); -]]></literal> - <compareExpr type="ELEMENT_NUM_ATTRIBUTES" - controlExpr="controlAttributes.remainingAttributes.size()" - testExpr="testAttributes.remainingAttributes.size()"/> - <literal><![CDATA[ - for (Attr controlAttr : controlAttributes.remainingAttributes) { - final Attr testAttr = - findMatchingAttr(testAttributes.remainingAttributes, - controlAttr); -]]></literal> - controlContext.navigateToAttribute(Nodes.getQName(controlAttr)); - try { - <compareExpr type="ATTR_NAME_LOOKUP" - controlExpr="Boolean.TRUE" - testExpr="Boolean.valueOf(testAttr != null)"/> - <literal><![CDATA[ - if (testAttr != null) { - testContext.navigateToAttribute(Nodes.getQName(testAttr)); - try { -]]></literal> - <compareMethodExpr method="compareNodes" - controlExpr="controlAttr" - testExpr="testAttr"/> - <literal><![CDATA[ - foundTestAttributes.add(testAttr); - } finally { - testContext.navigateToParent(); - } - } - } finally { - controlContext.navigateToParent(); - } - } -]]></literal> - <literal><![CDATA[ - for (Attr testAttr : testAttributes.remainingAttributes) { - testContext.navigateToAttribute(Nodes.getQName(testAttr)); - try { -]]></literal> - <compareExpr type="ATTR_NAME_LOOKUP" - controlExpr="Boolean.valueOf(foundTestAttributes.contains(testAttr))" - testExpr="Boolean.TRUE"/> - <literal><![CDATA[ - } finally { - testContext.navigateToParent(); - } - } -]]></literal> - <compareExpr type="SCHEMA_LOCATION" - controlExpr="controlAttributes.schemaLocation != null ? controlAttributes.schemaLocation.getValue() : null" - testExpr="testAttributes.schemaLocation != null ? testAttributes.schemaLocation.getValue() : null" - /> - <compareExpr type="NO_NAMESPACE_SCHEMA_LOCATION" - controlExpr="controlAttributes.noNamespaceSchemaLocation != null ? controlAttributes.noNamespaceSchemaLocation.getValue() : null" - testExpr="testAttributes.noNamespaceSchemaLocation != null ? testAttributes.noNamespaceSchemaLocation.getValue() : null" - /> - <literal><![CDATA[ - return lastResult; - } - - private ComparisonResult - compareProcessingInstructions(ProcessingInstruction control, - XPathContext controlContext, - ProcessingInstruction test, - XPathContext testContext) { -]]></literal> - <lastResultDef/> - <compare type="PROCESSING_INSTRUCTION_TARGET" property="getTarget()"/> - <literal><![CDATA[ - return compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA, - control, getXPath(controlContext), - control.getData(), - test, getXPath(testContext), - test.getData())); - } - - private ComparisonResult compareNodeLists(Iterable<Node> controlSeq, - XPathContext controlContext, - Iterable<Node> testSeq, - XPathContext testContext) { -]]></literal> - <lastResultDef/> - <literal><![CDATA[ - // if there are no children on either Node, the result is equal - lastResult = ComparisonResult.EQUAL; - - Iterable<Map.Entry<Node, Node>> matches = - getNodeMatcher().match(controlSeq, testSeq); - List<Node> controlList = Linqy.asList(controlSeq); - List<Node> testList = Linqy.asList(testSeq); - Set<Node> seen = new HashSet<Node>(); - for (Map.Entry<Node, Node> pair : matches) { - Node control = pair.getKey(); - seen.add(control); - Node test = pair.getValue(); - seen.add(test); - int controlIndex = controlList.indexOf(control); - int testIndex = testList.indexOf(test); - controlContext.navigateToChild(controlIndex); - testContext.navigateToChild(testIndex); - try { -]]></literal> - <compareExpr type="CHILD_NODELIST_SEQUENCE" - controlExpr="Integer.valueOf(controlIndex)" - testExpr="Integer.valueOf(testIndex)" - /> - <compareMethodExpr method="compareNodes" - controlExpr="control" - testExpr="test"/> - <literal><![CDATA[ - } finally { - testContext.navigateToParent(); - controlContext.navigateToParent(); - } - } - final int controlSize = controlList.size(); - for (int i = 0; i < controlSize; i++) { - if (!seen.contains(controlList.get(i))) { - controlContext.navigateToChild(i); - try { - lastResult = - compare(new Comparison(ComparisonType.CHILD_LOOKUP, - controlList.get(i), - getXPath(controlContext), - controlList.get(i), - null, null, null)); -]]></literal> - <if-return-boilerplate/> - <literal><![CDATA[ - } finally { - controlContext.navigateToParent(); - } - } - } - final int testSize = testList.size(); - for (int i = 0; i < testSize; i++) { - if (!seen.contains(testList.get(i))) { - testContext.navigateToChild(i); - try { - lastResult = - compare(new Comparison(ComparisonType.CHILD_LOOKUP, - null, null, null, - testList.get(i), - getXPath(testContext), - testList.get(i))); -]]></literal> - <if-return-boilerplate/> - <literal><![CDATA[ - } finally { - testContext.navigateToParent(); - } - } - } - return lastResult; - } - - private ComparisonResult compareAttributes(Attr control, - XPathContext controlContext, - Attr test, - XPathContext testContext) { -]]></literal> - <lastResultDef/> - <compare type="ATTR_VALUE_EXPLICITLY_SPECIFIED" property="getSpecified()"/> - <literal><![CDATA[ - return compare(new Comparison(ComparisonType.ATTR_VALUE, - control, getXPath(controlContext), - control.getValue(), - test, getXPath(testContext), - test.getValue())); - } - - private static Attributes splitAttributes(final NamedNodeMap map) { - Attr sLoc = (Attr) map.getNamedItemNS(XMLConstants - .W3C_XML_SCHEMA_INSTANCE_NS_URI, - "schemaLocation"); - Attr nNsLoc = (Attr) map.getNamedItemNS(XMLConstants - .W3C_XML_SCHEMA_INSTANCE_NS_URI, - "noNamespaceSchemaLocation"); - List<Attr> rest = new LinkedList<Attr>(); - final int len = map.getLength(); - for (int i = 0; i < len; i++) { - Attr a = (Attr) map.item(i); - if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(a.getNamespaceURI()) - && - !XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI - .equals(a.getNamespaceURI())) { - rest.add(a); - } - } - return new Attributes(sLoc, nNsLoc, rest); - } - - private static class Attributes { - private final Attr schemaLocation; - private final Attr noNamespaceSchemaLocation; - private final List<Attr> remainingAttributes; - private Attributes(Attr schemaLocation, Attr noNamespaceSchemaLocation, - List<Attr> remainingAttributes) { - this.schemaLocation = schemaLocation; - this.noNamespaceSchemaLocation = noNamespaceSchemaLocation; - this.remainingAttributes = remainingAttributes; - } - } - - private static Attr findMatchingAttr(final List<Attr> attrs, - final Attr attrToMatch) { - final boolean hasNs = attrToMatch.getNamespaceURI() != null; - final String nsToMatch = attrToMatch.getNamespaceURI(); - final String nameToMatch = hasNs ? attrToMatch.getLocalName() - : attrToMatch.getName(); - for (Attr a : attrs) { - if (((!hasNs && a.getNamespaceURI() == null) - || - (hasNs && nsToMatch.equals(a.getNamespaceURI()))) - && - ((hasNs && nameToMatch.equals(a.getLocalName())) - || - (!hasNs && nameToMatch.equals(a.getName()))) - ) { - return a; - } - } - return null; - } - - private static final Linqy.Mapper<Node, QName> QNAME_MAPPER = - new Linqy.Mapper<Node, QName>() { - public QName map(Node n) { return Nodes.getQName(n); } - }; - - private static final Linqy.Mapper<Node, XPathContext.NodeInfo> TO_NODE_INFO = - new Linqy.Mapper<Node, XPathContext.NodeInfo>() { - public XPathContext.NodeInfo map(Node n) { - return new XPathContext.DOMNodeInfo(n); - } - }; - - private static final Predicate<Node> INTERESTING_NODES = - new Predicate<Node>() { - public boolean matches(Node n) { - return n.getNodeType() != Node.DOCUMENT_TYPE_NODE; - } - }; -]]></literal> -</class> Copied: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs (from rev 479, trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.xml) =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2010-09-24 10:42:48 UTC (rev 484) @@ -0,0 +1,671 @@ +/* + 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; +using System.Collections.Generic; +using System.Xml; +using System.Xml.Schema; +using net.sf.xmlunit.util; + +namespace net.sf.xmlunit.diff{ + + /// <summary> + /// Difference engine based on DOM. + /// </summary> + public sealed class DOMDifferenceEngine : AbstractDifferenceEngine { + + private static readonly object DUMMY = new object(); + + public override void Compare(ISource control, ISource test) { + if (control == null) { + throw new ArgumentNullException("control"); + } + if (test == null) { + throw new ArgumentNullException("test"); + } + + CompareNodes(net.sf.xmlunit.util.Convert.ToNode(control), + new XPathContext(), + net.sf.xmlunit.util.Convert.ToNode(test), + new XPathContext()); + } + + /// <summary> + /// Recursively compares two XML nodes. + /// </summary> + /// <remarks> + /// Performs comparisons common to all node types, then performs + /// the node type specific comparisons and finally recurses into + /// the node's child lists. + /// + /// Stops as soon as any comparison returns ComparisonResult.CRITICAL. + /// </remarks> + internal ComparisonResult CompareNodes(XmlNode control, + XPathContext controlContext, + XmlNode test, + XPathContext testContext) { + ComparisonResult lastResult = + Compa... [truncated message content] |
From: <bo...@us...> - 2011-11-02 08:00:04
|
Revision: 498 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=498&view=rev Author: bodewig Date: 2011-11-02 07:59:58 +0000 (Wed, 02 Nov 2011) Log Message: ----------- provide a strong name for .NET assemblies Modified Paths: -------------- trunk/xmlunit/xmlunit.nant.build Added Paths: ----------- trunk/xmlunit/xmlunit.snk Modified: trunk/xmlunit/xmlunit.nant.build =================================================================== --- trunk/xmlunit/xmlunit.nant.build 2011-11-02 07:46:52 UTC (rev 497) +++ trunk/xmlunit/xmlunit.nant.build 2011-11-02 07:59:58 UTC (rev 498) @@ -66,7 +66,7 @@ <attribute type="AssemblyDescriptionAttribute" value="Core Classes of XMLUnit for .NET" /> <attribute type="InternalsVisibleToAttribute" - value="${project::get-name()}-core.tests"/> + value="${project::get-name()}-core.tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fdec9d5858956ff10ff9cf39935441a7d4a216475a467e951ddd8fcce0b74443696680a6cfb58f8b1d96166acb76f9eae0431a223cecb30e224c21f30e57c457747f6ba176e6c22f48e105b200b458509b6de815cccdfc9ebe59ae4024c4b8659d2f2fcb65b1688f8327b10c96ed7e5f536ba6a1978ae86aca438439efbd6cb6"/> </attributes> </asminfo> <copy todir="${gen.src.dir}"> @@ -75,7 +75,7 @@ </fileset> </copy> <csc target="library" output="${bin.dir}/${project::get-name()}-core.dll" - debug="true" verbose="${csc.verbose}"> + debug="true" verbose="${csc.verbose}" keyfile="xmlunit.snk"> <sources basedir="${gen.src.dir}"> <include name="**/*.cs"/> </sources> @@ -86,7 +86,7 @@ depends="compile-core"> <csc target="library" output="${bin.dir}/${project::get-name()}-core.tests.dll" - debug="true" verbose="${csc.verbose}"> + debug="true" verbose="${csc.verbose}" keyfile="xmlunit.snk"> <references basedir="${bin.dir}"> <include name="${project::get-name()}-core.dll"/> <include name="${nunit.v2.assembly}"/> Added: trunk/xmlunit/xmlunit.snk =================================================================== (Binary files differ) Property changes on: trunk/xmlunit/xmlunit.snk ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-07 20:50:54
|
Revision: 524 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=524&view=rev Author: bodewig Date: 2013-02-07 20:50:46 +0000 (Thu, 07 Feb 2013) Log Message: ----------- merge build and user-guide changes from 1.x branch Modified Paths: -------------- trunk/xmlunit/build.xml trunk/xmlunit/docbook.xml trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Property Changed: ---------------- trunk/xmlunit/build.xml trunk/xmlunit/docbook.xml trunk/xmlunit/src/user-guide/XMLUnit-Java.xml Modified: trunk/xmlunit/build.xml =================================================================== --- trunk/xmlunit/build.xml 2013-02-07 20:50:15 UTC (rev 523) +++ trunk/xmlunit/build.xml 2013-02-07 20:50:46 UTC (rev 524) @@ -227,7 +227,6 @@ <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> @@ -276,6 +275,12 @@ <target name="dist" depends="clean,bindist,srcdist,compile-userguide-examples" description="creates the distribution files"> + <jar jarfile="${lib.dir}/xmlunit-${xmlunit.version}-sources.jar" + basedir="${src.dir}/java" + /> + <jar jarfile="${lib.dir}/xmlunit-${xmlunit.version}-javadoc.jar" + basedir="${docs.dir}/api" + /> <checksum algorithm="md5"> <fileset dir="${dist.dir}"> <include name="*.zip"/> @@ -286,6 +291,14 @@ <include name="*.zip"/> </fileset> </checksum> + <checksum algorithm="md5"> + <fileset dir="${lib.dir}"/> + </checksum> + <checksum algorithm="sha1"> + <fileset dir="${lib.dir}"> + <exclude name="*.md5"/> + </fileset> + </checksum> </target> <target name="compile-userguide-examples" depends="compile"> Property changes on: trunk/xmlunit/build.xml ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x/build.xml:355,521-522 Modified: trunk/xmlunit/docbook.xml =================================================================== --- trunk/xmlunit/docbook.xml 2013-02-07 20:50:15 UTC (rev 523) +++ trunk/xmlunit/docbook.xml 2013-02-07 20:50:46 UTC (rev 524) @@ -1,3 +1,35 @@ +<!-- +Copyright (c) 2001-2013, 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> <!-- allow overrides --> <property file="docbook.properties"/> @@ -5,6 +37,7 @@ <!-- location of Docbook Stylesheets and dblatex --> <property name="db5.xsl" location="../../docbook/docbook5-xsl-1.72.0"/> <property name="dblatex" value="/usr/bin/dblatex"/> + <property name="xsltproc" value="/usr/bin/xsltproc"/> <property name="html.dir" location="${userguide.docs.dir}/html"/> <property name="user.guide" value="XMLUnit-Java"/> @@ -20,11 +53,36 @@ targetfile="${html.dir}/index.html"/> </target> - <target name="users-guide-html" depends="-html-needs-refresh?" - unless="HTML is up-to-date" - description="Creates HTML version of the User's Guide"> + <target name="-xsltproc-available?" depends="-html-needs-refresh?"> + <available property="xsltproc available" + file="${xsltproc}"/> + <condition property="run TraX"> + <not> + <or> + <isset property="xsltproc available"/> + <isset property="HTML is up-to-date"/> + </or> + </not> + </condition> + <condition property="run xsltproc"> + <and> + <isset property="xsltproc available"/> + <not> + <isset property="HTML is up-to-date"/> + </not> + </and> + </condition> + </target> + + <target name="-users-guide-html-pre" depends="-html-needs-refresh?" + unless="HTML is up-to-date"> <delete dir="${html.dir}" quiet="true"/> <mkdir dir="${html.dir}"/> + </target> + + <target name="-users-guide-html-trax" + depends="-xsltproc-available?,-users-guide-html-pre" + if="run TraX"> <xslt basedir="${src.userguide.dir}" destdir="${html.dir}" @@ -34,10 +92,33 @@ <param name="section.autolabel" expression="1"/> <param name="section.label.includes.component.label" expression="1"/> </xslt> - <copy file="${src.dir}/site/xmlunit.png" toDir="${html.dir}"/> <delete file="${html.dir}/${user.guide}.html" quiet="true"/> </target> + <target name="-users-guide-html-xsltproc" + depends="-xsltproc-available?,-users-guide-html-pre" + if="run xsltproc"> + <exec executable="${xsltproc}" failonerror="true"> + <arg value="-o"/> + <!-- xsltproc needs the trailing slash to work properly --> + <arg value="${html.dir}/"/> + <arg value="--param"/> + <arg value="section.autolabel"/> + <arg value="1"/> + <arg value="--param"/> + <arg value="section.label.includes.component.label"/> + <arg value="1"/> + <arg file="${db5.xsl}/html/chunk.xsl"/> + <arg file="${src.userguide.dir}/${user.guide}.xml"/> + </exec> + </target> + + <target name="users-guide-html" + depends="-users-guide-html-trax,-users-guide-html-xsltproc" + unless="HTML is up-to-date" + description="Creates HTML version of the User's Guide"> + </target> + <target name="-check-os"> <condition property="isWindows"> <os family="windows"/> Property changes on: trunk/xmlunit/docbook.xml ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x/docbook.xml:355,513-517 Modified: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml =================================================================== --- trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2013-02-07 20:50:15 UTC (rev 523) +++ trunk/xmlunit/src/user-guide/XMLUnit-Java.xml 2013-02-07 20:50:46 UTC (rev 524) @@ -1,13 +1,40 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE article PUBLIC "-//OASIS//DTD Simplified DocBook XML V1.1b1//EN" "http://docbook.org/xml/simple/1.1b1/sdocbook.dtd"> +<!-- +Copyright (c) 2001-2013, 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. +--> + <article> - <title>XMLUnit Java User's Guide - <inlinemediaobject><imageobject> - <imagedata fileref="xmlunit.png" width="331" depth="100" - valign="middle" format="PNG"/> - </imageobject></inlinemediaobject> - </title> + <title>XMLUnit Java User's Guide</title> <articleinfo> <authorgroup> <author> @@ -44,6 +71,11 @@ <date>September 2009</date> <revremark>Documentation for XMLUnit Java 1.3</revremark> </revision> + <revision> + <revnumber>1.4</revnumber> + <date>February 2013</date> + <revremark>Documentation for XMLUnit Java 1.4</revremark> + </revision> </revhistory> </articleinfo> @@ -2830,8 +2862,10 @@ (<literal>String</literal>) prefixes as keys and (<literal>String</literal>) namespace URIs as values.</para> - <para>The empty string is used as prefix for the default - namespace of a document.</para> + <para>Note there is nothing like a default namespace in XPath + selectors. If you are using namespaces in your XPath, all + namespaces need a prefix (of length greater than zero). This + is independent of the prefixes used in your document.</para> <para>The following example is taken from XMLUnit's own tests. It demonstrates that the namespace prefix of the document under @@ -3618,7 +3652,7 @@ <section id="Changes 1.4"> <title>Changes from XMLUnit 1.3 to 1.4</title> - <section id="Breaking Changes 1.3"> + <section id="Breaking Changes 1.4"> <title>Breaking Changes</title> <!--itemizedlist> @@ -3628,8 +3662,14 @@ <section id="New Features 1.4"> <title>New Features</title> - <!--itemizedlist> - </itemizedlist--> + <itemizedlist> + <listitem> + xsi:type attributes now have their value interpreted as a + QName and will compare as identical if their namespace URI + and local names match even if they use different + prefixes. <ulink url="https://sourceforge.net/tracker/?func=detail&aid=3602981&group_id=23187&atid=377771">Issue 3602981</ulink> + </listitem> + </itemizedlist> </section> <section id="Bugfixes 1.4"> @@ -3639,9 +3679,18 @@ <listitem> <literal>XMLTestCase</literal>'s and <literal>XMLAssert</literal>'s <literal>assertXpathsEqual</literal> methods threw an - exception at least one XPath matched an attribute. <ulink + exception when at least one XPath matched an attribute. <ulink url="https://sourceforge.net/tracker/?func=detail&aid=3290264&group_id=23187&atid=377768">Issue 377768</ulink>. </listitem> + + <listitem> + <literal>FloatingPointTolerantDifferenceListener</literal> + expected numbers to differ by less than the given + tolerance rather than "less or equal" than as the docs said. + <ulink + href="https://sourceforge.net/tracker/index.php?func=detail&aid=3593368&group_id=23187&atid=377768">Issue + 3593368</ulink> + </listitem> </itemizedlist> </section> </section> Property changes on: trunk/xmlunit/src/user-guide/XMLUnit-Java.xml ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml:346,355,494,497-517 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |