summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/common-xml/src
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-07-21 20:20:40 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-07-21 20:20:40 +0000
commit6ede8f5c7858d075b99bd7f75800d12e5ec2cef1 (patch)
treebe114886a906f4795ce7ab66fa2c7292a62c13a1 /sca-java-2.x/trunk/modules/common-xml/src
parent3d8624b6480be57c37076c68c179319aeef83d26 (diff)
Update regular expression to correctly handle multiple prefixes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@966400 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/common-xml/src')
-rw-r--r--sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java b/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
index a2922e9173..3b1f7b52f0 100644
--- a/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
+++ b/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.common.xml.xpath;
+import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLStreamReader;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@@ -51,6 +52,11 @@ public class XPathHelperTestCase {
+ "</c:child>"
+ "</r:root>";
+ private static String XML2 = "<definitions xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
+ "xmlns:test=\"http://docs.oasis-open.org/ns/opencsa/scatests/200903\" " +
+ "targetNamespace=\"http://docs.oasis-open.org/ns/opencsa/scatests/200903\"></definitions>";
+
private static String XPATH =
"<policySet attachTo=\"//c:child1[@name='child1']/self::node()\" xmlns:c=\"http://child1\" xmlns=\"http://p\">" + "<child xmlns:c=\"http://c2\"/></policySet>";
@@ -108,6 +114,27 @@ public class XPathHelperTestCase {
Assert.assertTrue(node instanceof Element);
Assert.assertEquals(node.getNodeName(), "c:child1");
}
+
+ @Test
+ public void testGetPrefixes() throws Exception {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(XML2);
+ reader.nextTag();
+ NamespaceContext ctx = xpathHelper.getNamespaceContext("//sca:reference[IntentRefs('test:foo')]",
+ reader.getNamespaceContext());
+ Assert.assertNotNull(ctx.getNamespaceURI("sca"));
+ Assert.assertNotNull(ctx.getNamespaceURI("test"));
+
+ }
+
+ @Test
+ public void testGetPrefixes2() throws Exception {
+ XMLStreamReader reader = staxHelper.createXMLStreamReader(XML2);
+ reader.nextTag();
+ NamespaceContext ctx = xpathHelper.getNamespaceContext("//sca:implementation.java[ IntentRefs( 'test:foo' ) ]",
+ reader.getNamespaceContext());
+ Assert.assertNotNull(ctx.getNamespaceURI("sca"));
+ Assert.assertNotNull(ctx.getNamespaceURI("test"));
+ }
/**
* @throws java.lang.Exception