Author: davsclaus
Date: Sun Sep 21 12:00:45 2008
New Revision: 697586
URL: http://svn.apache.org/viewvc?rev=697586&view=rev
Log:
CAMEL-926: beanShell added to script builder
Added:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java
(contents, props changed)
- copied, changed from r697576,
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/GroovyScriptRouteTest.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=697586&r1=697585&r2=697586&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/pom.xml (original)
+++ activemq/camel/trunk/components/camel-script/pom.xml Sun Sep 21 12:00:45
2008
@@ -185,6 +185,10 @@
<includes>
<include>**/*Test.*</include>
</includes>
+ <!-- TODO: beanshell doesnt work on java 5 yet with the
bsh-engine we got in pom right now -->
+ <excludes>
+ <exclude>**/BeanShellScriptRouteTest.*</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>
Copied:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java
(from r697576,
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/GroovyScriptRouteTest.java)
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java?p2=activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java&p1=activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/GroovyScriptRouteTest.java&r1=697576&r2=697586&rev=697586&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/GroovyScriptRouteTest.java
(original)
+++
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java
Sun Sep 21 12:00:45 2008
@@ -1,45 +1,63 @@
-/**
- * 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 org.apache.camel.ContextTestSupport;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test for a Groovy script based on end-user question.
- */
-public class GroovyScriptRouteTest extends ContextTestSupport {
-
- public void testGroovyScript() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceived("Hello World");
- mock.expectedHeaderReceived("foo", "Hello World");
-
- template.sendBodyAndHeader("seda:a", "Hello World", "foo", "London");
-
- mock.assertIsSatisfied();
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
-
from("seda:a").setHeader("foo").groovy("request.body").to("mock:result");
- }
- };
- }
-}
+/**
+ * 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 org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.builder.script.ScriptBuilder.beanShell;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Unit test for a BeanSheel script
+ */
+public class BeanShellScriptRouteTest 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);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ 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);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start").choice().
+ when(beanShell("request.headers['foo'] =
'bar'")).to("mock:result")
+ .otherwise().to("mock:unmatched");
+ }
+ };
+ }
+
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/BeanShellScriptRouteTest.java
------------------------------------------------------------------------------
svn:mergeinfo =