You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/06/05 12:04:07 UTC

svn commit: r1346324 - in /camel/trunk: components/ components/camel-spring-batch/ components/camel-spring-batch/src/ components/camel-spring-batch/src/main/ components/camel-spring-batch/src/main/java/ components/camel-spring-batch/src/main/java/org/ ...

Author: davsclaus
Date: Tue Jun  5 10:04:05 2012
New Revision: 1346324

URL: http://svn.apache.org/viewvc?rev=1346324&view=rev
Log:
CAMEL-5311: Added new camel-spring-batch component. Thanks to Henryk Konsek for the patch.

Added:
    camel/trunk/components/camel-spring-batch/   (with props)
    camel/trunk/components/camel-spring-batch/pom.xml   (with props)
    camel/trunk/components/camel-spring-batch/src/
    camel/trunk/components/camel-spring-batch/src/main/
    camel/trunk/components/camel-spring-batch/src/main/java/
    camel/trunk/components/camel-spring-batch/src/main/java/org/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java   (with props)
    camel/trunk/components/camel-spring-batch/src/main/resources/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt   (with props)
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt   (with props)
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/component/spring-batch
    camel/trunk/components/camel-spring-batch/src/test/
    camel/trunk/components/camel-spring-batch/src/test/java/
    camel/trunk/components/camel-spring-batch/src/test/java/org/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java   (with props)
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java   (with props)
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java   (with props)
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java   (with props)
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java   (with props)
    camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java   (with props)
    camel/trunk/components/camel-spring-batch/src/test/resources/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/
    camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml   (with props)
Modified:
    camel/trunk/components/pom.xml
    camel/trunk/parent/pom.xml

Propchange: camel/trunk/components/camel-spring-batch/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jun  5 10:04:05 2012
@@ -0,0 +1,17 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+prj.el
+.jdee_classpath
+.jdee_sources
+velocity.log
+eclipse-classes
+*.ipr
+*.iml
+*.iws
+*.idea

