Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2C5761722E for ; Fri, 23 Jan 2015 12:27:09 +0000 (UTC) Received: (qmail 42499 invoked by uid 500); 23 Jan 2015 12:27:09 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 42430 invoked by uid 500); 23 Jan 2015 12:27:09 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 42419 invoked by uid 99); 23 Jan 2015 12:27:09 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jan 2015 12:27:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A83FBE0393; Fri, 23 Jan 2015 12:27:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: camel git commit: Added unit test based on user forum issue Date: Fri, 23 Jan 2015 12:27:08 +0000 (UTC) Repository: camel Updated Branches: refs/heads/master 7a6d7238a -> 2254699d3 Added unit test based on user forum issue Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2254699d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2254699d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2254699d Branch: refs/heads/master Commit: 2254699d3153adf483f4db4cf003dd94f1e9185f Parents: 7a6d723 Author: Claus Ibsen Authored: Fri Jan 23 13:27:01 2015 +0100 Committer: Claus Ibsen Committed: Fri Jan 23 13:27:01 2015 +0100 ---------------------------------------------------------------------- .../RecipientListExchangePropertyTest.java | 53 ++++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/2254699d/camel-core/src/test/java/org/apache/camel/processor/RecipientListExchangePropertyTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/RecipientListExchangePropertyTest.java b/camel-core/src/test/java/org/apache/camel/processor/RecipientListExchangePropertyTest.java index d450c84..784c5ed 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/RecipientListExchangePropertyTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/RecipientListExchangePropertyTest.java @@ -17,44 +17,55 @@ package org.apache.camel.processor; import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; /** * @version */ public class RecipientListExchangePropertyTest extends ContextTestSupport { - public void testRecipientExchangeProperty() throws Exception { - getMockEndpoint("mock:a").expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://a"); - getMockEndpoint("mock:a").expectedPropertyReceived(Exchange.TO_ENDPOINT, "mock://a"); - getMockEndpoint("mock:b").expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://b"); - getMockEndpoint("mock:b").expectedPropertyReceived(Exchange.TO_ENDPOINT, "mock://b"); - getMockEndpoint("mock:c").expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://c"); - getMockEndpoint("mock:c").expectedPropertyReceived(Exchange.TO_ENDPOINT, "mock://c"); + private final MyStuff myStuff = new MyStuff("Blah"); - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedBodiesReceived("Hello c"); - // would be the last one - mock.expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://c"); + public void testExchangeProperty() throws Exception { + getMockEndpoint("mock:x").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:x").message(0).property("foo").isEqualTo(myStuff); + getMockEndpoint("mock:y").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:y").message(0).property("foo").isEqualTo(myStuff); + getMockEndpoint("mock:z").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:z").message(0).property("foo").isEqualTo(myStuff); + getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); + getMockEndpoint("mock:result").message(0).property("foo").isEqualTo(myStuff); - String out = template.requestBodyAndHeader("direct:start", "Hello World", "slip", "direct:a,direct:b,direct:c", String.class); - assertEquals("Hello c", out); + template.sendBodyAndProperty("direct:a", "Hello World", "foo", myStuff); assertMockEndpointsSatisfied(); + + MyStuff stuff = getMockEndpoint("mock:result").getReceivedExchanges().get(0).getProperty("foo", MyStuff.class); + assertSame("Should be same instance", myStuff, stuff); } protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from("direct:start").recipientList(header("slip")).to("mock:result"); - - from("direct:a").to("mock:a").transform(constant("Hello a")); - from("direct:b").to("mock:b").transform(constant("Hello b")); - from("direct:c").to("mock:c").transform(constant("Hello c")); + from("direct:a") + .recipientList(constant("mock:x,mock:y,mock:z")) + .to("mock:result"); } }; + + } + + private static class MyStuff { + + private String name; + + private MyStuff(String name) { + this.name = name; + } + + public String getName() { + return name; + } } -} \ No newline at end of file +}