camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] git commit: CAMEL-6604: Fixed routing slip and dynamic router EIP to work with stream caching properly.
Date Sat, 03 Aug 2013 07:45:41 GMT
Updated Branches:
  refs/heads/camel-2.10.x 024ea5cc9 -> 10b3108a3
  refs/heads/camel-2.11.x 047001556 -> 2c6e0e501
  refs/heads/master 4e1b35666 -> 557514020


CAMEL-6604: Fixed routing slip and dynamic router EIP to work with stream caching properly.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55751402
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55751402
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55751402

Branch: refs/heads/master
Commit: 55751402055e01a774be3c9e3c1d440f6cfb5f1b
Parents: 4e1b356
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Aug 3 09:37:07 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Aug 3 09:37:20 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/processor/RoutingSlip.java |  5 ++
 .../processor/StreamCachingRoutingSlipTest.java | 49 ++++++++++++++++++++
 2 files changed, 54 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/55751402/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java b/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
index cd4a864..bde0f42 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
@@ -36,6 +36,7 @@ import org.apache.camel.impl.ProducerCache;
 import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.MessageHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
 import org.slf4j.Logger;
@@ -268,6 +269,10 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor,
Trace
         // exchange being routed.
         copy.setExchangeId(current.getExchangeId());
         copyOutToIn(copy, current);
+
+        // ensure stream caching is reset
+        MessageHelper.resetStreamCache(copy.getIn());
+
         return copy;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/55751402/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java
b/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java
new file mode 100644
index 0000000..9a0909b
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/StreamCachingRoutingSlipTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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 java.io.ByteArrayInputStream;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class StreamCachingRoutingSlipTest extends ContextTestSupport {
+
+    public void testByteArrayInputStream() throws Exception {
+        getMockEndpoint("mock:foo").expectedBodiesReceived("<hello/>");
+        getMockEndpoint("mock:bar").expectedBodiesReceived("<hello/>");
+        getMockEndpoint("mock:baz").expectedBodiesReceived("<hello/>");
+
+        template.sendBodyAndHeader("direct:a", new ByteArrayInputStream("<hello/>".getBytes()),
"mySlip", "mock:foo,mock:bar,mock:baz");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                context.setStreamCaching(true);
+
+                from("direct:a")
+                    .routingSlip(header("mySlip"));
+            }
+        };
+    }
+}
+


Mime
View raw message