You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/07/15 19:11:49 UTC
svn commit: r1503343 - in
/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test:
AbstractCXFTest.java TestUtilities.java XPathAssert.java
Author: dkulp
Date: Mon Jul 15 17:11:48 2013
New Revision: 1503343
URL: http://svn.apache.org/r1503343
Log:
Merged revisions 1502882 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1502882 | dkulp | 2013-07-13 17:29:17 -0400 (Sat, 13 Jul 2013) | 2 lines
Add some methods to assert the qname based value of an XPath expression
........
Modified:
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java
Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?rev=1503343&r1=1503342&r2=1503343&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java (original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java Mon Jul 15 17:11:48 2013
@@ -26,6 +26,7 @@ import java.util.Map;
import javax.wsdl.WSDLException;
import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -140,6 +141,19 @@ public class AbstractCXFTest extends Ass
public void assertXPathEquals(String xpath, String value, Node node) throws Exception {
testUtilities.assertXPathEquals(xpath, value, node);
}
+
+
+ /**
+ * Assert that the text of the xpath node retrieved is equal to the value
+ * specified.
+ *
+ * @param xpath
+ * @param value
+ * @param node
+ */
+ public void assertXPathEquals(String xpath, QName value, Node node) throws Exception {
+ testUtilities.assertXPathEquals(xpath, value, node);
+ }
/**
* Assert that this node is not a SOAP fault part.
Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java?rev=1503343&r1=1503342&r2=1503343&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java (original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java Mon Jul 15 17:11:48 2013
@@ -177,6 +177,17 @@ public class TestUtilities {
public void assertXPathEquals(String xpath, String value, Node node) throws Exception {
XPathAssert.assertXPathEquals(xpath, value, node, namespaces);
}
+ /**
+ * Assert that the text of the xpath node retrieved is equal to the value
+ * specified.
+ *
+ * @param xpath
+ * @param value
+ * @param node
+ */
+ public void assertXPathEquals(String xpath, QName value, Node node) throws Exception {
+ XPathAssert.assertXPathEquals(xpath, value, node, namespaces);
+ }
/**
* Assert that this node is not a Soap fault body.
Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java?rev=1503343&r1=1503342&r2=1503343&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java (original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/XPathAssert.java Mon Jul 15 17:11:48 2013
@@ -26,6 +26,7 @@ import java.util.Map;
import javax.xml.namespace.NamespaceContext;
import javax.xml.transform.TransformerException;
+import javax.xml.namespace.QName;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -156,6 +157,42 @@ public final class XPathAssert {
+ " in document "
+ writeNodeToString(node));
}
+
+ /**
+ * Asser that the text of the xpath node retrieved is equal to the value
+ * specified.
+ *
+ * @param xpath
+ * @param value
+ * @param node
+ */
+ public static void assertXPathEquals(String xpath,
+ QName value,
+ Node node,
+ Map<String, String> namespaces)
+ throws Exception {
+ Object o = createXPath(namespaces).compile(xpath)
+ .evaluate(node, XPathConstants.NODE);
+ if (o instanceof Node) {
+ Node result = (Node)o;
+ String value2 = DOMUtils.getContent(result);
+ QName q2 = DOMUtils.createQName(value2, result);
+ Assert.assertEquals(value, q2);
+ return;
+ } else {
+ o = createXPath(namespaces).compile(xpath)
+ .evaluate(node, XPathConstants.STRING);
+ if (o instanceof String) {
+ QName q2 = DOMUtils.createQName(o.toString(), node);
+ Assert.assertEquals(value, q2);
+ return;
+ }
+ }
+ throw new AssertionFailedError("No nodes were found for expression: "
+ + xpath
+ + " in document "
+ + writeNodeToString(node));
+ }
public static void assertNoFault(Node node) throws Exception {
Map<String, String> namespaces = new HashMap<String, String>();