camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/3] git commit: CAMEL-7139: camel-mvel problem in OSGi. Thanks to Andrzej Majewski for patch.
Date Mon, 03 Feb 2014 14:17:02 GMT
CAMEL-7139: camel-mvel problem in OSGi. Thanks to Andrzej Majewski for patch.


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

Branch: refs/heads/camel-2.12.x
Commit: 6e8689a2d5d26dc9427b53e31eae56e95df39faa
Parents: b972cf8
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Feb 3 15:14:51 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Feb 3 15:17:30 2014 +0100

----------------------------------------------------------------------
 .../camel/language/mvel/MvelExpression.java     |  7 ---
 tests/camel-itest-osgi/pom.xml                  |  5 ++
 .../apache/camel/itest/osgi/mvel/MvelTest.java  | 61 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6e8689a2/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelExpression.java
----------------------------------------------------------------------
diff --git a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelExpression.java
b/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelExpression.java
index d842493..157452f 100644
--- a/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelExpression.java
+++ b/components/camel-mvel/src/main/java/org/apache/camel/language/mvel/MvelExpression.java
@@ -33,17 +33,10 @@ public class MvelExpression extends ExpressionSupport {
         this.expressionString = expressionString;
         this.type = type;
 
-        // see http://jira.codehaus.org/browse/MVEL-250
-        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
         try {
-            // set the TCCL to the MVEL
-            Thread.currentThread().setContextClassLoader(org.mvel2.MVEL.class.getClassLoader());
             this.compiled = org.mvel2.MVEL.compileExpression(expressionString);
         } catch (Exception e) {
             throw new ExpressionIllegalSyntaxException(expressionString, e);
-        } finally {
-            // restore
-            Thread.currentThread().setContextClassLoader(tccl);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/6e8689a2/tests/camel-itest-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/pom.xml b/tests/camel-itest-osgi/pom.xml
index 1d70d61..f662aa2 100644
--- a/tests/camel-itest-osgi/pom.xml
+++ b/tests/camel-itest-osgi/pom.xml
@@ -182,6 +182,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-mvel</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-hazelcast</artifactId>
       <scope>test</scope>
     </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/6e8689a2/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mvel/MvelTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mvel/MvelTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mvel/MvelTest.java
new file mode 100644
index 0000000..9bc2ffd
--- /dev/null
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mvel/MvelTest.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.osgi.mvel;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.apache.camel.itest.osgi.core.bean.MyFooBean;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+
+@RunWith(JUnit4TestRunner.class)
+public class MvelTest extends OSGiIntegrationTestSupport {
+    
+    @Test
+    public void testMvelLanguage() throws Exception {
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodyReceived();
+        
+        template.sendBody("direct:testmvel", new MyFooBean());
+       
+    }
+        
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:testmvel").choice().when().mvel("request.body instanceof org.apache.camel.itest.osgi.core.bean.MyFooBean").to("mock:result");
          
+            }
+        };
+    }
+    
+    @Configuration
+    public static Option[] configure() {
+        Option[] options = combine(
+            getDefaultCamelKarafOptions(),
+            loadCamelFeatures("camel-mvel"));
+        
+        return options;
+    }
+
+}


Mime
View raw message