camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1231440 - /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListBeanTest.java
Date Sat, 14 Jan 2012 04:47:53 GMT
Author: hadrian
Date: Sat Jan 14 04:47:52 2012
New Revision: 1231440

URL: http://svn.apache.org/viewvc?rev=1231440&view=rev
Log:
CAMEL-4894. Unit test demonstrating the problem

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListBeanTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListBeanTest.java?rev=1231440&r1=1231439&r2=1231440&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListBeanTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListBeanTest.java
Sat Jan 14 04:47:52 2012
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.processor;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -42,10 +45,27 @@ public class RecipientListBeanTest exten
 
         assertMockEndpointsSatisfied();
     }
+
+    // @Ignore("CAMEL-4894") @Test
+    public void fixmeTestRecipientListWithParams() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello b");
+
+        Map<String, Object> headers = new HashMap<String, Object>();
+        headers.put("one", 21);
+        headers.put("two", "direct:a,direct:b,direct:c");
+
+        String out = template.requestBodyAndHeaders("direct:params", "Hello World", headers,
String.class);
+        assertEquals("Hello b", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
                 from("direct:start").recipientList(bean("myBean", "foo")).to("mock:result");
+                from("direct:params").recipientList(bean("myBean", "bar(header.one, header.two)"),
",").to("mock:result");
 
                 from("direct:a").transform(constant("Hello a"));
                 from("direct:b").transform(constant("Hello b"));
@@ -59,6 +79,17 @@ public class RecipientListBeanTest exten
         public String[] foo(String body) {
             return body.split(",");
         }
+
+        public String foo(int one, String two) {
+            String [] recipients = two.split(",");
+            int count = Math.min(one, recipients.length);
+            StringBuilder answer = new StringBuilder();
+            for (int i = 0; i < count; i++) {
+                answer.append(i > 0 ? "," : "");
+                answer.append(recipients[i]);
+            }
+            return answer.toString();
+        }
     }
 
 }
\ No newline at end of file



Mime
View raw message