You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/08/22 10:14:25 UTC

git commit: CAMEL-6656 fixed the issue that spring-batch losses header

Updated Branches:
  refs/heads/camel-2.11.x a41037c25 -> 7919dd42f


CAMEL-6656 fixed the issue that spring-batch losses header


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

Branch: refs/heads/camel-2.11.x
Commit: 7919dd42fd7cc4681dbb990a652854fd3532274d
Parents: a41037c
Author: Willem Jiang <ni...@apache.org>
Authored: Thu Aug 22 14:37:37 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Thu Aug 22 16:09:43 2013 +0800

----------------------------------------------------------------------
 .../component/spring/batch/SpringBatchProducer.java      |  1 +
 .../spring/batch/SpringBatchIntegrationTest.java         | 11 +++++++++++
 .../component/spring/batch/springBatchtestContext.xml    |  7 ++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7919dd42/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java b/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
index 8f25f2a..d50b7d0 100644
--- a/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
+++ b/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
@@ -44,6 +44,7 @@ public class SpringBatchProducer extends DefaultProducer {
     public void process(Exchange exchange) throws Exception {
         JobParameters jobParameters = prepareJobParameters(exchange.getIn().getHeaders());
         JobExecution jobExecution = jobLauncher.run(job, jobParameters);
+        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
         exchange.getOut().setBody(jobExecution);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7919dd42/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
index 77e3ad2..ea17b28 100644
--- a/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
+++ b/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
@@ -25,6 +25,8 @@ import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class SpringBatchIntegrationTest extends CamelSpringTestSupport {
+    @EndpointInject(uri = "mock:header")
+    MockEndpoint headerEndpoint;
 
     @EndpointInject(uri = "mock:output")
     MockEndpoint outputEndpoint;
@@ -60,6 +62,15 @@ public class SpringBatchIntegrationTest extends CamelSpringTestSupport {
 
         jobExecutionEventsQueueEndpoint.assertIsSatisfied();
     }
+    
+    @Test
+    public void testMessageHeader() throws Exception {
+        headerEndpoint.expectedHeaderReceived("header", 1);
+        
+        template.sendBodyAndHeader(null, "header", "1");
+        
+        headerEndpoint.assertIsSatisfied();
+    }
 
     @Override
     protected AbstractApplicationContext createApplicationContext() {

http://git-wip-us.apache.org/repos/asf/camel/blob/7919dd42/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml b/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
index ee2e6ed..7479e77 100644
--- a/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
+++ b/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
@@ -50,6 +50,11 @@
                 <camel:simple>Echo ${body}</camel:simple>
             </camel:setBody>
         </camel:route>
+        <camel:route>
+            <camel:from uri="direct:header"/>
+            <camel:to uri="spring-batch:echoJob"/>
+            <camel:to uri="mock:header"/>
+        </camel:route>
     </camel:camelContext>
 
     <camel:consumerTemplate id="consumerTemplate" camelContextId="camel"/>
@@ -91,4 +96,4 @@
         <constructor-arg value="mock:jobExecutionEventsQueue"/>
     </bean>
 
-</beans>
\ No newline at end of file
+</beans>