Added: camel/trunk/components/camel-spring-batch/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/pom.xml?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/pom.xml (added)
+++ camel/trunk/components/camel-spring-batch/pom.xml Tue Jun  5 10:04:05 2012
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>components</artifactId>
+        <version>2.10-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-spring-batch</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: Spring Batch</name>
+    <description>Camel Spring Batch support</description>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.component.spring.batch.*</camel.osgi.export.pkg>
+        <camel.osgi.import.before.defaults>org.springframework.batch.*;version="[2,3)"
+        </camel.osgi.import.before.defaults>
+    </properties>
+
+    <dependencies>
+        <!-- Camel -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+
+        <!-- Spring Batch -->
+        <dependency>
+            <groupId>org.springframework.batch</groupId>
+            <artifactId>spring-batch-core</artifactId>
+            <version>${spring-batch-version}</version>
+        </dependency>
+
+        <!-- Tests -->
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>${commons-lang-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core-xml</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Propchange: camel/trunk/components/camel-spring-batch/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring-batch/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.component.spring.batch;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.CamelContextHelper;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.launch.JobLauncher;
+
+public class SpringBatchComponent extends DefaultComponent {
+
+    private static final String DEFAULT_JOB_LAUNCHER_REF_NAME = "jobLauncher";
+
+    private JobLauncher jobLauncher;
+
+    private JobLauncher defaultResolvedJobLauncher;
+
+    private Map<String, JobLauncher> allResolvedJobLaunchers;
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        Job resolvedJob = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining, Job.class);
+        return new SpringBatchEndpoint(uri, this, jobLauncher, defaultResolvedJobLauncher, allResolvedJobLaunchers, resolvedJob);
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        defaultResolvedJobLauncher = getCamelContext().getRegistry().lookup(DEFAULT_JOB_LAUNCHER_REF_NAME, JobLauncher.class);
+        allResolvedJobLaunchers = getCamelContext().getRegistry().lookupByType(JobLauncher.class);
+    }
+
+    public void setJobLauncher(JobLauncher jobLauncher) {
+        this.jobLauncher = jobLauncher;
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchComponent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,100 @@
+/**
+ * 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.component.spring.batch;
+
+import java.util.Map;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.launch.JobLauncher;
+
+public class SpringBatchEndpoint extends DefaultEndpoint {
+
+    private String jobLauncherRef;
+
+    private JobLauncher jobLauncher;
+
+    private JobLauncher defaultResolvedJobLauncher;
+
+    private Map<String, JobLauncher> allResolvedJobLaunchers;
+
+    private final Job job;
+
+    public SpringBatchEndpoint(String endpointUri, Component component,
+                               JobLauncher jobLauncher, JobLauncher defaultResolvedJobLauncher,
+                               Map<String, JobLauncher> allResolvedJobLaunchers,
+                               Job job) {
+        super(endpointUri, component);
+        this.jobLauncher = jobLauncher;
+        this.defaultResolvedJobLauncher = defaultResolvedJobLauncher;
+        this.allResolvedJobLaunchers = allResolvedJobLaunchers;
+        this.job = job;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new SpringBatchProducer(this, jobLauncher, job);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("Not supported");
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        if (jobLauncher == null) {
+            jobLauncher = resolveJobLauncher();
+        }
+    }
+
+    private JobLauncher resolveJobLauncher() {
+        if (jobLauncherRef != null) {
+            JobLauncher jobLauncher = getCamelContext().getRegistry().lookup(jobLauncherRef, JobLauncher.class);
+            if (jobLauncher == null) {
+                throw new IllegalStateException(String.format("No JobLauncher named %s found in the registry.", jobLauncherRef));
+            }
+            return jobLauncher;
+        }
+
+        if (defaultResolvedJobLauncher != null) {
+            return defaultResolvedJobLauncher;
+        }
+
+        if (allResolvedJobLaunchers.size() == 1) {
+            return allResolvedJobLaunchers.values().iterator().next();
+        } else if (allResolvedJobLaunchers.size() > 1) {
+            throw new IllegalStateException("Expected single jobLauncher instance. Found: " + allResolvedJobLaunchers.size());
+        }
+
+        throw new IllegalStateException("Cannot find Spring Batch JobLauncher.");
+    }
+
+    public void setJobLauncherRef(String jobLauncherRef) {
+        this.jobLauncherRef = jobLauncherRef;
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,66 @@
+/**
+ * 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.component.spring.batch;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.JobParameters;
+import org.springframework.batch.core.JobParametersBuilder;
+import org.springframework.batch.core.launch.JobLauncher;
+
+public class SpringBatchProducer extends DefaultProducer {
+
+    private final JobLauncher jobLauncher;
+
+    private final Job job;
+
+    public SpringBatchProducer(Endpoint endpoint, JobLauncher jobLauncher, Job job) {
+        super(endpoint);
+        this.job = job;
+        this.jobLauncher = jobLauncher;
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        JobParameters jobParameters = prepareJobParameters(exchange.getIn().getHeaders());
+        jobLauncher.run(job, jobParameters);
+    }
+
+    protected JobParameters prepareJobParameters(Map<String, Object> headers) {
+        JobParametersBuilder parametersBuilder = new JobParametersBuilder();
+        for (Map.Entry<String, Object> headerEntry : headers.entrySet()) {
+            String headerKey = headerEntry.getKey();
+            Object headerValue = headerEntry.getValue();
+            if (headerValue instanceof Date) {
+                parametersBuilder.addDate(headerKey, (Date) headerValue);
+            } else if (headerValue instanceof Long) {
+                parametersBuilder.addLong(headerKey, (Long) headerValue);
+            } else if (headerValue instanceof Double) {
+                parametersBuilder.addDouble(headerKey, (Double) headerValue);
+            } else {
+                parametersBuilder.addString(headerKey, headerValue.toString());
+            }
+        }
+        return parametersBuilder.toJobParameters();
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/SpringBatchProducer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.component.spring.batch.support;
+
+import org.apache.camel.ProducerTemplate;
+import org.springframework.batch.item.ItemProcessor;
+
+public class CamelItemProcessor<I, O> implements ItemProcessor<I, O> {
+
+    private final ProducerTemplate producerTemplate;
+
+    private final String endpointUri;
+
+    public CamelItemProcessor(ProducerTemplate producerTemplate, String endpointUri) {
+        this.producerTemplate = producerTemplate;
+        this.endpointUri = endpointUri;
+    }
+
+    @Override
+    public O process(I i) throws Exception {
+        return (O) producerTemplate.requestBody(endpointUri, i);
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,39 @@
+/**
+ * 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.component.spring.batch.support;
+
+import org.apache.camel.ConsumerTemplate;
+import org.springframework.batch.item.ItemReader;
+
+public class CamelItemReader<I> implements ItemReader<I> {
+
+    private final ConsumerTemplate consumerTemplate;
+
+    private final String endpointUri;
+
+    public CamelItemReader(ConsumerTemplate consumerTemplate, String endpointUri) {
+        this.consumerTemplate = consumerTemplate;
+        this.endpointUri = endpointUri;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public I read() throws Exception {
+        return (I) consumerTemplate.receiveBody(endpointUri);
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemReader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,42 @@
+/**
+ * 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.component.spring.batch.support;
+
+import java.util.List;
+
+import org.apache.camel.ProducerTemplate;
+import org.springframework.batch.item.ItemWriter;
+
+public class CamelItemWriter<I> implements ItemWriter<I> {
+
+    private final ProducerTemplate producerTemplate;
+
+    private final String endpointUri;
+
+    public CamelItemWriter(ProducerTemplate producerTemplate, String endpointUri) {
+        this.producerTemplate = producerTemplate;
+        this.endpointUri = endpointUri;
+    }
+
+    @Override
+    public void write(List<? extends I> items) throws Exception {
+        for (I item : items) {
+            producerTemplate.sendBody(endpointUri, item);
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelItemWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java (added)
+++ camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.component.spring.batch.support;
+
+import org.apache.camel.ProducerTemplate;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobExecutionListener;
+
+public class CamelJobExecutionListener implements JobExecutionListener {
+
+    private final ProducerTemplate producerTemplate;
+
+    private final String endpointUri;
+
+    public CamelJobExecutionListener(ProducerTemplate producerTemplate, String endpointUri) {
+        this.producerTemplate = producerTemplate;
+        this.endpointUri = endpointUri;
+    }
+
+    @Override
+    public void beforeJob(JobExecution jobExecution) {
+        producerTemplate.sendBodyAndHeader(endpointUri, jobExecution, EventType.HEADER_KEY, EventType.BEFORE.name());
+    }
+
+    @Override
+    public void afterJob(JobExecution jobExecution) {
+        producerTemplate.sendBodyAndHeader(endpointUri, jobExecution, EventType.HEADER_KEY, EventType.AFTER.name());
+    }
+
+    public static enum EventType {
+
+        BEFORE, AFTER;
+
+        public static final String HEADER_KEY = "SPRING_BATCH_JOB_EVENT_TYPE";
+
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt Tue Jun  5 10:04:05 2012
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Propchange: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt Tue Jun  5 10:04:05 2012
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/component/spring-batch
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/component/spring-batch?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/component/spring-batch (added)
+++ camel/trunk/components/camel-spring-batch/src/main/resources/META-INF/services/org/apache/camel/component/spring-batch Tue Jun  5 10:04:05 2012
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.spring.batch.SpringBatchComponent

Added: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java (added)
+++ camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,268 @@
+/**
+ * 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.component.spring.batch;
+
+import java.util.Date;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.SimpleRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.commons.lang.reflect.FieldUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.JobParameters;
+import org.springframework.batch.core.launch.JobLauncher;
+
+
+import static org.mockito.BDDMockito.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SpringBatchEndpointTest extends CamelTestSupport {
+
+    // Fixtures
+
+    @Mock
+    JobLauncher jobLauncher;
+
+    @Mock
+    JobLauncher alternativeJobLauncher;
+
+    @Mock
+    Job job;
+
+    // Camel fixtures
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("spring-batch:mockJob");
+            }
+        };
+    }
+
+    @Override
+    public JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("jobLauncher", jobLauncher);
+        registry.bind("alternativeJobLauncher", alternativeJobLauncher);
+        registry.bind("mockJob", job);
+        return registry;
+    }
+
+    // Tests
+
+    @Test
+    public void shouldInjectJobToEndpoint() throws IllegalAccessException {
+        SpringBatchEndpoint batchEndpoint = getMandatoryEndpoint("spring-batch:mockJob", SpringBatchEndpoint.class);
+        Job batchEndpointJob = (Job) FieldUtils.readField(batchEndpoint, "job", true);
+        assertSame(job, batchEndpointJob);
+    }
+
+    @Test
+    public void shouldRunJob() throws Exception {
+        // When
+        sendBody("direct:start", "Start the job, please.");
+
+        // Then
+        verify(jobLauncher).run(eq(job), any(JobParameters.class));
+    }
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldThrowExceptionIfUsedAsConsumer() throws Exception {
+        // When
+        context().addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("spring-batch:mockJob").to("direct:emptyEndpoint");
+            }
+        });
+    }
+
+    @Test
+    public void shouldConvertHeadersToJobParams() throws Exception {
+        // Given
+        String headerKey = "headerKey";
+        String headerValue = "headerValue";
+
+        // When
+        template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
+
+        // Then
+        ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
+        verify(jobLauncher).run(any(Job.class), jobParameters.capture());
+        String parameter = jobParameters.getValue().getString(headerKey);
+        assertEquals(parameter, headerValue);
+    }
+
+    @Test
+    public void shouldConvertDateHeadersToJobParams() throws Exception {
+        // Given
+        String headerKey = "headerKey";
+        Date headerValue = new Date();
+
+        // When
+        template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
+
+        // Then
+        ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
+        verify(jobLauncher).run(any(Job.class), jobParameters.capture());
+        Date parameter = jobParameters.getValue().getDate(headerKey);
+        assertEquals(parameter, headerValue);
+    }
+
+    @Test
+    public void shouldConvertLongHeadersToJobParams() throws Exception {
+        // Given
+        String headerKey = "headerKey";
+        Long headerValue = 1L;
+
+        // When
+        template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
+
+        // Then
+        ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
+        verify(jobLauncher).run(any(Job.class), jobParameters.capture());
+        Long parameter = jobParameters.getValue().getLong(headerKey);
+        assertEquals(parameter, headerValue);
+    }
+
+    @Test
+    public void shouldConvertDoubleHeadersToJobParams() throws Exception {
+        // Given
+        String headerKey = "headerKey";
+        Double headerValue = 1.0;
+
+        // When
+        template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
+
+        // Then
+        ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
+        verify(jobLauncher).run(any(Job.class), jobParameters.capture());
+        Double parameter = jobParameters.getValue().getDouble(headerKey);
+        assertEquals(parameter, headerValue);
+    }
+
+    @Test
+    public void shouldInjectJobLauncherByReferenceName() throws Exception {
+        // Given
+        context().addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:launcherRefTest").to("spring-batch:mockJob?jobLauncherRef=alternativeJobLauncher");
+            }
+        });
+
+        // When
+        template.sendBody("direct:launcherRefTest", "Start the job, please.");
+
+        // Then
+        SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobLauncherRef=alternativeJobLauncher", SpringBatchEndpoint.class);
+        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
+        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
+    }
+
+    @Test(expected = FailedToCreateRouteException.class)
+    public void shouldFailWhenThereIsNoJobLauncher() throws Exception {
+        // Given
+        SimpleRegistry registry = new SimpleRegistry();
+        registry.put("mockJob", job);
+        CamelContext camelContext = new DefaultCamelContext(registry);
+        camelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("spring-batch:mockJob");
+            }
+        });
+
+        // When
+        camelContext.start();
+    }
+
+    @Test(expected = FailedToCreateRouteException.class)
+    public void shouldFailWhenThereIsMoreThanOneJobLauncher() throws Exception {
+        // Given
+        SimpleRegistry registry = new SimpleRegistry();
+        registry.put("mockJob", job);
+        registry.put("launcher1", jobLauncher);
+        registry.put("launcher2", jobLauncher);
+        CamelContext camelContext = new DefaultCamelContext(registry);
+        camelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("spring-batch:mockJob");
+            }
+        });
+
+        // When
+        camelContext.start();
+    }
+
+    @Test
+    public void shouldResolveAnyJobLauncher() throws Exception {
+        // Given
+        SimpleRegistry registry = new SimpleRegistry();
+        registry.put("mockJob", job);
+        registry.put("someRandomName", jobLauncher);
+        CamelContext camelContext = new DefaultCamelContext(registry);
+        camelContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("spring-batch:mockJob");
+            }
+        });
+
+        // When
+        camelContext.start();
+
+        // Then
+        SpringBatchEndpoint batchEndpoint = camelContext.getEndpoint("spring-batch:mockJob", SpringBatchEndpoint.class);
+        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
+        assertSame(jobLauncher, batchEndpointJobLauncher);
+    }
+
+    @Test
+    public void shouldUseJobLauncherFromComponent() throws Exception {
+        // Given
+        SpringBatchComponent batchComponent = new SpringBatchComponent();
+        batchComponent.setJobLauncher(alternativeJobLauncher);
+        context.addComponent("customBatchComponent", batchComponent);
+
+        // When
+        context().addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:startCustom").to("customBatchComponent:mockJob");
+            }
+        });
+
+        // Then
+        SpringBatchEndpoint batchEndpoint = context().getEndpoint("customBatchComponent:mockJob", SpringBatchEndpoint.class);
+        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
+        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java (added)
+++ camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,77 @@
+/**
+ * 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.component.spring.batch;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.junit.Assert.assertTrue;
+
+public class SpringBatchIntegrationTest {
+
+    ApplicationContext applicationContext;
+
+    ProducerTemplate producerTemplate;
+
+    MockEndpoint outputEndpoint;
+
+    MockEndpoint jobExecutionEventsQueueEndpoint;
+
+    String[] inputMessages;
+
+    @Before
+    public void setUp() {
+        applicationContext = new ClassPathXmlApplicationContext("classpath:org/apache/camel/component/spring/batch/springBatchtestContext.xml");
+        producerTemplate = applicationContext.getBean(ProducerTemplate.class);
+        outputEndpoint = applicationContext.getBean(CamelContext.class).getEndpoint("mock:output", MockEndpoint.class);
+        jobExecutionEventsQueueEndpoint = applicationContext.getBean(CamelContext.class).getEndpoint("mock:jobExecutionEventsQueue", MockEndpoint.class);
+        inputMessages = new String[]{"foo", "bar", "baz"};
+
+        for (String message : inputMessages) {
+            producerTemplate.sendBody("seda:inputQueue", message);
+        }
+        producerTemplate.sendBody("seda:inputQueue", null);
+
+    }
+
+    @Test
+    public void shouldEchoInBatch() throws InterruptedException {
+        // When
+        producerTemplate.sendBody("direct:start", "Start batch!");
+
+        // Then
+        outputEndpoint.setExpectedMessageCount(inputMessages.length);
+        outputEndpoint.assertIsSatisfied();
+        assertTrue(outputEndpoint.getExchanges().get(0).getIn().getBody(String.class).startsWith("Echo "));
+    }
+
+    @Test
+    public void shouldGenerateBatchExecutionEvents() throws InterruptedException {
+        // When
+        producerTemplate.sendBody("direct:start", "Start batch!");
+
+        // Then
+        jobExecutionEventsQueueEndpoint.setExpectedMessageCount(2);
+        jobExecutionEventsQueueEndpoint.assertIsSatisfied();
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchIntegrationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java (added)
+++ camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,61 @@
+/**
+ * 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.component.spring.batch.support;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CamelItemProcessorTest extends CamelTestSupport {
+
+    // Fixtures
+
+    CamelItemProcessor<String, String> camelItemProcessor;
+
+    String message = "message";
+
+    // Camel fixtures
+
+    @Override
+    protected void doPostSetup() throws Exception {
+        camelItemProcessor = new CamelItemProcessor<String, String>(template(), "direct:start");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").setExchangePattern(ExchangePattern.InOut).
+                        setBody().simple("${body}${body}");
+            }
+        };
+    }
+
+    // Tests
+
+    @Test
+    public void shouldReturnDoubledMessage() throws Exception {
+        // When
+        String messageRead = camelItemProcessor.process(message);
+
+        // Then
+        assertEquals(message + message, messageRead);
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemProcessorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java (added)
+++ camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java Tue Jun  5 10:04:05 2012
@@ -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.component.spring.batch.support;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CamelItemReaderTest extends CamelTestSupport {
+
+    // Fixtures
+
+    CamelItemReader<String> camelItemReader;
+
+    String message = "message";
+
+    // Camel fixtures
+
+    @Override
+    protected void doPostSetup() throws Exception {
+        camelItemReader = new CamelItemReader<String>(consumer(), "seda:start");
+        sendBody("seda:start", message);
+    }
+
+    // Tests
+
+    @Test
+    public void shouldReadMessage() throws Exception {
+        // When
+        String messageRead = camelItemReader.read();
+
+        // Then
+        assertEquals(message, messageRead);
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemReaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java (added)
+++ camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,50 @@
+/**
+ * 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.component.spring.batch.support;
+
+import java.util.Collections;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class CamelItemWriterTest extends CamelTestSupport {
+
+    // Fixtures
+
+    CamelItemWriter<String> camelItemWriter;
+
+    String message = "message";
+
+    // Camel fixtures
+
+    @Override
+    protected void doPostSetup() throws Exception {
+        camelItemWriter = new CamelItemWriter<String>(template(), "seda:queue");
+    }
+
+    // Tests
+
+    @Test
+    public void shouldReadMessage() throws Exception {
+        // When
+        camelItemWriter.write(Collections.singletonList(message));
+
+        // Then
+        assertEquals(message, consumer().receiveBody("seda:queue"));
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelItemWriterTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java (added)
+++ camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java Tue Jun  5 10:04:05 2012
@@ -0,0 +1,84 @@
+/**
+ * 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.component.spring.batch.support;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.springframework.batch.core.JobExecution;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CamelJobExecutionListenerTest extends CamelTestSupport {
+
+    // Fixtures
+
+    @Mock
+    JobExecution jobExecution;
+
+    CamelJobExecutionListener jobExecutionListener;
+
+    // Camel fixtures
+
+    @Override
+    protected void doPostSetup() throws Exception {
+        jobExecutionListener = new CamelJobExecutionListener(template(), "seda:eventQueue");
+    }
+
+    // Tests
+
+    @Test
+    public void shouldSendBeforeJobEvent() throws Exception {
+        // When
+        jobExecutionListener.beforeJob(jobExecution);
+
+        // Then
+        assertEquals(jobExecution, consumer().receiveBody("seda:eventQueue"));
+    }
+
+    @Test
+    public void shouldSetBeforeJobEventHeader() throws Exception {
+        // When
+        jobExecutionListener.beforeJob(jobExecution);
+
+        // Then
+        Exchange beforeJobEvent = consumer().receive("seda:eventQueue");
+        assertEquals(CamelJobExecutionListener.EventType.BEFORE.name(), beforeJobEvent.getIn().getHeader(CamelJobExecutionListener.EventType.HEADER_KEY));
+    }
+
+    @Test
+    public void shouldSendAfterJobEvent() throws Exception {
+        // When
+        jobExecutionListener.afterJob(jobExecution);
+
+        // Then
+        assertEquals(jobExecution, consumer().receiveBody("seda:eventQueue"));
+    }
+
+    @Test
+    public void shouldSetAfterJobEventHeader() throws Exception {
+        // When
+        jobExecutionListener.afterJob(jobExecution);
+
+        // Then
+        Exchange beforeJobEvent = consumer().receive("seda:eventQueue");
+        assertEquals(CamelJobExecutionListener.EventType.AFTER.name(), beforeJobEvent.getIn().getHeader(CamelJobExecutionListener.EventType.HEADER_KEY));
+    }
+
+}

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/support/CamelJobExecutionListenerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml?rev=1346324&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml (added)
+++ camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml Tue Jun  5 10:04:05 2012
@@ -0,0 +1,94 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:batch="http://www.springframework.org/schema/batch"
+       xsi:schemaLocation="
+          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+          http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
+
+    <!-- Spring Batch task -->
+
+    <batch:job id="echoJob">
+        <batch:step id="echoStep">
+            <batch:tasklet>
+                <batch:chunk reader="camelReader" writer="camelWriter" processor="camelProcessor" commit-interval="3"/>
+            </batch:tasklet>
+        </batch:step>
+        <batch:listeners>
+            <batch:listener ref="camelJobExecutionListener"/>
+        </batch:listeners>
+    </batch:job>
+
+    <!-- Camel infrastructure -->
+
+    <camel:camelContext id="camel">
+        <camel:route>
+            <camel:from uri="direct:start"/>
+            <camel:to uri="spring-batch:echoJob"/>
+        </camel:route>
+        <camel:route>
+            <camel:from uri="direct:processor"/>
+            <camel:setExchangePattern pattern="InOut"/>
+            <camel:setBody>
+                <camel:simple>Echo ${body}</camel:simple>
+            </camel:setBody>
+        </camel:route>
+    </camel:camelContext>
+
+    <camel:consumerTemplate id="consumerTemplate" camelContextId="camel"/>
+
+    <camel:template id="template" camelContextId="camel"/>
+
+    <!-- Spring Batch infrastructure -->
+
+    <bean id="jobRepository"
+          class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
+        <property name="transactionManager" ref="transactionManager"/>
+    </bean>
+
+    <bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
+
+    <bean id="jobLauncher"
+          class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
+        <property name="jobRepository" ref="jobRepository"/>
+    </bean>
+
+    <bean id="camelReader" class="org.apache.camel.component.spring.batch.support.CamelItemReader">
+        <constructor-arg ref="consumerTemplate"/>
+        <constructor-arg value="seda:inputQueue"/>
+    </bean>
+
+    <bean id="camelWriter" class="org.apache.camel.component.spring.batch.support.CamelItemWriter">
+        <constructor-arg ref="template"/>
+        <constructor-arg value="mock:output"/>
+    </bean>
+
+    <bean id="camelProcessor" class="org.apache.camel.component.spring.batch.support.CamelItemProcessor">
+        <constructor-arg ref="template"/>
+        <constructor-arg value="direct:processor"/>
+    </bean>
+
+    <bean id="camelJobExecutionListener"
+          class="org.apache.camel.component.spring.batch.support.CamelJobExecutionListener">
+        <constructor-arg ref="template"/>
+        <constructor-arg value="mock:jobExecutionEventsQueue"/>
+    </bean>
+
+</beans>
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring-batch/src/test/resources/org/apache/camel/component/spring/batch/springBatchtestContext.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=1346324&r1=1346323&r2=1346324&view=diff
==============================================================================
--- camel/trunk/components/pom.xml (original)
+++ camel/trunk/components/pom.xml Tue Jun  5 10:04:05 2012
@@ -138,6 +138,7 @@
     <module>camel-snmp</module>
     <module>camel-soap</module>
     <module>camel-solr</module>
+    <module>camel-spring-batch</module>
     <module>camel-spring-javaconfig</module>
     <module>camel-spring-integration</module>
     <module>camel-spring-security</module>
@@ -171,5 +172,5 @@
             </modules>
         </profile>
   </profiles>
-  
+
 </project>

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1346324&r1=1346323&r2=1346324&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Tue Jun  5 10:04:05 2012
@@ -165,6 +165,7 @@
     <snappy-bundle-version>1.0.4.1_1</snappy-bundle-version>
     <snmp4j-version>1.10.1_1</snmp4j-version>
     <solr-version>3.6.0</solr-version>
+    <spring-batch-version>2.1.8.RELEASE</spring-batch-version>
     <spring-integration-version>2.1.1.RELEASE</spring-integration-version>
     <spring-javaconfig-version>1.0.0-20090215</spring-javaconfig-version>
     <spring-version>3.0.7.RELEASE</spring-version>