servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r487126 - /incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java
Date Thu, 14 Dec 2006 08:21:51 GMT
Author: gnodet
Date: Thu Dec 14 00:21:50 2006
New Revision: 487126

URL: http://svn.apache.org/viewvc?view=rev&rev=487126
Log:
Add a test for java extensions in xpath extensions

Modified:
    incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java

Modified: incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java?view=diff&rev=487126&r1=487125&r2=487126
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java
(original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.java
Thu Dec 14 00:21:50 2006
@@ -16,7 +16,9 @@
  */
 package org.apache.servicemix.expression;
 
+import org.apache.servicemix.client.DefaultNamespaceContext;
 import org.apache.servicemix.expression.JAXPStringXPathExpression;
+import org.apache.xalan.extensions.XPathFunctionResolverImpl;
 
 
 /**
@@ -44,4 +46,19 @@
             assertExpression(new JAXPStringXPathExpression("$name"), "James", "<foo><bar
xyz='cheese'/></foo>");
         }
     }
+
+    public void testUsingJavaExtensions() throws Exception {
+        JAXPStringXPathExpression exp = new JAXPStringXPathExpression();
+        exp.setXPath("java:org.apache.servicemix.expression.JAXPXPathExpressionTest.func(string(/header/value))");
+        DefaultNamespaceContext namespaceContext = new DefaultNamespaceContext();
+        namespaceContext.add("java", "http://xml.apache.org/xalan/java");
+        exp.setNamespaceContext(namespaceContext);
+        exp.setFunctionResolver(new XPathFunctionResolverImpl());
+        assertExpression(exp, "modified12", "<header><value>12</value></header>");
+    }
+
+    public static String func(String s) {
+        return "modified" + s;
+    }
+
 }



Mime
View raw message