You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by bd...@apache.org on 2010/07/21 22:20:40 UTC
svn commit: r966400 -
/tuscany/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
Author: bdaniel
Date: Wed Jul 21 20:20:40 2010
New Revision: 966400
URL: http://svn.apache.org/viewvc?rev=966400&view=rev
Log:
Update regular expression to correctly handle multiple prefixes
Modified:
tuscany/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
Modified: tuscany/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java?rev=966400&r1=966399&r2=966400&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java Wed Jul 21 20:20:40 2010
@@ -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