Updated Branches: refs/heads/camel-2.11.x 04f0d8d7f -> cb53ce82f refs/heads/camel-2.12.x b972cf85c -> 6e8689a2d refs/heads/master 095fa2b4a -> d6646e648
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/d6646e64 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d6646e64 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d6646e64 Branch: refs/heads/master Commit: d6646e648cfc7e5c5ce332f5fe540f346f88ef2c Parents: 095fa2b Author: Claus Ibsen <[email protected]> Authored: Mon Feb 3 15:14:51 2014 +0100 Committer: Claus Ibsen <[email protected]> Committed: Mon Feb 3 15:14:51 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/d6646e64/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/d6646e64/tests/camel-itest-osgi/pom.xml ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/pom.xml b/tests/camel-itest-osgi/pom.xml index cb80d70..f101648 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/d6646e64/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; + } + +}
