camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1345497 - /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeaders2Test.java
Date Sat, 02 Jun 2012 11:57:42 GMT
Author: davsclaus
Date: Sat Jun  2 11:57:42 2012
New Revision: 1345497

URL: http://svn.apache.org/viewvc?rev=1345497&view=rev
Log:
Added test based on user forum issue

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeaders2Test.java
      - copied, changed from r1345455, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeadersTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeaders2Test.java
(from r1345455, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeadersTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeaders2Test.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeaders2Test.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeadersTest.java&r1=1345455&r2=1345497&rev=1345497&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeadersTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DynamicRouterExchangeHeaders2Test.java
Sat Jun  2 11:57:42 2012
@@ -21,15 +21,18 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Header;
 import org.apache.camel.Headers;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
  * @version 
  */
-public class DynamicRouterExchangeHeadersTest extends ContextTestSupport {
+public class DynamicRouterExchangeHeaders2Test extends ContextTestSupport {
 
     private static List<String> bodies = new ArrayList<String>();
+    private static List<String> previouses = new ArrayList<String>();
 
     public void testDynamicRouter() throws Exception {
         getMockEndpoint("mock:a").expectedBodiesReceived("Hello World");
@@ -53,6 +56,12 @@ public class DynamicRouterExchangeHeader
         assertEquals("Hello World", bodies.get(2));
         assertEquals("Bye World", bodies.get(3));
         assertEquals("Bye World", bodies.get(4));
+
+        assertEquals(4, previouses.size());
+        assertEquals("mock://a", previouses.get(0));
+        assertEquals("mock://c", previouses.get(1));
+        assertEquals("direct://foo", previouses.get(2));
+        assertEquals("mock://result", previouses.get(3));
     }
 
     @Override
@@ -62,7 +71,7 @@ public class DynamicRouterExchangeHeader
             public void configure() throws Exception {
                 from("direct:start")
                     // use a bean as the dynamic router
-                    .dynamicRouter(method(DynamicRouterExchangeHeadersTest.class, "slip"));
+                    .dynamicRouter(method(DynamicRouterExchangeHeaders2Test.class, "slip"));
 
                 from("direct:foo").transform(constant("Bye World")).to("mock:foo");
             }
@@ -75,10 +84,14 @@ public class DynamicRouterExchangeHeader
      *
      * @param body the message body
      * @param headers the message headers where we can store state between invocations
+     * @param previous the previous slip
      * @return endpoints to go, or <tt>null</tt> to indicate the end
      */
-    public String slip(String body, @Headers Map<String, Object> headers) {
+    public String slip(String body, @Headers Map<String, Object> headers, @Header(Exchange.SLIP_ENDPOINT)
String previous) {
         bodies.add(body);
+        if (previous != null) {
+            previouses.add(previous);
+        }
 
         // get the state from the message headers and keep track how many times
         // we have been invoked



Mime
View raw message