CAMEL-10161 Passthrough headers for outputType=StreamList

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

Branch: refs/heads/master
Commit: 35581bd089f96c3d0a5f5807048595271ed5366c
Parents: 857311b
Author: Doug Tung <[email protected]>
Authored: Tue Jul 19 23:44:43 2016 -0700
Committer: Andrea Cosentino <[email protected]>
Committed: Thu Jul 21 14:02:59 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/sql/SqlProducer.java |  2 ++
 .../sql/SqlProducerOutputTypeStreamListTest.java         | 11 +++++++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/35581bd0/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
index bf44374..da6a9cf 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
@@ -277,6 +277,8 @@ public class SqlProducer extends DefaultProducer {
             }
 
             boolean isResultSet = ps.execute();
+            //pass through all headers
+            
exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
             if (isResultSet) {
                 rs = ps.getResultSet();
                 ResultSetIterator iterator = 
getEndpoint().queryForStreamList(con, ps, rs);

http://git-wip-us.apache.org/repos/asf/camel/blob/35581bd0/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputTypeStreamListTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputTypeStreamListTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputTypeStreamListTest.java
index a0a4034..f26bc8a 100644
--- 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputTypeStreamListTest.java
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputTypeStreamListTest.java
@@ -51,6 +51,17 @@ public class SqlProducerOutputTypeStreamListTest extends 
CamelTestSupport {
     }
 
     @Test
+    public void testPreserveHeaders() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedHeaderReceived("testHeader", "testValue");
+
+        template.sendBodyAndHeader("direct:start", "testmsg", "testHeader", 
"testValue");
+
+        mock.assertIsSatisfied();
+    }
+
+    @Test
     public void testReturnAnIterator() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);

Reply via email to