summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-06-22 15:25:22 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-06-22 15:25:22 +0000
commit5eb8043a5abd44f4df8bdd7de099b45a12a251fe (patch)
tree2f63501c0cc05a90229564a1cbcdd632f3ff52bd /sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
parent49e45e8c838b1b822c2e34aa50491ed9bd523d08 (diff)
Support policy XPath functions without ns prefixes and without a single node context
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@956919 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java b/sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
index fdbdcec1c9..d2b0775361 100644
--- a/sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
+++ b/sca-java-2.x/trunk/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
@@ -57,8 +57,8 @@ public class PolicyXPathFunctionResolverTestCase {
@Test
public void testIntentsRef() throws Exception {
InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
- String str = "//sca:composite/sca:component[sca:IntentRefs('sca:confidentiality')]";
- str = normalize(str);
+ String str = "//sca:composite/sca:component[IntentRefs('sca:confidentiality')]";
+ str = normalize(str, "sca");
// Test the rewrite of xpath so that the self:node() is passed into the SCA function
XPathExpression exp = xpath.compile(str);
Object result = exp.evaluate(xml, XPathConstants.NODESET);
@@ -68,9 +68,34 @@ public class PolicyXPathFunctionResolverTestCase {
}
@Test
+ public void testIntentsRef2() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = " //sca:composite/sca:component[sca:IntentRefs('sca:confidentiality')]";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+
+ @Test
+ public void testIntentsRef3() throws Exception {
+ InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
+ String str = " IntentRefs('sca:confidentiality') ";
+ str = normalize(str, "sca");
+ // Test the rewrite of xpath so that the self:node() is passed into the SCA function
+ XPathExpression exp = xpath.compile(str);
+ Object result = exp.evaluate(xml, XPathConstants.NODESET);
+ Assert.assertTrue(result instanceof NodeList);
+ NodeList nodes = (NodeList)result;
+ Assert.assertEquals(1, nodes.getLength());
+ }
+ @Test
public void testURIRef() throws Exception {
InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
- XPathExpression exp = xpath.compile(normalize("sca:composite/sca:component[sca:URIRef('AddServiceComponent')]"));
+ XPathExpression exp = xpath.compile(normalize("sca:composite/sca:component[sca:URIRef('AddServiceComponent')]","sca"));
Object result = exp.evaluate(xml, XPathConstants.NODESET);
Assert.assertTrue(result instanceof NodeList);
NodeList nodes = (NodeList)result;
@@ -80,7 +105,7 @@ public class PolicyXPathFunctionResolverTestCase {
@Test
public void testInterfaceRef() throws Exception {
InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
- XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:service[sca:InterfaceRef('AddService')]"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:service[sca:InterfaceRef('AddService')]","sca"));
Object result = exp.evaluate(xml, XPathConstants.NODESET);
Assert.assertTrue(result instanceof NodeList);
NodeList nodes = (NodeList)result;
@@ -90,7 +115,7 @@ public class PolicyXPathFunctionResolverTestCase {
@Test
public void testOperationRef() throws Exception {
InputSource xml = new InputSource(getClass().getResourceAsStream("Calculator.composite"));
- XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:reference[sca:OperationRef('AddService/add')]"));
+ XPathExpression exp = xpath.compile(normalize("//sca:composite/sca:component/sca:reference[sca:OperationRef('AddService/add')]","sca"));
Object result = exp.evaluate(xml, XPathConstants.NODESET);
Assert.assertTrue(result instanceof NodeList);
NodeList nodes = (NodeList)result;