Author: gertv
Date: Tue Nov 24 14:54:55 2009
New Revision: 883713
URL: http://svn.apache.org/viewvc?rev=883713&view=rev
Log:
CAMEL-2221: Inconsistent out message when using dynamic recipient list
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListReturnValueTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java?rev=883713&r1=883712&r2=883713&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/MethodInfo.java
Tue Nov 24 14:54:55 2009
@@ -115,6 +115,8 @@
Object result = invoke(method, pojo, arguments, exchange);
if (recipientList != null) {
recipientList.sendToRecipientList(exchange, result);
+ // we don't want to return the list of endpoints
+ return null;
}
return result;
}
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListReturnValueTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListReturnValueTest.java?rev=883713&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListReturnValueTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListReturnValueTest.java
Tue Nov 24 14:54:55 2009
@@ -0,0 +1,90 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.*;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.processor.interceptor.Tracer;
+
+/**
+ * Tests to ensure a consistent return value when using the different ways of
+ * configuring the RecipientList pattern
+ *
+ * @version $Revision: 809819 $
+ */
+public class RecipientListReturnValueTest extends ContextTestSupport {
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("myBean", new MyBean());
+ return jndi;
+ }
+
+ public void testRecipientListWithRecipientList() throws Exception {
+ doTestRecipientList("direct:recipientList");
+ }
+
+ public void testRecipientListWithBeanRef() throws Exception {
+ doTestRecipientList("direct:beanRef");
+ }
+
+ private void doTestRecipientList(String uri) throws InterruptedException {
+ MockEndpoint a = getMockEndpoint("mock:a");
+ a.expectedBodiesReceived("Hello a");
+
+ MockEndpoint b = getMockEndpoint("mock:b");
+ b.expectedBodiesReceived("Hello b");
+
+ String out = template.requestBody(uri, "Hello " + uri, String.class);
+
+ assertEquals("Hello b", out);
+ assertMockEndpointsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ getContext().addInterceptStrategy(new Tracer());
+
+ from("direct:beanRef").beanRef("myBean", "route");
+ from("direct:recipientList").recipientList(bean("myBean",
"recipientList"));
+
+ from("direct:a").transform(constant("Hello a")).to("mock:a");
+ from("direct:b").transform(constant("Hello b")).to("mock:b");
+ }
+ };
+ }
+
+ public class MyBean {
+
+ @org.apache.camel.RecipientList
+ public String[] route() {
+ return new String[] {
+ "direct:a", "direct:b"
+ };
+ }
+
+ public String[] recipientList() {
+ return new String[] {
+ "direct:a", "direct:b"
+ };
+ }
+ }
+}