camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1230601 - /camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
Date Thu, 12 Jan 2012 15:43:34 GMT
Author: hadrian
Date: Thu Jan 12 15:43:33 2012
New Revision: 1230601

URL: http://svn.apache.org/viewvc?rev=1230601&view=rev
Log:
Test for BeanParameterValue with no body

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java?rev=1230601&r1=1230600&r2=1230601&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanParameterValueTest.java
Thu Jan 12 15:43:33 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.bean;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.camel.ContextTestSupport;
@@ -83,6 +84,19 @@ public class BeanParameterValueTest exte
         assertMockEndpointsSatisfied();
     }
 
+    public void testBeanParameterNoBody() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Is Hadrian 21 years old?");
+
+        Map<String, Object> headers = new HashMap<String, Object>();
+        headers.put("SomeTest", true);
+        headers.put("SomeAge", 21);
+        headers.put("SomeName", "Hadrian");
+
+        template.sendBodyAndHeaders("direct:nobody", null, headers);
+
+        assertMockEndpointsSatisfied();
+    }
+
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
@@ -122,6 +136,10 @@ public class BeanParameterValueTest exte
                 from("direct:heads")
                     .to("bean:foo?method=heads(${body}, ${headers})")
                     .to("mock:result");
+
+                from("direct:nobody")
+                    .to("bean:foo?method=nobody(${header.SomeAge}, ${header.SomeName}, ${header.SomeTest})")
+                    .to("mock:result");
             }
         };
     }
@@ -152,5 +170,15 @@ public class BeanParameterValueTest exte
             return headers.get("hello") + " " + body;
         }
 
+        public String nobody(int age, String name, boolean question) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(question ? "Is " : "");
+            sb.append(name);
+            sb.append(question ? " " : "is ");
+            sb.append(age);
+            sb.append(" years old");
+            sb.append(question ? "?" : ".");
+            return sb.toString();
+        }
     }
 }



Mime
View raw message