Repository: camel
Updated Branches:
  refs/heads/master 41f047112 -> e6fbbf046


Added some simple language tests according to the question of the mailing list


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

Branch: refs/heads/master
Commit: 210735d71e5700f93e5ef2cd75ed721e6e1692cb
Parents: 41f0471
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Fri Apr 11 20:32:56 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Fri Apr 11 20:33:42 2014 +0800

----------------------------------------------------------------------
 .../camel/language/simple/SimpleTest.java       |  6 +++
 .../language/SpringSimpleExpressionTest.java    | 38 ++++++++++++++++
 .../language/SpringSimpleExpressionTest.xml     | 47 ++++++++++++++++++++
 3 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/210735d7/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java 
b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index c9e22a3..32dec6e 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -217,6 +217,12 @@ public class SimpleTest extends LanguageTestSupport {
         assertExpression("${body[0][code]}", 4321);
     }
     
+    public void testOGNLBodyExpression() throws Exception {
+        exchange.getIn().setBody("hello world");
+        assertPredicate("${body} == 'hello world'", true);
+        assertPredicate("${body.toUpperCase()} == 'HELLO WORLD'", true);
+    }
+    
     public void testOGNLCallReplace() throws Exception {
         Map<String, Object> map = new HashMap<String, Object>();
         map.put("cool", "Camel rocks");

http://git-wip-us.apache.org/repos/asf/camel/blob/210735d7/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleExpressionTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleExpressionTest.java
 
b/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleExpressionTest.java
new file mode 100644
index 0000000..2488eff
--- /dev/null
+++ 
b/components/camel-spring/src/test/java/org/apache/camel/language/SpringSimpleExpressionTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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.language;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringSimpleExpressionTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/language/SpringSimpleExpressionTest.xml");
+    }
+    
+    public void testSimpleEmptyString() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("False");
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/210735d7/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleExpressionTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleExpressionTest.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleExpressionTest.xml
new file mode 100644
index 0000000..32879b3
--- /dev/null
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/language/SpringSimpleExpressionTest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring";>
+      <route>
+             <from uri="direct:start"/>
+          <choice>
+                <when>
+                    <simple>
+                        ${body} == "Hello World"
+                    </simple>
+                    <transform>
+                        <constant>correct</constant>
+                    </transform>
+                </when>
+                <otherwise>
+                    <transform>
+                        <constant>incorrect</constant>
+                    </transform>
+                </otherwise>
+            </choice>
+        <to uri="mock:result"/>
+      </route>
+  </camelContext>
+
+</beans>

Reply via email to