camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: Added unit test based on user forum issue
Date Fri, 23 Jan 2015 12:27:08 GMT
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 <davsclaus@apache.org>
Authored: Fri Jan 23 13:27:01 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
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
+}


Mime
View raw message