Author: ammulder
Date: Wed Jul 2 11:13:20 2008
New Revision: 673453
URL: http://svn.apache.org/viewvc?rev=673453&view=rev
Log:
Switch to script engines from the ServiceMix repo (newer than the ones in
the LogicBlaze repo)
Add tests for Ruby (working) and JavaScript (not working) expressions.
Re-enable Python tests -- they should be fixed not commented out.
Added:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
- copied, changed from r673135,
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/RubyExpressionTest.java
Modified:
activemq/camel/trunk/components/camel-script/pom.xml
Modified: activemq/camel/trunk/components/camel-script/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/pom.xml?rev=673453&r1=673452&r2=673453&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/pom.xml (original)
+++ activemq/camel/trunk/components/camel-script/pom.xml Wed Jul 2 11:13:20
2008
@@ -38,11 +38,17 @@
</properties>
<repositories>
+ <!-- SMX Repository is more up to date than LogicBlaze repo -->
<repository>
- <id>logicblaze.all</id>
- <name>LogicBlaze Repository</name>
- <url>http://repo.logicblaze.com/maven2-all</url>
+ <id>servicemix.apache.svn</id>
+ <name>ServiceMix Repository</name>
+ <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
</repository>
+ <!--<repository>-->
+ <!--<id>logicblaze.all</id>-->
+ <!--<name>LogicBlaze Repository</name>-->
+ <!--<url>http://repo.logicblaze.com/maven2-all</url>-->
+ <!--</repository>-->
</repositories>
<dependencies>
@@ -58,23 +64,26 @@
<version>${spring-version}</version>
</dependency>
- <!-- testing -->
+ <!-- LogicBlaze Repo Script Engines
<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <type>test-jar</type>
- <optional>true</optional>
+ <groupId>javax.script</groupId>
+ <artifactId>groovy-engine</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
+ <groupId>javax.script</groupId>
+ <artifactId>js-engine</artifactId>
+ <version>1.0</version>
+ <classifier>jdk14</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.script</groupId>
- <artifactId>groovy-engine</artifactId>
+ <artifactId>jython-engine</artifactId>
<version>1.0</version>
<classifier>jdk14</classifier>
<scope>test</scope>
@@ -82,42 +91,81 @@
<dependency>
<groupId>javax.script</groupId>
- <artifactId>js-engine</artifactId>
+ <artifactId>jruby-engine</artifactId>
<version>1.0</version>
<classifier>jdk14</classifier>
<scope>test</scope>
</dependency>
+ -->
+
+ <!-- ServiceMix Repo Script Engines -->
<dependency>
- <groupId>rhino</groupId>
- <artifactId>js</artifactId>
- <version>1.6R7</version>
+ <groupId>com.sun.script</groupId>
+ <artifactId>groovy-engine</artifactId>
+ <version>20080611</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>javax.script</groupId>
+ <groupId>com.sun.script</groupId>
+ <artifactId>js-engine</artifactId>
+ <version>20080611</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.script</groupId>
<artifactId>jython-engine</artifactId>
- <version>1.0</version>
- <classifier>jdk14</classifier>
+ <version>20080611</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>com.sun.script</groupId>
+ <artifactId>jruby-engine</artifactId>
+ <version>20080611</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <optional>true</optional>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R7</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.python</groupId>
<artifactId>jython</artifactId>
<version>2.2.1</version>
</dependency>
+
<dependency>
- <groupId>javax.script</groupId>
- <artifactId>jruby-engine</artifactId>
- <version>1.0</version>
- <classifier>jdk14</classifier>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby</artifactId>
+ <version>1.1.2</version>
<scope>test</scope>
</dependency>
@@ -167,8 +215,9 @@
</includes>
<excludes>
<!-- These tests fail/error; I haven't investigated yet.
- The PythonExpressionTest also fails but that is demonstrating
a problem that should be fixed. -->
- <exclude>**/PythonExpressionTest.*</exclude>
+ The PythonExpressionTest also fails but that is demonstrating
a problem that should be fixed.
+ Same with JavaScriptExpressionTest.
+ Same with RubyExpressionTest -->
<exclude>**/PythonLanguageTest.*</exclude>
<exclude>**/JavaScriptLanguageTest.*</exclude>
<exclude>**/GroovyFilterTest.*</exclude>
Copied:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
(from r673135,
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java)
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java?p2=activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java&p1=activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java&r1=673135&r2=673453&rev=673453&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java
(original)
+++
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
Wed Jul 2 11:13:20 2008
@@ -1,3 +1,19 @@
+/**
+ * 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.builder.script;
import java.util.Map;
@@ -6,14 +22,13 @@
import org.apache.camel.builder.RouteBuilder;
/**
- * Tests a routing expression using Python
+ * Tests a routing expression using JavaScript
*/
-public class PythonExpressionTest extends ContextTestSupport {
+public class JavaScriptExpressionTest extends ContextTestSupport {
public void testSendMatchingMessage() throws Exception {
- // Currently, this test fails because the Python expression in
createRouteBuilder
- // below returns null and that is treated as 'false', therefore it's
as if the
- // message didn't match the expression
- // To fix that, we need to figure out how to get the expression to
return a boolean
+ // Currently, this test fails because the JavaScript expression in
createRouteBuilder
+ // below returns false
+ // To fix that, we need to figure out how to get the expression to
return the right value
getMockEndpoint("mock:result").expectedMessageCount(1);
getMockEndpoint("mock:unmatched").expectedMessageCount(0);
@@ -40,10 +55,10 @@
public void configure() throws Exception {
from("direct:start").choice().
// The following python expression should return a
boolean
- // but it seems to return null instead -- what's up
with that?
- when().python("request.headers['foo'] ==
'bar'").to("mock:result")
+ // but it seems to always return false -- what's up
with that?
+ when().javaScript("request.headers['foo'] ==
'bar'").to("mock:result")
.otherwise().to("mock:unmatched");
}
};
}
-}
+}
\ No newline at end of file
Added:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/RubyExpressionTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/RubyExpressionTest.java?rev=673453&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/RubyExpressionTest.java
(added)
+++
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/RubyExpressionTest.java
Wed Jul 2 11:13:20 2008
@@ -0,0 +1,59 @@
+/**
+ * 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.builder.script;
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * Tests a routing expression using Ruby
+ */
+public class RubyExpressionTest extends ContextTestSupport {
+ public void testSendMatchingMessage() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+ getMockEndpoint("mock:unmatched").expectedMessageCount(0);
+
+ Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put("foo", "bar");
+ sendBody("direct:start", "hello", headers);
+
+ assertMockEndpointsSatisifed();
+ }
+
+ public void testSendNonMatchingMessage() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(0);
+ getMockEndpoint("mock:unmatched").expectedMessageCount(1);
+
+ Map<String, Object> headers = new HashMap<String, Object>();
+ headers.put("foo", "foo");
+ sendBody("direct:start", "hello", headers);
+
+ assertMockEndpointsSatisifed();
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start").choice().
+ when().ruby("$request.headers['foo'] ==
'bar'").to("mock:result")
+ .otherwise().to("mock:unmatched");
+ }
+ };
+ }
+}
\ No newline at end of file