camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1213597 - /camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterThreeBodyOgnlTest.java
Date Tue, 13 Dec 2011 08:36:20 GMT
Author: davsclaus
Date: Tue Dec 13 08:36:20 2011
New Revision: 1213597

URL: http://svn.apache.org/viewvc?rev=1213597&view=rev
Log:
Added unit test based on user forum issue

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterThreeBodyOgnlTest.java
      - copied, changed from r1213196, camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueOgnlTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterThreeBodyOgnlTest.java
(from r1213196, camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueOgnlTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterThreeBodyOgnlTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterThreeBodyOgnlTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueOgnlTest.java&r1=1213196&r2=1213597&rev=1213597&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueOgnlTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterThreeBodyOgnlTest.java
Tue Dec 13 08:36:20 2011
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.bean;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
@@ -23,33 +26,16 @@ import org.apache.camel.impl.JndiRegistr
 /**
  *
  */
-public class BeanParameterValueOgnlTest extends ContextTestSupport {
+public class BeanParameterThreeBodyOgnlTest extends ContextTestSupport {
 
     public void testBeanParameterValue() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
-        template.sendBody("direct:start", "World");
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testBeanParameterValueBodyOgnl() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Tony");
-
-        Animal tiger = new Animal("Tony", 13);
-        template.sendBody("direct:start2", tiger);
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testBeanParameterValueHeaderOgnl() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived("Hello Kong");
-
-        Animal kong = new Animal("Kong", 34);
-        Animal tiger = new Animal("Tony", 13);
-        tiger.setFriend(kong);
+        getMockEndpoint("mock:result").expectedBodiesReceived("3");
 
-        template.sendBodyAndHeader("direct:start3", "Hello World", "animal", tiger);
+        List<String> body = new ArrayList<String>();
+        body.add("A");
+        body.add("B");
+        body.add("C");
+        template.sendBody("direct:start", body);
 
         assertMockEndpointsSatisfied();
     }
@@ -67,15 +53,7 @@ public class BeanParameterValueOgnlTest 
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("bean:foo?method=bar(${body},true)")
-                    .to("mock:result");
-
-                from("direct:start2")
-                    .to("bean:foo?method=bar(${body.name}, true)")
-                    .to("mock:result");
-
-                from("direct:start3")
-                    .to("bean:foo?method=bar(${header.animal?.friend.name}, true)")
+                    .to("bean:foo?method=bar(${body[0]},${body[1]},${body[2]})")
                     .to("mock:result");
             }
         };
@@ -83,62 +61,24 @@ public class BeanParameterValueOgnlTest 
 
     public static class MyBean {
 
-        public String bar(String body, boolean hello) {
-            if (hello) {
-                return "Hello " + body;
-            } else {
-                return body;
-            }
-        }
-
-        public String echo(String body, int times) {
-            if (times > 0) {
-                StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < times; i++) {
-                    sb.append(body);
-                }
-                return sb.toString();
-            }
-
-            return body;
-        }
-    }
-
-    public static final class Animal {
-        private String name;
-        private int age;
-        private Animal friend;
-
-        private Animal(String name, int age) {
-            this.name = name;
-            this.age = age;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public int getAge() {
-            return age;
-        }
-
-        public Animal getFriend() {
-            return friend;
-        }
+        public String bar(String order1, String order2, String order3) {
+            assertEquals("A", order1);
+            assertEquals("B", order2);
+            assertEquals("C", order3);
 
-        public void setFriend(Animal friend) {
-            this.friend = friend;
+            return "3";
         }
 
-        public boolean isDangerous() {
-            return name.contains("Tiger");
+        public String bar(String order1, String order2) {
+            assertEquals("A", order1);
+            assertEquals("B", order2);
+            return "2";
         }
 
-        @Override
-        public String toString() {
-            return name;
+        public String bar(String order1) {
+            assertEquals("A", order1);
+            return "1";
         }
     }
 
-
 }



Mime
View raw message