diff options
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r-- | sca-java-2.x/trunk/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java | 27 |
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 |