camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/2] git commit: CAMEL-7319 Fixed the dead code of XPathTest.testUsingJavaExtensions
Date Sat, 22 Mar 2014 01:52:36 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 8cdc97f17 -> 111bdb120
  refs/heads/camel-2.13.x 114de3697 -> cd8aeb10e


CAMEL-7319 Fixed the dead code of XPathTest.testUsingJavaExtensions


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cd8aeb10
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cd8aeb10
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cd8aeb10

Branch: refs/heads/camel-2.13.x
Commit: cd8aeb10e354260560bd3b91a65d91d77f3d2071
Parents: 114de36
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Sat Mar 22 09:43:42 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Sat Mar 22 09:51:58 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/builder/xml/XPathTest.java | 29 ++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cd8aeb10/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java b/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
index 99eb53e..08ec4ff 100644
--- a/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
+++ b/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
@@ -268,24 +268,31 @@ public class XPathTest extends ContextTestSupport {
     }
 
     public void testUsingJavaExtensions() throws Exception {
-        Object instance;
+        Object instance = null;
 
         // we may not have Xalan on the classpath
         try {
             instance = Class.forName("org.apache.xalan.extensions.XPathFunctionResolverImpl").newInstance();
-
-            if (instance instanceof XPathFunctionResolver) {
-                XPathFunctionResolver functionResolver = (XPathFunctionResolver)instance;
-    
-                XPathBuilder builder = xpath("java:" + getClass().getName() + ".func(string(/header/value))").namespace("java",
"http://xml.apache.org/xalan/java").functionResolver(functionResolver);
-    
-                String xml = "<header><value>12</value></header>";
-                Object value = assertExpression(builder, xml, "modified12");
-                log.debug("Evaluated xpath: " + builder.getText() + " on XML: " + xml + "
result: " + value);
-            }
         } catch (Throwable e) {
+            
             log.debug("Could not find Xalan on the classpath so ignoring this test case:
" + e);
         }
+        if (instance instanceof XPathFunctionResolver) {
+            XPathFunctionResolver functionResolver = (XPathFunctionResolver)instance;
+
+            XPathBuilder builder = xpath("java:" + getClass().getName() + ".func(string(/header/value))")
+                .namespace("java", "http://xml.apache.org/xalan/java").functionResolver(functionResolver)
+                .stringResult();
+
+            String xml = "<header><value>12</value></header>";
+            // it can throw the exception if we put the xalan into the test class path
+            assertExpression(builder, xml, "modified12");
+        }
+
+    }
+    
+    public static String func(String message) {
+        return "modified" + message;
     }
 
     protected Object assertExpression(String xpath, String xml, String expected) {


Mime
View raw message