You can subscribe to this list here.
2007 |
Jan
|
Feb
(3) |
Mar
(18) |
Apr
(39) |
May
(15) |
Jun
(12) |
Jul
(3) |
Aug
(23) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(21) |
Feb
(23) |
Mar
(33) |
Apr
(8) |
May
(1) |
Jun
(22) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(6) |
Nov
|
Dec
(11) |
2009 |
Jan
(5) |
Feb
|
Mar
(2) |
Apr
(24) |
May
(36) |
Jun
(18) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(3) |
Nov
(1) |
Dec
|
2010 |
Jan
(5) |
Feb
(3) |
Mar
|
Apr
(15) |
May
(24) |
Jun
(11) |
Jul
(8) |
Aug
(34) |
Sep
(42) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(13) |
Feb
(32) |
Mar
(35) |
Apr
(31) |
May
(33) |
Jun
(30) |
Jul
(32) |
Aug
(31) |
Sep
(30) |
Oct
(31) |
Nov
(32) |
Dec
(31) |
2012 |
Jan
(35) |
Feb
(31) |
Mar
(31) |
Apr
(30) |
May
(31) |
Jun
(34) |
Jul
(23) |
Aug
(30) |
Sep
(30) |
Oct
(29) |
Nov
(30) |
Dec
(32) |
2013 |
Jan
(25) |
Feb
(39) |
Mar
(1) |
Apr
(18) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(20) |
Sep
(41) |
Oct
(32) |
Nov
(9) |
Dec
(31) |
2014 |
Jan
(31) |
Feb
(30) |
Mar
(34) |
Apr
(60) |
May
(31) |
Jun
(28) |
Jul
(32) |
Aug
(28) |
Sep
(26) |
Oct
(32) |
Nov
(43) |
Dec
(115) |
2015 |
Jan
(106) |
Feb
(101) |
Mar
(51) |
Apr
(32) |
May
(63) |
Jun
(18) |
Jul
|
Aug
(18) |
Sep
|
Oct
(1) |
Nov
(84) |
Dec
(63) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(104) |
Apr
(30) |
May
(6) |
Jun
(30) |
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(48) |
Dec
(22) |
2017 |
Jan
(15) |
Feb
(29) |
Mar
(43) |
Apr
(29) |
May
(25) |
Jun
(28) |
Jul
(62) |
Aug
(35) |
Sep
(35) |
Oct
(72) |
Nov
(10) |
Dec
(4) |
2018 |
Jan
(7) |
Feb
(4) |
Mar
|
Apr
(46) |
May
(20) |
Jun
(12) |
Jul
(9) |
Aug
(42) |
Sep
(4) |
Oct
(17) |
Nov
(32) |
Dec
(31) |
2019 |
Jan
(21) |
Feb
(14) |
Mar
|
Apr
(74) |
May
(25) |
Jun
(43) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(10) |
2020 |
Jan
(1) |
Feb
|
Mar
(26) |
Apr
(8) |
May
(62) |
Jun
(4) |
Jul
(25) |
Aug
|
Sep
(21) |
Oct
(24) |
Nov
(26) |
Dec
(9) |
2021 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(11) |
Nov
(1) |
Dec
(12) |
2022 |
Jan
(47) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(14) |
2023 |
Jan
(3) |
Feb
|
Mar
(60) |
Apr
(9) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
(5) |
Feb
|
Mar
|
Apr
(10) |
May
(1) |
Jun
|
Jul
|
Aug
(17) |
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
|
Mar
(88) |
Apr
(64) |
May
(47) |
Jun
(20) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <bo...@us...> - 2010-04-29 15:37:51
|
Revision: 370 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=370&view=rev Author: bodewig Date: 2010-04-29 15:37:45 +0000 (Thu, 29 Apr 2010) Log Message: ----------- Add unit tests for XPathEngine Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-29 10:15:52 UTC (rev 369) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-29 15:37:45 UTC (rev 370) @@ -15,6 +15,7 @@ public final class Resources { public static final String ANIMAL_FILE = "src/tests/resources/test1.xml"; + public static final String BLAME_FILE = "src/tests/resources/test.blame.html"; private Resources() { } Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.java 2010-04-29 15:37:45 UTC (rev 370) @@ -0,0 +1,107 @@ +/* + 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.Resources; +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(Resources.BLAME_FILE).build(); + } + + @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 evaluateWithMultipleMatchs() { + 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()); + } +} Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/xpath/JAXPXPathEngineTest.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...> - 2010-04-29 10:15:59
|
Revision: 369 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=369&view=rev Author: bodewig Date: 2010-04-29 10:15:52 +0000 (Thu, 29 Apr 2010) Log Message: ----------- preserve order of initial Map in getPrefixes if there was one in the first place Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 10:01:38 UTC (rev 368) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 10:15:52 UTC (rev 369) @@ -17,9 +17,9 @@ import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; @@ -97,7 +97,7 @@ if (uri == null) { throw new IllegalArgumentException("uri must not be null"); } - Collection<String> c = new HashSet<String>(); + Collection<String> c = new LinkedHashSet<String>(); boolean done = false; if (XMLConstants.XML_NS_URI.equals(uri)) { c.add(XMLConstants.XML_NS_PREFIX); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 10:01:44
|
Revision: 368 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=368&view=rev Author: bodewig Date: 2010-04-29 10:01:38 +0000 (Thu, 29 Apr 2010) Log Message: ----------- extract reusable helpers Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java Added Paths: ----------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/IterableNodeList.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 09:38:19 UTC (rev 367) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 10:01:38 UTC (rev 368) @@ -15,6 +15,14 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Iterator; +import java.util.Map; +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -57,4 +65,57 @@ throw new XMLUnitException(e); } } + + /** + * Creates a JAXP NamespaceContext from a Map prefix => Namespace URI. + */ + public static NamespaceContext + toNamespaceContext(Map<String, String> prefix2URI) { + final Map<String, String> copy = + new LinkedHashMap<String, String>(prefix2URI); + return new NamespaceContext() { + public String getNamespaceURI(String prefix) { + if (prefix == null) { + throw new IllegalArgumentException("prefix must not be null"); + } + if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { + return XMLConstants.XML_NS_URI; + } + if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { + return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; + } + String uri = copy.get(prefix); + return uri != null ? uri : XMLConstants.NULL_NS_URI; + } + + public String getPrefix(String uri) { + Iterator i = getPrefixes(uri); + return i.hasNext() ? (String) i.next() : null; + } + + public Iterator getPrefixes(String uri) { + if (uri == null) { + throw new IllegalArgumentException("uri must not be null"); + } + Collection<String> c = new HashSet<String>(); + boolean done = false; + if (XMLConstants.XML_NS_URI.equals(uri)) { + c.add(XMLConstants.XML_NS_PREFIX); + done = true; + } + if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) { + c.add(XMLConstants.XMLNS_ATTRIBUTE); + done = true; + } + if (!done) { + for (Map.Entry<String, String> entry : copy.entrySet()) { + if (uri.equals(entry.getValue())) { + c.add(entry.getKey()); + } + } + } + return c.iterator(); + } + }; + } } \ No newline at end of file Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/IterableNodeList.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/IterableNodeList.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/IterableNodeList.java 2010-04-29 10:01:38 UTC (rev 368) @@ -0,0 +1,49 @@ +/* + 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.util; + +import java.util.Iterator; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * Provides an iterable view to a NodeList, the Iterator that can be + * obtained from this Iterable will be read-only. + */ +public final class IterableNodeList implements Iterable<Node> { + private final NodeList nl; + private final int length; + + public IterableNodeList(NodeList nl) { + this.nl = nl; + length = nl.getLength(); + } + + public Iterator<Node> iterator() { + return new NodeListIterator(); + } + + private class NodeListIterator implements Iterator<Node> { + private int current = 0; + public void remove() { + throw new UnsupportedOperationException(); + } + public Node next() { + return nl.item(current++); + } + public boolean hasNext() { + return current < length; + } + } +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/IterableNodeList.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java 2010-04-29 09:38:19 UTC (rev 367) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java 2010-04-29 10:01:38 UTC (rev 368) @@ -13,13 +13,7 @@ */ package net.sf.xmlunit.xpath; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; import java.util.Map; -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; import javax.xml.transform.Source; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; @@ -28,6 +22,7 @@ import net.sf.xmlunit.exceptions.ConfigurationException; import net.sf.xmlunit.exceptions.XMLUnitException; import net.sf.xmlunit.util.Convert; +import net.sf.xmlunit.util.IterableNodeList; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -59,10 +54,10 @@ */ public Iterable<Node> selectNodes(String xPath, Source s) { try { - NodeList nl = (NodeList) xpath.evaluate(xPath, - Convert.toInputSource(s), - XPathConstants.NODESET); - return new IterableNodeList(nl); + return new IterableNodeList( + (NodeList) xpath.evaluate(xPath, Convert.toInputSource(s), + XPathConstants.NODESET) + ); } catch (XPathExpressionException ex) { throw new XMLUnitException(ex); } @@ -85,81 +80,7 @@ * @param prefix2Uri maps from prefix to namespace URI. */ public void setNamespaceContext(Map<String, String> prefix2Uri) { - xpath.setNamespaceContext(new NC(prefix2Uri)); + xpath.setNamespaceContext(Convert.toNamespaceContext(prefix2Uri)); } - private static class NC implements NamespaceContext { - private final Map<String, String> prefix2Uri; - - private NC(Map<String, String> prefix2Uri) { - this.prefix2Uri = prefix2Uri; - } - - public String getNamespaceURI(String prefix) { - if (prefix == null) { - throw new IllegalArgumentException("prefix must not be null"); - } - if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { - return XMLConstants.XML_NS_URI; - } - if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { - return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - } - String uri = prefix2Uri.get(prefix); - return uri != null ? uri : XMLConstants.NULL_NS_URI; - } - - public String getPrefix(String uri) { - Iterator i = getPrefixes(uri); - return i.hasNext() ? (String) i.next() : null; - } - - public Iterator getPrefixes(String uri) { - if (uri == null) { - throw new IllegalArgumentException("uri must not be null"); - } - Collection<String> c = new HashSet<String>(); - boolean done = false; - if (XMLConstants.XML_NS_URI.equals(uri)) { - c.add(XMLConstants.XML_NS_PREFIX); - done = true; - } - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) { - c.add(XMLConstants.XMLNS_ATTRIBUTE); - done = true; - } - if (!done) { - for (Map.Entry<String, String> entry : prefix2Uri.entrySet()) { - if (uri.equals(entry.getValue())) { - c.add(entry.getKey()); - } - } - } - return c.iterator(); - } - } - - private static class IterableNodeList implements Iterable<Node> { - private final NodeList nl; - private final int length; - private int current = 0; - private IterableNodeList(NodeList nl) { - this.nl = nl; - length = nl.getLength(); - } - public Iterator<Node> iterator() { - return new Iterator<Node>() { - public void remove() { - throw new UnsupportedOperationException(); - } - public Node next() { - return nl.item(current++); - } - public boolean hasNext() { - return current < length; - } - }; - } - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 09:38:26
|
Revision: 367 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=367&view=rev Author: bodewig Date: 2010-04-29 09:38:19 +0000 (Thu, 29 Apr 2010) Log Message: ----------- rename class to leave door open for different implementations (at which point we may want to extract an interface) Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java Added Paths: ----------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java Removed Paths: ------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java Copied: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java (from rev 363, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java) =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/JAXPXPathEngine.java 2010-04-29 09:38:19 UTC (rev 367) @@ -0,0 +1,165 @@ +/* + 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.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; +import javax.xml.transform.Source; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import net.sf.xmlunit.exceptions.ConfigurationException; +import net.sf.xmlunit.exceptions.XMLUnitException; +import net.sf.xmlunit.util.Convert; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * Simplified access to JAXP's XPath API. + */ +public class JAXPXPathEngine { + private final XPath xpath; + + public JAXPXPathEngine(XPathFactory fac) { + try { + xpath = fac.newXPath(); + } catch (Exception e) { + throw new ConfigurationException(e); + } + } + + /** + * Create an XPathEngine that uses JAXP's default XPathFactory + * under the covers. + */ + public JAXPXPathEngine() { + this(XPathFactory.newInstance()); + } + + /** + * Returns a potentially empty collection of Nodes matching an + * XPath expression. + */ + public Iterable<Node> selectNodes(String xPath, Source s) { + try { + NodeList nl = (NodeList) xpath.evaluate(xPath, + Convert.toInputSource(s), + XPathConstants.NODESET); + return new IterableNodeList(nl); + } catch (XPathExpressionException ex) { + throw new XMLUnitException(ex); + } + } + + /** + * Evaluates an XPath expression and stringifies the result. + */ + public String evaluate(String xPath, Source s) { + try { + return xpath.evaluate(xPath, Convert.toInputSource(s)); + } catch (XPathExpressionException ex) { + throw new XMLUnitException(ex); + } + } + + /** + * Establish a namespace context. + * + * @param prefix2Uri maps from prefix to namespace URI. + */ + public void setNamespaceContext(Map<String, String> prefix2Uri) { + xpath.setNamespaceContext(new NC(prefix2Uri)); + } + + private static class NC implements NamespaceContext { + private final Map<String, String> prefix2Uri; + + private NC(Map<String, String> prefix2Uri) { + this.prefix2Uri = prefix2Uri; + } + + public String getNamespaceURI(String prefix) { + if (prefix == null) { + throw new IllegalArgumentException("prefix must not be null"); + } + if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { + return XMLConstants.XML_NS_URI; + } + if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { + return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; + } + String uri = prefix2Uri.get(prefix); + return uri != null ? uri : XMLConstants.NULL_NS_URI; + } + + public String getPrefix(String uri) { + Iterator i = getPrefixes(uri); + return i.hasNext() ? (String) i.next() : null; + } + + public Iterator getPrefixes(String uri) { + if (uri == null) { + throw new IllegalArgumentException("uri must not be null"); + } + Collection<String> c = new HashSet<String>(); + boolean done = false; + if (XMLConstants.XML_NS_URI.equals(uri)) { + c.add(XMLConstants.XML_NS_PREFIX); + done = true; + } + if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) { + c.add(XMLConstants.XMLNS_ATTRIBUTE); + done = true; + } + if (!done) { + for (Map.Entry<String, String> entry : prefix2Uri.entrySet()) { + if (uri.equals(entry.getValue())) { + c.add(entry.getKey()); + } + } + } + return c.iterator(); + } + } + + private static class IterableNodeList implements Iterable<Node> { + private final NodeList nl; + private final int length; + private int current = 0; + private IterableNodeList(NodeList nl) { + this.nl = nl; + length = nl.getLength(); + } + public Iterator<Node> iterator() { + return new Iterator<Node>() { + public void remove() { + throw new UnsupportedOperationException(); + } + public Node next() { + return nl.item(current++); + } + public boolean hasNext() { + return current < length; + } + }; + } + } + +} Deleted: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java 2010-04-29 08:58:05 UTC (rev 366) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java 2010-04-29 09:38:19 UTC (rev 367) @@ -1,165 +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.xpath; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import javax.xml.XMLConstants; -import javax.xml.namespace.NamespaceContext; -import javax.xml.transform.Source; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; -import net.sf.xmlunit.exceptions.ConfigurationException; -import net.sf.xmlunit.exceptions.XMLUnitException; -import net.sf.xmlunit.util.Convert; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Simplified access to JAXP's XPath API. - */ -public class XPathEngine { - private final XPath xpath; - - public XPathEngine(XPathFactory fac) { - try { - xpath = fac.newXPath(); - } catch (Exception e) { - throw new ConfigurationException(e); - } - } - - /** - * Create an XPathEngine that uses JAXP's default XPathFactory - * under the covers. - */ - public XPathEngine() { - this(XPathFactory.newInstance()); - } - - /** - * Returns a potentially empty collection of Nodes matching an - * XPath expression. - */ - public Iterable<Node> selectNodes(String xPath, Source s) { - try { - NodeList nl = (NodeList) xpath.evaluate(xPath, - Convert.toInputSource(s), - XPathConstants.NODESET); - return new IterableNodeList(nl); - } catch (XPathExpressionException ex) { - throw new XMLUnitException(ex); - } - } - - /** - * Evaluates an XPath expression and stringifies the result. - */ - public String evaluate(String xPath, Source s) { - try { - return xpath.evaluate(xPath, Convert.toInputSource(s)); - } catch (XPathExpressionException ex) { - throw new XMLUnitException(ex); - } - } - - /** - * Establish a namespace context. - * - * @param prefix2Uri maps from prefix to namespace URI. - */ - public void setNamespaceContext(Map<String, String> prefix2Uri) { - xpath.setNamespaceContext(new NC(prefix2Uri)); - } - - private static class NC implements NamespaceContext { - private final Map<String, String> prefix2Uri; - - private NC(Map<String, String> prefix2Uri) { - this.prefix2Uri = prefix2Uri; - } - - public String getNamespaceURI(String prefix) { - if (prefix == null) { - throw new IllegalArgumentException("prefix must not be null"); - } - if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { - return XMLConstants.XML_NS_URI; - } - if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { - return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; - } - String uri = prefix2Uri.get(prefix); - return uri != null ? uri : XMLConstants.NULL_NS_URI; - } - - public String getPrefix(String uri) { - Iterator i = getPrefixes(uri); - return i.hasNext() ? (String) i.next() : null; - } - - public Iterator getPrefixes(String uri) { - if (uri == null) { - throw new IllegalArgumentException("uri must not be null"); - } - Collection<String> c = new HashSet<String>(); - boolean done = false; - if (XMLConstants.XML_NS_URI.equals(uri)) { - c.add(XMLConstants.XML_NS_PREFIX); - done = true; - } - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) { - c.add(XMLConstants.XMLNS_ATTRIBUTE); - done = true; - } - if (!done) { - for (Map.Entry<String, String> entry : prefix2Uri.entrySet()) { - if (uri.equals(entry.getValue())) { - c.add(entry.getKey()); - } - } - } - return c.iterator(); - } - } - - private static class IterableNodeList implements Iterable<Node> { - private final NodeList nl; - private final int length; - private int current = 0; - private IterableNodeList(NodeList nl) { - this.nl = nl; - length = nl.getLength(); - } - public Iterator<Node> iterator() { - return new Iterator<Node>() { - public void remove() { - throw new UnsupportedOperationException(); - } - public Node next() { - return nl.item(current++); - } - public boolean hasNext() { - return current < length; - } - }; - } - } - -} Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2010-04-29 08:58:05 UTC (rev 366) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2010-04-29 09:38:19 UTC (rev 367) @@ -53,24 +53,24 @@ import org.w3c.dom.NodeList; import net.sf.xmlunit.exceptions.XMLUnitException; -import net.sf.xmlunit.xpath.XPathEngine; +import net.sf.xmlunit.xpath.JAXPXPathEngine; /** * XPath engine based on javax.xml.xpath. */ public class Jaxp13XpathEngine implements XpathEngine { - private final XPathEngine engine; + private final JAXPXPathEngine engine; public Jaxp13XpathEngine() throws ConfigurationException { try { - XPathEngine e = null; + JAXPXPathEngine e = null; if (XMLUnit.getXPathFactory() != null) { - e = new XPathEngine((XPathFactory) Class - .forName(XMLUnit.getXPathFactory()) - .newInstance()); + e = new JAXPXPathEngine((XPathFactory) Class + .forName(XMLUnit.getXPathFactory()) + .newInstance()); } else { - e = new XPathEngine(); + e = new JAXPXPathEngine(); } engine = e; } catch (net.sf.xmlunit.exceptions.ConfigurationException ex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 08:58:12
|
Revision: 366 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=366&view=rev Author: bodewig Date: 2010-04-29 08:58:05 +0000 (Thu, 29 Apr 2010) Log Message: ----------- take advantage of Connvert.toInputSource Modified Paths: -------------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java 2010-04-29 08:58:05 UTC (rev 366) @@ -0,0 +1,21 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package net.sf.xmlunit; + +public final class Resources { + public static final String ANIMAL_FILE = "src/tests/resources/test1.xml"; + + private Resources() { } + +} Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/Resources.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-29 08:48:24 UTC (rev 365) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-29 08:58:05 UTC (rev 366) @@ -22,50 +22,42 @@ 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 net.sf.xmlunit.Resources; +import net.sf.xmlunit.util.Convert; +import org.junit.Test; + import static org.hamcrest.core.Is.*; import static org.hamcrest.core.IsInstanceOf.*; 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)); + return b.parse(Convert.toInputSource(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 + Document d = parse(Input.fromFile(Resources.ANIMAL_FILE).build()); Source s = Input.fromDocument(d).build(); - assertThat(s, instanceOf(DOMSource.class)); - Object o = ((DOMSource) s).getNode(); - assertThat(o, instanceOf(Document.class)); - Document d2 = (Document) o; - assertThat(d2, notNullValue()); - assertThat(d2.getDocumentElement().getTagName(), is("animal")); + allIsWellFor(s); } @Test public void shouldParseAnExistingFileByName() throws Exception { - allIsWellFor(Input.fromFile(TEST_FILE).build()); + allIsWellFor(Input.fromFile(Resources.ANIMAL_FILE).build()); } @Test public void shouldParseAnExistingFileByFile() throws Exception { - allIsWellFor(Input.fromFile(new File(TEST_FILE)).build()); + allIsWellFor(Input.fromFile(new File(Resources.ANIMAL_FILE)).build()); } @Test public void shouldParseAnExistingFileFromStream() throws Exception { FileInputStream is = null; try { - is = new FileInputStream(TEST_FILE); + is = new FileInputStream(Resources.ANIMAL_FILE); allIsWellFor(Input.fromStream(is).build()); } finally { if (is != null) { @@ -77,7 +69,7 @@ @Test public void shouldParseAnExistingFileFromReader() throws Exception { FileReader r = null; try { - r = new FileReader(TEST_FILE); + r = new FileReader(Resources.ANIMAL_FILE); allIsWellFor(Input.fromReader(r).build()); } finally { if (r != null) { @@ -96,15 +88,15 @@ } @Test public void shouldParseFileFromURIString() throws Exception { - allIsWellFor(Input.fromURI("file:" + TEST_FILE).build()); + allIsWellFor(Input.fromURI("file:" + Resources.ANIMAL_FILE).build()); } @Test public void shouldParseFileFromURI() throws Exception { - allIsWellFor(Input.fromURI(new URI("file:" + TEST_FILE)).build()); + allIsWellFor(Input.fromURI(new URI("file:" + Resources.ANIMAL_FILE)).build()); } @Test public void shouldParseFileFromURL() throws Exception { - allIsWellFor(Input.fromURL(new URL("file:" + TEST_FILE)).build()); + allIsWellFor(Input.fromURL(new URL("file:" + Resources.ANIMAL_FILE)).build()); } @Test public void shouldParseATransformationFromSource() throws Exception { @@ -113,13 +105,7 @@ .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl") .build()) .build(); - // again, transformed is a DOMSource, cannot use parse() - assertThat(s, instanceOf(DOMSource.class)); - Object o = ((DOMSource) s).getNode(); - assertThat(o, instanceOf(Document.class)); - Document d2 = (Document) o; - assertThat(d2, notNullValue()); - assertThat(d2.getDocumentElement().getTagName(), is("furry")); + allIsWellFor(s, "furry"); } @Test public void shouldParseATransformationFromBuilder() throws Exception { @@ -127,24 +113,23 @@ Source s = Input.byTransforming(input) .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl")) .build(); - // again, transformed is a DOMSource, cannot use parse() - assertThat(s, instanceOf(DOMSource.class)); - Object o = ((DOMSource) s).getNode(); - assertThat(o, instanceOf(Document.class)); - Document d2 = (Document) o; - assertThat(d2, notNullValue()); - assertThat(d2.getDocumentElement().getTagName(), is("furry")); + allIsWellFor(s, "furry"); } private static void allIsWellFor(Source s) throws Exception { + allIsWellFor(s, "animal"); + } + + private static void allIsWellFor(Source s, String rootElementName) + throws Exception { assertThat(s, notNullValue()); Document d = parse(s); assertThat(d, notNullValue()); - assertThat(d.getDocumentElement().getTagName(), is("animal")); + assertThat(d.getDocumentElement().getTagName(), is(rootElementName)); } private static byte[] readTestFile() throws Exception { - FileInputStream is = new FileInputStream(TEST_FILE); + FileInputStream is = new FileInputStream(Resources.ANIMAL_FILE); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int read = -1; Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-29 08:48:24 UTC (rev 365) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-29 08:58:05 UTC (rev 366) @@ -21,6 +21,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; +import net.sf.xmlunit.Resources; import org.hamcrest.core.IsNull; import org.junit.Test; import org.w3c.dom.Document; @@ -31,8 +32,6 @@ public class ConvertTest { - private static final String TEST_FILE = "src/tests/resources/test1.xml"; - private static void convertAndAssert(Source s) throws Exception { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); @@ -42,18 +41,18 @@ } @Test public void streamSourceToInputSource() throws Exception { - convertAndAssert(new StreamSource(new File(TEST_FILE))); + convertAndAssert(new StreamSource(new File(Resources.ANIMAL_FILE))); } @Test public void domSourceToInputSource() throws Exception { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document d = b.parse(new File(TEST_FILE)); + Document d = b.parse(new File(Resources.ANIMAL_FILE)); convertAndAssert(new DOMSource(d)); } @Test public void saxSourceToInputSource() throws Exception { - InputSource s = new InputSource(new FileInputStream(TEST_FILE)); + InputSource s = new InputSource(new FileInputStream(Resources.ANIMAL_FILE)); convertAndAssert(new SAXSource(s)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 08:48:30
|
Revision: 365 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=365&view=rev Author: bodewig Date: 2010-04-29 08:48:24 +0000 (Thu, 29 Apr 2010) Log Message: ----------- test for convert Added Paths: ----------- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java Added: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java (rev 0) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.java 2010-04-29 08:48:24 UTC (rev 365) @@ -0,0 +1,60 @@ +/* + 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.util; + +import java.io.File; +import java.io.FileInputStream; +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 javax.xml.transform.stream.StreamSource; +import org.hamcrest.core.IsNull; +import org.junit.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +import static org.junit.Assert.assertThat; +import static org.hamcrest.core.Is.is; + +public class ConvertTest { + + private static final String TEST_FILE = "src/tests/resources/test1.xml"; + + private static void convertAndAssert(Source s) throws Exception { + DocumentBuilder b = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document d = b.parse(Convert.toInputSource(s)); + assertThat(d, IsNull.notNullValue()); + assertThat(d.getDocumentElement().getTagName(), is("animal")); + } + + @Test public void streamSourceToInputSource() throws Exception { + convertAndAssert(new StreamSource(new File(TEST_FILE))); + } + + @Test public void domSourceToInputSource() throws Exception { + DocumentBuilder b = + DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document d = b.parse(new File(TEST_FILE)); + convertAndAssert(new DOMSource(d)); + } + + @Test public void saxSourceToInputSource() throws Exception { + InputSource s = new InputSource(new FileInputStream(TEST_FILE)); + convertAndAssert(new SAXSource(s)); + } + +} Property changes on: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/util/ConvertTest.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...> - 2010-04-29 06:46:14
|
Revision: 364 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=364&view=rev Author: bodewig Date: 2010-04-29 06:46:08 +0000 (Thu, 29 Apr 2010) Log Message: ----------- additional convenience builder methods Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java trunk/xmlunit/src/main/net-core/builder/Input.cs trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java trunk/xmlunit/src/tests/net-core/builder/InputTest.cs Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java 2010-04-29 06:44:42 UTC (rev 363) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/builder/Input.java 2010-04-29 06:46:08 UTC (rev 364) @@ -141,6 +141,7 @@ public static interface TransformationBuilder extends Builder { TransformationBuilder withStylesheet(Source s); + TransformationBuilder withStylesheet(Builder b); TransformationBuilder withParameter(String name, Object value); TransformationBuilder withOutputProperty(String name, String value); } @@ -158,6 +159,9 @@ styleSheet = s; return this; } + public TransformationBuilder withStylesheet(Builder b) { + return withStylesheet(b.build()); + } public TransformationBuilder withOutputProperty(String name, String value) { output.setProperty(name, value); @@ -196,4 +200,8 @@ public static TransformationBuilder byTransforming(Source s) { return new Transformation(s); } + + public static TransformationBuilder byTransforming(Builder b) { + return byTransforming(b.build()); + } } Modified: trunk/xmlunit/src/main/net-core/builder/Input.cs =================================================================== --- trunk/xmlunit/src/main/net-core/builder/Input.cs 2010-04-29 06:44:42 UTC (rev 363) +++ trunk/xmlunit/src/main/net-core/builder/Input.cs 2010-04-29 06:46:08 UTC (rev 364) @@ -83,6 +83,7 @@ public interface ITransformationBuilder : IBuilder { ITransformationBuilder WithStylesheet(ISource s); + ITransformationBuilder WithStylesheet(IBuilder b); ITransformationBuilder WithExtensionObject(string namespaceUri, object extension); ITransformationBuilder WithParameter(string name, @@ -101,6 +102,9 @@ this.styleSheet = s; return this; } + public ITransformationBuilder WithStylesheet(IBuilder b) { + return WithStylesheet(b.Build()); + } public ITransformationBuilder WithExtensionObject(string namespaceUri, object extension) { @@ -137,5 +141,8 @@ public static ITransformationBuilder ByTransforming(ISource s) { return new Transformation(s); } + public static ITransformationBuilder ByTransforming(IBuilder b) { + return ByTransforming(b.Build()); + } } } Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-29 06:44:42 UTC (rev 363) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/builder/InputTest.java 2010-04-29 06:46:08 UTC (rev 364) @@ -107,7 +107,7 @@ allIsWellFor(Input.fromURL(new URL("file:" + TEST_FILE)).build()); } - @Test public void shouldParseATransformation() throws Exception { + @Test public void shouldParseATransformationFromSource() throws Exception { Source input = Input.fromMemory("<animal>furry</animal>").build(); Source s = Input.byTransforming(input) .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl") @@ -122,6 +122,20 @@ assertThat(d2.getDocumentElement().getTagName(), is("furry")); } + @Test public void shouldParseATransformationFromBuilder() throws Exception { + Input.Builder input = Input.fromMemory("<animal>furry</animal>"); + Source s = Input.byTransforming(input) + .withStylesheet(Input.fromFile("src/tests/resources/animal.xsl")) + .build(); + // again, transformed is a DOMSource, cannot use parse() + assertThat(s, instanceOf(DOMSource.class)); + Object o = ((DOMSource) s).getNode(); + assertThat(o, instanceOf(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); Modified: trunk/xmlunit/src/tests/net-core/builder/InputTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/builder/InputTest.cs 2010-04-29 06:44:42 UTC (rev 363) +++ trunk/xmlunit/src/tests/net-core/builder/InputTest.cs 2010-04-29 06:46:08 UTC (rev 364) @@ -71,7 +71,7 @@ AllIsWellFor(Input.FromURI(new Uri("file:" + TEST_FILE)).Build()); } - [Test] public void ShouldParseATransformation() { + [Test] public void ShouldParseATransformationFromSource() { ISource input = Input.FromMemory("<animal>furry</animal>").Build(); ISource s = Input.ByTransforming(input) .WithStylesheet(Input.FromFile("../../../src/tests/resources/animal.xsl") @@ -83,6 +83,17 @@ Assert.That(d.DocumentElement.Name, Is.EqualTo("furry")); } + [Test] public void ShouldParseATransformationFromBuilder() { + Input.IBuilder input = Input.FromMemory("<animal>furry</animal>"); + ISource s = Input.ByTransforming(input) + .WithStylesheet(Input.FromFile("../../../src/tests/resources/animal.xsl")) + .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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 06:44:48
|
Revision: 363 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=363&view=rev Author: bodewig Date: 2010-04-29 06:44:42 +0000 (Thu, 29 Apr 2010) Log Message: ----------- docs - and don't hard code Source implementations SAXSource can deal with Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 06:14:31 UTC (rev 362) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 06:44:42 UTC (rev 363) @@ -25,12 +25,22 @@ import net.sf.xmlunit.exceptions.XMLUnitException; import org.xml.sax.InputSource; +/** + * Conversion methods. + */ public final class Convert { private Convert() { } + /** + * Creates a SAX InputSource from a TraX Source. + * + * <p>May use an XSLT identity transformation if SAXSource cannot + * convert it directly.</p> + */ public static InputSource toInputSource(Source s) { try { - if (!(s instanceof SAXSource) && !(s instanceof StreamSource)) { + InputSource is = SAXSource.sourceToInputSource(s); + if (is == null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); StreamResult r = new StreamResult(bos); TransformerFactory fac = TransformerFactory.newInstance(); @@ -38,8 +48,9 @@ t.transform(s, r); s = new StreamSource(new ByteArrayInputStream(bos .toByteArray())); + is = SAXSource.sourceToInputSource(s); } - return SAXSource.sourceToInputSource(s); + return is; } catch (javax.xml.transform.TransformerConfigurationException e) { throw new ConfigurationException(e); } catch (javax.xml.transform.TransformerException e) { Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java 2010-04-29 06:14:31 UTC (rev 362) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java 2010-04-29 06:44:42 UTC (rev 363) @@ -31,6 +31,9 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; +/** + * Simplified access to JAXP's XPath API. + */ public class XPathEngine { private final XPath xpath; @@ -42,10 +45,18 @@ } } + /** + * Create an XPathEngine that uses JAXP's default XPathFactory + * under the covers. + */ public XPathEngine() { this(XPathFactory.newInstance()); } + /** + * Returns a potentially empty collection of Nodes matching an + * XPath expression. + */ public Iterable<Node> selectNodes(String xPath, Source s) { try { NodeList nl = (NodeList) xpath.evaluate(xPath, @@ -57,6 +68,9 @@ } } + /** + * Evaluates an XPath expression and stringifies the result. + */ public String evaluate(String xPath, Source s) { try { return xpath.evaluate(xPath, Convert.toInputSource(s)); @@ -65,6 +79,11 @@ } } + /** + * Establish a namespace context. + * + * @param prefix2Uri maps from prefix to namespace URI. + */ public void setNamespaceContext(Map<String, String> prefix2Uri) { xpath.setNamespaceContext(new NC(prefix2Uri)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 06:14:40
|
Revision: 362 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=362&view=rev Author: bodewig Date: 2010-04-29 06:14:31 +0000 (Thu, 29 Apr 2010) Log Message: ----------- New XPath engine for Java 2.0 Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java Added Paths: ----------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java 2010-04-29 06:14:31 UTC (rev 362) @@ -0,0 +1,146 @@ +/* + 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.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; +import javax.xml.transform.Source; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import net.sf.xmlunit.exceptions.ConfigurationException; +import net.sf.xmlunit.exceptions.XMLUnitException; +import net.sf.xmlunit.util.Convert; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class XPathEngine { + private final XPath xpath; + + public XPathEngine(XPathFactory fac) { + try { + xpath = fac.newXPath(); + } catch (Exception e) { + throw new ConfigurationException(e); + } + } + + public XPathEngine() { + this(XPathFactory.newInstance()); + } + + public Iterable<Node> selectNodes(String xPath, Source s) { + try { + NodeList nl = (NodeList) xpath.evaluate(xPath, + Convert.toInputSource(s), + XPathConstants.NODESET); + return new IterableNodeList(nl); + } catch (XPathExpressionException ex) { + throw new XMLUnitException(ex); + } + } + + public String evaluate(String xPath, Source s) { + try { + return xpath.evaluate(xPath, Convert.toInputSource(s)); + } catch (XPathExpressionException ex) { + throw new XMLUnitException(ex); + } + } + + public void setNamespaceContext(Map<String, String> prefix2Uri) { + xpath.setNamespaceContext(new NC(prefix2Uri)); + } + + private static class NC implements NamespaceContext { + private final Map<String, String> prefix2Uri; + + private NC(Map<String, String> prefix2Uri) { + this.prefix2Uri = prefix2Uri; + } + + public String getNamespaceURI(String prefix) { + if (prefix == null) { + throw new IllegalArgumentException("prefix must not be null"); + } + if (XMLConstants.XML_NS_PREFIX.equals(prefix)) { + return XMLConstants.XML_NS_URI; + } + if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { + return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; + } + String uri = prefix2Uri.get(prefix); + return uri != null ? uri : XMLConstants.NULL_NS_URI; + } + + public String getPrefix(String uri) { + Iterator i = getPrefixes(uri); + return i.hasNext() ? (String) i.next() : null; + } + + public Iterator getPrefixes(String uri) { + if (uri == null) { + throw new IllegalArgumentException("uri must not be null"); + } + Collection<String> c = new HashSet<String>(); + boolean done = false; + if (XMLConstants.XML_NS_URI.equals(uri)) { + c.add(XMLConstants.XML_NS_PREFIX); + done = true; + } + if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) { + c.add(XMLConstants.XMLNS_ATTRIBUTE); + done = true; + } + if (!done) { + for (Map.Entry<String, String> entry : prefix2Uri.entrySet()) { + if (uri.equals(entry.getValue())) { + c.add(entry.getKey()); + } + } + } + return c.iterator(); + } + } + + private static class IterableNodeList implements Iterable<Node> { + private final NodeList nl; + private final int length; + private int current = 0; + private IterableNodeList(NodeList nl) { + this.nl = nl; + length = nl.getLength(); + } + public Iterator<Node> iterator() { + return new Iterator<Node>() { + public void remove() { + throw new UnsupportedOperationException(); + } + public Node next() { + return nl.item(current++); + } + public boolean hasNext() { + return current < length; + } + }; + } + } + +} Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/xpath/XPathEngine.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2010-04-29 06:13:34 UTC (rev 361) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2010-04-29 06:14:31 UTC (rev 362) @@ -42,32 +42,39 @@ import org.custommonkey.xmlunit.exceptions.ConfigurationException; import org.custommonkey.xmlunit.exceptions.XpathException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.xml.transform.dom.DOMSource; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import net.sf.xmlunit.exceptions.XMLUnitException; +import net.sf.xmlunit.xpath.XPathEngine; + /** * XPath engine based on javax.xml.xpath. */ public class Jaxp13XpathEngine implements XpathEngine { - private final XPath xpath; + private final XPathEngine engine; public Jaxp13XpathEngine() throws ConfigurationException { try { - XPathFactory f = null; + XPathEngine e = null; if (XMLUnit.getXPathFactory() != null) { - f = (XPathFactory) Class.forName(XMLUnit.getXPathFactory()) - .newInstance(); + e = new XPathEngine((XPathFactory) Class + .forName(XMLUnit.getXPathFactory()) + .newInstance()); } else { - f = XPathFactory.newInstance(); + e = new XPathEngine(); } - - xpath = f.newXPath(); + engine = e; + } catch (net.sf.xmlunit.exceptions.ConfigurationException ex) { + throw new ConfigurationException(ex.getCause()); } catch (Exception ex) { throw new ConfigurationException(ex); } @@ -84,10 +91,12 @@ public NodeList getMatchingNodes(String select, Document document) throws XpathException { try { - return (NodeList) xpath.evaluate(select, document, - XPathConstants.NODESET); - } catch (XPathExpressionException ex) { - throw new XpathException(ex); + return new NodeListForIterable(engine + .selectNodes(select, + new DOMSource(document)) + ); + } catch (XMLUnitException ex) { + throw new XpathException(ex.getCause()); } } @@ -103,13 +112,34 @@ public String evaluate(String select, Document document) throws XpathException { try { - return xpath.evaluate(select, document); - } catch (XPathExpressionException ex) { - throw new XpathException(ex); + return engine.evaluate(select, new DOMSource(document)); + } catch (XMLUnitException ex) { + throw new XpathException(ex.getCause()); } } public void setNamespaceContext(NamespaceContext ctx) { - xpath.setNamespaceContext(new XMLUnitNamespaceContext2Jaxp13(ctx)); + engine.setNamespaceContext(XMLUnitNamespaceContext2Jaxp13 + .turnIntoMap(ctx)); } + + private static class NodeListForIterable implements NodeList { + private final List<Node> l; + + private NodeListForIterable(Iterable<Node> it) { + ArrayList<Node> a = new ArrayList<Node>(); + for (Node n : it) { + a.add(n); + } + l = Collections.unmodifiableList(a); + } + + public int getLength() { + return l.size(); + } + + public Node item(int idx) { + return l.get(idx); + } + } } Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java 2010-04-29 06:13:34 UTC (rev 361) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java 2010-04-29 06:14:31 UTC (rev 362) @@ -91,7 +91,7 @@ return i.hasNext() ? (String) i.next() : null; } - private static Map turnIntoMap(NamespaceContext ctx) { + static Map turnIntoMap(NamespaceContext ctx) { HashMap/*<String, String>*/ m = new HashMap(); for (Iterator i = ctx.getPrefixes(); i.hasNext(); ) { String prefix = (String) i.next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-29 06:13:40
|
Revision: 361 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=361&view=rev Author: bodewig Date: 2010-04-29 06:13:34 +0000 (Thu, 29 Apr 2010) Log Message: ----------- extract Source => InputSource Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/ParsingValidator.java Added Paths: ----------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java Added: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java (rev 0) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java 2010-04-29 06:13:34 UTC (rev 361) @@ -0,0 +1,49 @@ +/* + 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.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import net.sf.xmlunit.exceptions.ConfigurationException; +import net.sf.xmlunit.exceptions.XMLUnitException; +import org.xml.sax.InputSource; + +public final class Convert { + private Convert() { } + + public static InputSource toInputSource(Source s) { + try { + if (!(s instanceof SAXSource) && !(s instanceof StreamSource)) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + StreamResult r = new StreamResult(bos); + TransformerFactory fac = TransformerFactory.newInstance(); + Transformer t = fac.newTransformer(); + t.transform(s, r); + s = new StreamSource(new ByteArrayInputStream(bos + .toByteArray())); + } + return SAXSource.sourceToInputSource(s); + } catch (javax.xml.transform.TransformerConfigurationException e) { + throw new ConfigurationException(e); + } catch (javax.xml.transform.TransformerException e) { + throw new XMLUnitException(e); + } + } +} \ No newline at end of file Property changes on: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Convert.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/ParsingValidator.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/ParsingValidator.java 2010-04-27 14:31:03 UTC (rev 360) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/ParsingValidator.java 2010-04-29 06:13:34 UTC (rev 361) @@ -17,9 +17,9 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXSource; import net.sf.xmlunit.exceptions.ConfigurationException; import net.sf.xmlunit.exceptions.XMLUnitException; +import net.sf.xmlunit.util.Convert; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; @@ -50,7 +50,7 @@ @Override public ValidationResult validateSchema() { throw new XMLUnitException("Schema validation is not supported by" - + " ParsinValidator"); + + " ParsingValidator"); } @Override public ValidationResult validateInstance(Source s) { @@ -69,7 +69,7 @@ if (Languages.W3C_XML_SCHEMA_NS_URI.equals(language)) { InputSource[] schemaSource = new InputSource[source.length]; for (int i = 0; i < source.length; i++) { - schemaSource[i] = toInputSource(source[i]); + schemaSource[i] = Convert.toInputSource(source[i]); } parser.setProperty(Properties.SCHEMA_SOURCE, schemaSource); @@ -77,7 +77,7 @@ handler.setSchemaSystemId(source[0].getSystemId()); } } - InputSource input = toInputSource(s); + InputSource input = Convert.toInputSource(s); try { parser.parse(input, handler); } catch (SAXException e) { @@ -101,11 +101,6 @@ } } - // TODO factor out to a common class, will be needed by other parts as well - private static InputSource toInputSource(Source s) throws SAXException { - return SAXSource.sourceToInputSource(s); - } - private static class Properties { static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2010-04-27 14:31:09
|
Revision: 360 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=360&view=rev Author: bodewig Date: 2010-04-27 14:31:03 +0000 (Tue, 27 Apr 2010) Log Message: ----------- upgrade to NUnit 2.5.5 Modified Paths: -------------- trunk/xmlunit/lib/nunit.framework.dll Modified: trunk/xmlunit/lib/nunit.framework.dll =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2010-02-22 08:14:36
|
Bugs item #1860681, was opened at 2007-12-29 22:17 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1860681&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.1 Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: jmeister (joerg-meister) Assigned to: Stefan Bodewig (bodewig) Summary: DifferenceEngine.compareNodeList Initial Comment: Hello, it seems to me as if there is a bug in the non-deprecated version of the method DifferenceEngine.compareNodeList(). To illustrate what I mean, I have generated a small example for you. Let's say, we have the following test respectively control structure: ===[ testDoc ]================================ <books> <book> <title>Kabale und Liebe</title> </book> <book> <title>Schuld und Suehne</title> </book> </books> ===[ controlDoc ]============================= <books> <book> <title>Schuld und Suehne</title> </book> </books> Now, we want to compare these structures via XMLUnit. To do so, we generate a DetailedDiff and use a MultiLevelElementNameAndTextQualifier for a correct Node matching: Diff diff = new Diff(controlDoc, testDoc); diff.overrideElementQualifier(new MultiLevelElementNameAndTextQualifier(2)); DetailedDiff dd = new DetailedDiff(diff); Iterator i = dd.getAllDifferences().iterator(); while (i.hasNext()) System.err.println((Difference) i.next()); The result of the comparison are the following error messages (the structure of the messages are always "comparing <ctrl_node> to <test_node>" with their respective XPaths): Expected number of child nodes '1' but was '2' - comparing <books...> at /books[1] to <books...> at /books[1] Expected sequence of child nodes '0' but was '1' - comparing <book...> at /books[1]/book[1] to <book...> at /books[1]/book[2] Expected presence of child node 'null' but was 'book' - comparing at /books[1]/book[1] to <book...> at /books[1]/book[2] The first and the second message are OK. XMLUnit compared the node "Schuld und Suehne" of the control structure (/books[1]/book[1]) to "Schuld und Suehne" of the test structure (/books[1]/book[2]) and recognized, that the sequence of nodes is different. Now the problem arises: Since there are no more nodes in the control structure, but one node left in the test structure, the DifferenceEngine throws a "CHILD_NODE_NOT_FOUND" message for this node. The problem is, that the XpathNodeTracker for test and control structure are not updated in the source code, therefore they return the wrong XPath for the unmatched node "Kabale and Liebe" - it says it is "/books[1]/book[2]", but in reality it is "/books[1]/book[1]"... In this case (a node in the test structure has no counterpart in the control structure or the other way around), the XpathNodeTracker always return the XPaths to the last node matched in test respectively control structure... I have attached a proposal of how this problem may be solved. Therefore you would have to change the DifferenceEngine as well as the XpathNodeTracker. I have marked up the lines within the source code with the key word "CODE_CHANGE", so it should be easy for you to understand what I mean. If you realize it that way, the result for the example given above would be: Expected number of child nodes '1' but was '2' - comparing <books...> at /books[1] to <books...> at /books[1] Expected sequence of child nodes '0' but was '1' - comparing <book...> at /books[1]/book[1] to <book...> at /books[1]/book[2] Expected presence of child node 'null' but was 'book' - comparing at to <book...> at /books[1]/book[1] Why is it that important, that you fix this bug? Well, if you want to react on the "CHILD_NODE_NOT_FOUND" event in a DifferenceListener, then you will need the exact XPath for the node that has no counterpart. At the moment, the wrong XPath is returned. Besides that, the error message in its current form is confusing... I have used JUnit 3.8.1 Xerces 2.8.1 XMLUnit 1.1 Hope this helps, Joerg ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2010-02-22 08:14 Message: TUB5XZ <a href="http://qizpwpjussiq.com/">qizpwpjussiq</a>, [url=http://rzvyyqyndhrr.com/]rzvyyqyndhrr[/url], [link=http://rcpiomnpsamu.com/]rcpiomnpsamu[/link], http://ikbptnwfbptt.com/ ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-03-03 16:07 Message: Logged In: YES user_id=113148 Originator: NO should be fixed in svn trunk now. See http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=240 ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-01-04 10:29 Message: Logged In: YES user_id=113148 Originator: NO Hi Jörg, I've turned your test into a testcase and committed a disabled version of it (stating my expectations of what the XPaths should be) to svn: http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=236 Later I'm going to review your changes and we'll see whether they also address the reverse case. It would help tremendously if you could provide your changes as patches (what "svn diff" would give you in a checked out copy) instead of full files in the future. Thanks for the report ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1860681&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-02-08 12:33:25
|
Bugs item #2946497, was opened at 2010-02-05 12:56 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2946497&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.2 Status: Open Resolution: None Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: Error for xmls with different child & attr sequence Initial Comment: I have two xmls XML 1 <root> <Override ContentType="slideLayout+xml" PartName="slideLayout1.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout8.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout7.xml" /> </root> XML 2 <root> <Override ContentType="slideLayout+xml" PartName="slideLayout8.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout1.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout7.xml" /> </root> XML 3 <root> <Override PartName="slideLayout8.xml" ContentType="slideLayout+xml" /> <Override PartName="slideLayout1.xml" ContentType="slideLayout+xml" /> <Override PartName="slideLayout7.xml" ContentType="slideLayout+xml" /> </root> Accordingly to me all the xmls are equal. I tried using TestCase.java (attached here) to compare them. I tried to compare these two xmls ignoring both the child sequence as well as the attribute sequence, but xml unit still complains they are different. Here is the source code I tried, please let me know what changes do I do my source in order to make XMLUnit say the three xml files are equal. import java.io.IOException; import java.util.List; import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Difference; import org.custommonkey.xmlunit.DifferenceConstants; import org.custommonkey.xmlunit.DifferenceListener; import org.custommonkey.xmlunit.XMLTestCase; import org.w3c.dom.Node; import org.xml.sax.SAXException; /** * @author rohitghatol * */ public class TestCase extends XMLTestCase { public static final String TAB = " "; private static final String leftSnippet = "<root><Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout1.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout8.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout7.xml\" /> </root>"; private static final String rightSnippet = "<root><Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout8.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout1.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout7.xml\" /> </root>"; public void compareString(final String leftContent, final String rightContent) throws SAXException, IOException { final DetailedDiff myDiff = new DetailedDiff(compareXML(leftContent, rightContent)); myDiff.overrideDifferenceListener(new NoSequenceDifferenceListener()); final List<Difference> allDifferences = myDiff.getAllDifferences(); if ( (null == allDifferences) || (allDifferences.size() <= 0) ) { System.out.println(TAB + "No Difference found"); } else { System.out.println(TAB + allDifferences.size() + " number of difference found"); } int index = 0; for ( final Difference diff : allDifferences ) { System.out.println(TAB + ":" + (index++) + ": Difference = " + diff); } System.out.println("======================================================="); } private class NoSequenceDifferenceListener implements DifferenceListener { /* * (non-Javadoc) * @see org.custommonkey.xmlunit.DifferenceListener#differenceFound(org.custommonkey.xmlunit.Difference) */ @Override public int differenceFound(final Difference diff) { int returnVal = DifferenceListener.RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; switch ( diff.getId() ) { case DifferenceConstants.ATTR_SEQUENCE_ID: case DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID: returnVal = DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; break; default: returnVal = DifferenceListener.RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; } return returnVal; } /* * (non-Javadoc) * @see org.custommonkey.xmlunit.DifferenceListener#skippedComparison(org.w3c.dom.Node, org.w3c.dom.Node) */ @Override public void skippedComparison(final Node node1, final Node node2) { System.out.println("---> node1 " + node1.getLocalName()); } } public static void main(final String[] args) throws SAXException, IOException { final TestCase testcase = new TestCase(); testcase.compareString(leftSnippet, rightSnippet); } } ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2010-02-08 13:33 Message: Your problem is not related to attribute order at all, XMLUnit is just not comparing the elements you want it to compare, Dy default it will match XML elements by their name and since in your case all elements have the same name it will compare them in order. What you want is to tell XMLUnit it should only compare the elements that have the same name and the same PartName attribute. To do so, you'd use an ElementNameAndAttributeQualifier - see http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#ElementNameAndAttributeQualifier ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2946497&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-02-05 11:56:10
|
Bugs item #2946497, was opened at 2010-02-05 11:56 Message generated for change (Tracker Item Submitted) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2946497&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.2 Status: Open Resolution: None Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: Error for xmls with different child & attr sequence Initial Comment: I have two xmls XML 1 <root> <Override ContentType="slideLayout+xml" PartName="slideLayout1.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout8.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout7.xml" /> </root> XML 2 <root> <Override ContentType="slideLayout+xml" PartName="slideLayout8.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout1.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout7.xml" /> </root> XML 3 <root> <Override PartName="slideLayout8.xml" ContentType="slideLayout+xml" /> <Override PartName="slideLayout1.xml" ContentType="slideLayout+xml" /> <Override PartName="slideLayout7.xml" ContentType="slideLayout+xml" /> </root> Accordingly to me all the xmls are equal. I tried using TestCase.java (attached here) to compare them. I tried to compare these two xmls ignoring both the child sequence as well as the attribute sequence, but xml unit still complains they are different. Here is the source code I tried, please let me know what changes do I do my source in order to make XMLUnit say the three xml files are equal. import java.io.IOException; import java.util.List; import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Difference; import org.custommonkey.xmlunit.DifferenceConstants; import org.custommonkey.xmlunit.DifferenceListener; import org.custommonkey.xmlunit.XMLTestCase; import org.w3c.dom.Node; import org.xml.sax.SAXException; /** * @author rohitghatol * */ public class TestCase extends XMLTestCase { public static final String TAB = " "; private static final String leftSnippet = "<root><Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout1.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout8.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout7.xml\" /> </root>"; private static final String rightSnippet = "<root><Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout8.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout1.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout7.xml\" /> </root>"; public void compareString(final String leftContent, final String rightContent) throws SAXException, IOException { final DetailedDiff myDiff = new DetailedDiff(compareXML(leftContent, rightContent)); myDiff.overrideDifferenceListener(new NoSequenceDifferenceListener()); final List<Difference> allDifferences = myDiff.getAllDifferences(); if ( (null == allDifferences) || (allDifferences.size() <= 0) ) { System.out.println(TAB + "No Difference found"); } else { System.out.println(TAB + allDifferences.size() + " number of difference found"); } int index = 0; for ( final Difference diff : allDifferences ) { System.out.println(TAB + ":" + (index++) + ": Difference = " + diff); } System.out.println("======================================================="); } private class NoSequenceDifferenceListener implements DifferenceListener { /* * (non-Javadoc) * @see org.custommonkey.xmlunit.DifferenceListener#differenceFound(org.custommonkey.xmlunit.Difference) */ @Override public int differenceFound(final Difference diff) { int returnVal = DifferenceListener.RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; switch ( diff.getId() ) { case DifferenceConstants.ATTR_SEQUENCE_ID: case DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID: returnVal = DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; break; default: returnVal = DifferenceListener.RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; } return returnVal; } /* * (non-Javadoc) * @see org.custommonkey.xmlunit.DifferenceListener#skippedComparison(org.w3c.dom.Node, org.w3c.dom.Node) */ @Override public void skippedComparison(final Node node1, final Node node2) { System.out.println("---> node1 " + node1.getLocalName()); } } public static void main(final String[] args) throws SAXException, IOException { final TestCase testcase = new TestCase(); testcase.compareString(leftSnippet, rightSnippet); } } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2946497&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-01-08 11:24:14
|
Feature Requests item #2927652, was opened at 2010-01-07 17:23 Message generated for change (Comment added) made by bblankenburg You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927652&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Bastian Blankenburg (bblankenburg) Assigned to: Nobody/Anonymous (nobody) Summary: XML ID dereferencing difference engine Initial Comment: We have several cases where the XML ID / IDREF is used to save space for re-used elements. In such cases, the XML IDs are generated local to the XML document and do not have to be equal across documents even though their content is equivalent. For such cases, I subclasses the difference engine to not compare values of attributes with type IDREF directly, but compare the referenced elements instead. However, to determine the schema type of an attribute, it is necessary to obtain the Document via a validating parser. Thus, my implementation takes the schema and control XML source on construction, which is not elegant and makes the engine applicable only for XMLs of the given schema. Probably this feature could be better implemented in XMLUnit. Also, I added a wrapper for ComparisonController, because the standard Diff takes a DifferenceEngine on construction which cannot be changed afterwards and vice versa. So there does not seem to be a good way to use a subclass of DifferenceEngine with a standard Diff instance, but maybe I overlooked sth. here. Sources are attached. ---------------------------------------------------------------------- >Comment By: Bastian Blankenburg (bblankenburg) Date: 2010-01-08 12:24 Message: Considering the last point, after having looked through the code, I think it would be good if the assert* methods would use a configurable factory to instantiate the Diff, and the Diff should use a factory to instantiate the difference engine. That way, a custom difference engine might be used in conjunction with all assert* methods, not just the ones taking the Diff as parameter. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927652&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-01-07 16:23:12
|
Feature Requests item #2927652, was opened at 2010-01-07 17:23 Message generated for change (Tracker Item Submitted) made by bblankenburg You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927652&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Bastian Blankenburg (bblankenburg) Assigned to: Nobody/Anonymous (nobody) Summary: XML ID dereferencing difference engine Initial Comment: We have several cases where the XML ID / IDREF is used to save space for re-used elements. In such cases, the XML IDs are generated local to the XML document and do not have to be equal across documents even though their content is equivalent. For such cases, I subclasses the difference engine to not compare values of attributes with type IDREF directly, but compare the referenced elements instead. However, to determine the schema type of an attribute, it is necessary to obtain the Document via a validating parser. Thus, my implementation takes the schema and control XML source on construction, which is not elegant and makes the engine applicable only for XMLs of the given schema. Probably this feature could be better implemented in XMLUnit. Also, I added a wrapper for ComparisonController, because the standard Diff takes a DifferenceEngine on construction which cannot be changed afterwards and vice versa. So there does not seem to be a good way to use a subclass of DifferenceEngine with a standard Diff instance, but maybe I overlooked sth. here. Sources are attached. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927652&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-01-07 15:46:53
|
Feature Requests item #2927620, was opened at 2010-01-07 16:46 Message generated for change (Tracker Item Submitted) made by bblankenburg You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927620&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Bastian Blankenburg (bblankenburg) Assigned to: Nobody/Anonymous (nobody) Summary: Child element qualifier Initial Comment: I had several cases where an element has a kind of ID child element (as opposed to an ID attribute). I thus wrote an element qualifier which compares the first child elements of the control and test elements, respectively, with a given element qualifier. Together with my previous feature request (2927527), I use it e.g. this way: qualifier = new ConjunctiveElementQualifier( new ElementNameQualifier(), new DisjunctiveElementQualifier( new ChildElementQualifier("abbreviation", nameAndTextQualifier), new ChildElementQualifier("validity", nameAndTextQualifier), new ChildElementQualifier("date", nameAndTextQualifier))); This works in my case because each interesting element has exactly one of "abbreviation", "validity" or "date" child elements. Otherwise, one would need an additional qualifier which looks up the appropriate qualifier based on the element name. Source is attached. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927620&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-01-07 14:44:15
|
Feature Requests item #2927527, was opened at 2010-01-07 14:44 Message generated for change (Comment added) made by bblankenburg You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927527&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Combinatoric element qualifiers Initial Comment: I constructed some more complex element qualifiers (see my following feature request) and found it useful to construct them out of existing simple ones. I thus built - an abstract CombinatoricElementQualifier which basically just wraps a list of element qualifiers for convenience - a disjuntive element qualifier, implementing qualifier1 || qualifier2 || ... with Java semantics for || - a conjunctive element qualifier, implementing qualifier1 && qualifier2 && ... with Java semantics for && They are attached. I think others might find them or sth. similar useful (for examle, the ElementNameQualifier is frequently used in conjunction with a customized qualifier). ---------------------------------------------------------------------- Comment By: Bastian Blankenburg (bblankenburg) Date: 2010-01-07 15:44 Message: Sorry forgot to login, the above request was from me. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927527&group_id=23187 |
From: SourceForge.net <no...@so...> - 2010-01-07 13:44:56
|
Feature Requests item #2927527, was opened at 2010-01-07 13:44 Message generated for change (Tracker Item Submitted) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927527&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Combinatoric element qualifiers Initial Comment: I constructed some more complex element qualifiers (see my following feature request) and found it useful to construct them out of existing simple ones. I thus built - an abstract CombinatoricElementQualifier which basically just wraps a list of element qualifiers for convenience - a disjuntive element qualifier, implementing qualifier1 || qualifier2 || ... with Java semantics for || - a conjunctive element qualifier, implementing qualifier1 && qualifier2 && ... with Java semantics for && They are attached. I think others might find them or sth. similar useful (for examle, the ElementNameQualifier is frequently used in conjunction with a customized qualifier). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2927527&group_id=23187 |
From: SourceForge.net <no...@so...> - 2009-11-19 14:55:13
|
Feature Requests item #2900491, was opened at 2009-11-19 14:55 Message generated for change (Tracker Item Submitted) made by jan_materne You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2900491&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: XMLUnit for Java Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jan Matèrne (jan_materne) Assigned to: Nobody/Anonymous (nobody) Summary: Provide assert method for making "strictless" chess Initial Comment: For using the assertXPathEvaluatesTo() method the expected string must match the actual completely. If you just want to check if the evaluation contains a substring this is not possible at the moment. Suggestion: protected void assertXPathEvaluationContains(String expected, String xpath, Document document) throws XPathExpressionException { XPathExpression xpathExpression = XPathFactory.newInstance().newXPath().compile(xpath); String evaluate = xpathExpression.evaluate(document); if (expected == null) { assertNull(evaluate); } else { assertNotNull(evaluate); assertTrue(evaluate.contains(expected)); } } (maybe another implementation - I dont know the internals of XMLUnit) cheers Jan ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=2900491&group_id=23187 |
From: SourceForge.net <no...@so...> - 2009-10-27 10:07:17
|
Bugs item #1875554, was opened at 2008-01-19 23:43 Message generated for change (Comment added) made by elvanor You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1875554&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Closed Resolution: Works For Me Priority: 5 Private: No Submitted By: Petteri Räty (betelgeus) Assigned to: Nobody/Anonymous (nobody) Summary: testURIResolverForStylesheet fails with JDK >=1.5 Initial Comment: [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.004 sec [junit] Running org.custommonkey.xmlunit.test_SimpleXpathEngine testURIResolverForStylesheet Failure should fail because of unknown include URI junit.framework.AssertionFailedError: should fail because of unknown include URI at org.custommonkey.xmlunit.test_Transform.testURIResolverForStylesheet(test_Transform.java:137) 0.015 happens with 1.5 and 1.6. Doesn't matter whether I use the XSLT implementation from the JDK or Xalan 2.7 ---------------------------------------------------------------------- Comment By: Elvanör (elvanor) Date: 2009-10-27 10:07 Message: I tried running tests with the new 1.3 version on Gentoo (same as previous reporter), but I am running into the exact same problem. On what OS are you running the tests on? It would be nice to fix this so we can have passing tests on the official Gentoo package. PS: I could not reopen this bug (probably a permission problem). Can someone with appropriate rights do? ---------------------------------------------------------------------- Comment By: SourceForge Robot (sf-robot) Date: 2008-03-14 02:20 Message: Logged In: YES user_id=1312539 Originator: NO This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-02-28 11:39 Message: Logged In: YES user_id=113148 Originator: NO strange, it passes for me on JDK 1.6 as well as Apache Gump running Java 5 http://vmgump.apache.org/gump/public/xmlunit/xmlunit/gump_work/build_xmlunit_xmlunit.html or Java 6 http://gump.zones.apache.org/gump/test/xmlunit/xmlunit/gump_work/build_xmlunit_xmlunit.html ---------------------------------------------------------------------- Comment By: Petteri Räty (betelgeus) Date: 2008-01-19 23:44 Message: Logged In: YES user_id=924568 Originator: YES [junit] Tests run: 8, Failures: 1, Errors: 0, Time elapsed: 0.209 sec [junit] TEST org.custommonkey.xmlunit.test_Transform FAILED Wrong line pasted ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=1875554&group_id=23187 |
From: SourceForge.net <no...@so...> - 2009-10-16 14:45:06
|
Bugs item #2880531, was opened at 2009-10-16 16:44 Message generated for change (Tracker Item Submitted) made by thehpi You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2880531&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Hans Pikkemaat (thehpi) Assigned to: Nobody/Anonymous (nobody) Summary: xml file comparison fails Initial Comment: If I run attached java example with arguments the 2 other file attachments, the comparison fails. Maybe I'm wrong but I would expect this to succeed. I used a macbook pro on java 1.5. If I'm making a mistake please let me know. Hans ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2880531&group_id=23187 |
From: SourceForge.net <no...@so...> - 2009-10-06 02:20:55
|
Bugs item #2758280, was opened at 2009-04-13 08:55 Message generated for change (Comment added) made by sf-robot You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2758280&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: Virat Gohil (viratgohil) Assigned to: Nobody/Anonymous (nobody) Summary: Elements being compared even if they do not qualify. Initial Comment: Control XML <a>1</a> <b>1</b> <c>1</c> <d>1</d> <e>1</e> The test XML looks like this: <a>1</a> <b>1</b> <z>1</z> <c>1</c> <d>1</d> <e>1</e> I figured out that the DifferenceEngine.compareNodeList() does the following: 1. It compiles a list of objects that are comparable (qualifies for comparison). 2. Once this operation is complete, there will be 3 lists available: a. List of comparable objects b. list of objects present in control node but absent in test node. c. list of objects present in test node but absent in control node. 3. Compares the comparable objects. 4. compares the objects in list b against list c (above), even though they do not qualify for comparison. I think point 4 is a defect. I downloaded the source code and modified the following: Original: DifferenceEngine.java:435 if (nextTest == null && !unmatchedTestNodes.isEmpty()) { nextTest = (Node) unmatchedTestNodes.get(0); testIndex = new Integer(testChildren.indexOf(nextTest)); unmatchedTestNodes.remove(0); } Modify: if (nextTest == null && !unmatchedTestNodes.isEmpty()) { nextTest = (Node) unmatchedTestNodes.get(0); if(elementQualifier.qualifyForComparison((Element)nextControl, (Element)nextTest)) { testIndex = new Integer(testChildren.indexOf(nextTest)); unmatchedTestNodes.remove(0); } else nextTest=null; } ---------------------------------------------------------------------- >Comment By: SourceForge Robot (sf-robot) Date: 2009-10-06 02:20 Message: This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2009-09-21 10:22 Message: documented with svn revision 355 (and 356 for trunk) ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2009-09-18 15:33 Message: A slightly different fix went into svn revision 353 of the 1.x branch and 354 of trunk. I'll mark this report fixed once I get around documenting the new flag in the user guide. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2009-06-09 11:12 Message: This has always been XMLUnit's behavior and there may be code that relies on the feature, so we'd need to introduce yet another configuration option. This is not too likely to happen in the 1.x codebase. We are currently redesigning the API for XMLUnit 2.x and this is something I intend to keep in mind. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2009-04-14 04:55 Message: A small change in the example XML that I submitted above: Control XML: <a>1</a> <b>1</b> <c>1</c> <d>1</d> <e>1</e> Test XML: <a>1</a> <b>1</b> <d>1</d> <e>1</e> <z>1</z> Here both the XML have same number of elements, but Test xml is missing element "c" and has an extra element "z", this will make the Difference Engine compare element "c" against element "z". Thanks, Virat ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2758280&group_id=23187 |
From: <bo...@us...> - 2009-09-21 20:00:29
|
Revision: 359 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=359&view=rev Author: bodewig Date: 2009-09-21 20:00:22 +0000 (Mon, 21 Sep 2009) Log Message: ----------- Release 1.3 Modified Paths: -------------- trunk/xmlunit/src/site/index.html Modified: trunk/xmlunit/src/site/index.html =================================================================== --- trunk/xmlunit/src/site/index.html 2009-09-21 19:39:02 UTC (rev 358) +++ trunk/xmlunit/src/site/index.html 2009-09-21 20:00:22 UTC (rev 359) @@ -60,8 +60,8 @@ <tr> <td colspan="2"> <p>The current stable release is <a - href="http://sourceforge.net/project/showfiles.php?group_id=23187&package_id=15921&release_id=605991">XMLUnit - 1.2</a>, June 2008.</p> + href="https://sourceforge.net/projects/xmlunit/files/xmlunit%20for%20Java/XMLUnit%20for%20Java%201.3/">XMLUnit + 1.3</a>, September 2009.</p> <p>XMLUnit for Java provides two JUnit extension classes, <code>XMLAssert</code> and <code>XMLTestCase</code>, and a set of supporting classes (e.g. <code>Diff</code>, <code>DetailedDiff</code>,<code>Transform</code>,<code>SimpleXpathEngine</code>,<code>Validator</code>,<code>NodeTest</code>) @@ -104,7 +104,7 @@ <tr> <td colspan="2"> <p>The current release is <a - href="https://sourceforge.net/project/showfiles.php?group_id=23187&package_id=91308">XmlUnit + href="https://sourceforge.net/projects/xmlunit/files/xmlunit%20for%20.Net/XMLUnit%20for%20.NET%200.4/">XmlUnit .Net 0.4</a>, April 2009</p> <p>XMLUnit for .Net provides NUnit extension classes written in C#, e.g. <code>XmlAssertion</code> and <code>XmlDiff</code>, that allow This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-09-21 19:39:08
|
Revision: 358 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=358&view=rev Author: bodewig Date: 2009-09-21 19:39:02 +0000 (Mon, 21 Sep 2009) Log Message: ----------- bump version Modified Paths: -------------- branches/xmlunit-1.x/LICENSE.txt branches/xmlunit-1.x/build.xml Modified: branches/xmlunit-1.x/LICENSE.txt =================================================================== --- branches/xmlunit-1.x/LICENSE.txt 2009-09-21 19:37:43 UTC (rev 357) +++ branches/xmlunit-1.x/LICENSE.txt 2009-09-21 19:39:02 UTC (rev 358) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007, Jeff Martin, Tim Bacon +Copyright (c) 2001-2009, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: branches/xmlunit-1.x/build.xml =================================================================== --- branches/xmlunit-1.x/build.xml 2009-09-21 19:37:43 UTC (rev 357) +++ branches/xmlunit-1.x/build.xml 2009-09-21 19:39:02 UTC (rev 358) @@ -37,7 +37,7 @@ <property file="build.properties"/> <!-- Version --> - <property name="xmlunit.version" value="1.3alpha"/> + <property name="xmlunit.version" value="1.4alpha"/> <!-- some locations --> <property name="src.dir" value="src"/> @@ -264,7 +264,7 @@ </target> <target name="dist" - depends="clean,bindist,srcdist,compile-userguide-examples" + depends="bindist,srcdist,compile-userguide-examples" description="creates the distribution files"> <checksum algorithm="md5"> <fileset dir="${dist.dir}"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |