diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fd66b81
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+*.sw?
+.#*
+*#
+*~
+.classpath
+.project
+.settings
+bin
+build
+target
+dependency-reduced-pom.xml
+*.sublime-*
+/scratch
+.gradle
+.idea
+*.iml
+README.html
diff --git a/pom.xml b/pom.xml
index f494f99..9f9a308 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,32 @@
+
+
+
+ maven-compiler-plugin
+
+ 1.7
+ 1.7
+
+
+
+
+
+
+ spring-snapshots
+ http://repo.spring.io/libs-snapshot
+ true
+
+
+
+
+
+ spring-snapshots
+ http://repo.spring.io/libs-snapshot
+ true
+
+
\ No newline at end of file
diff --git a/src/test/java/org/example/SingletonScopedCompositeItemProcessorTest.java b/src/test/java/org/example/SingletonScopedCompositeItemProcessorTest.java
new file mode 100644
index 0000000..734ca31
--- /dev/null
+++ b/src/test/java/org/example/SingletonScopedCompositeItemProcessorTest.java
@@ -0,0 +1,108 @@
+package org.example;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.batch.core.ExitStatus;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.Step;
+import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
+import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
+import org.springframework.batch.item.ItemProcessor;
+import org.springframework.batch.item.ItemReader;
+import org.springframework.batch.item.ItemWriter;
+import org.springframework.batch.item.support.CompositeItemProcessor;
+import org.springframework.batch.test.JobLauncherTestUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@ContextConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+public class SingletonScopedCompositeItemProcessorTest {
+ @Configuration
+ @EnableBatchProcessing
+ static class TestConfig {
+ @Autowired
+ private JobBuilderFactory jobBuilder;
+ @Autowired
+ private StepBuilderFactory stepBuilder;
+
+ @Bean
+ JobLauncherTestUtils jobLauncherTestUtils() {
+ return new JobLauncherTestUtils();
+ }
+
+ @Bean
+ public DataSource dataSource() {
+ EmbeddedDatabaseBuilder embeddedDatabaseBuilder = new EmbeddedDatabaseBuilder();
+ return embeddedDatabaseBuilder.addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql")
+ .addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql")
+ .setType(EmbeddedDatabaseType.HSQL)
+ .build();
+ }
+
+ @Bean
+ public Job jobUnderTest() {
+ return jobBuilder.get("job-under-test")
+ .start(stepUnderTest())
+ .build();
+ }
+
+ @Bean
+ public Step stepUnderTest() {
+ return stepBuilder.get("step-under-test")
+ .chunk(1)
+ .reader(reader())
+ .processor(compositeProcessor())
+ .writer(writer())
+ .build();
+ }
+
+ @Bean
+ public ItemReader reader() {
+ return new StatefulItemReader();
+ }
+
+ @Bean
+ public ItemProcessor compositeProcessor() {
+ CompositeItemProcessor cip = new CompositeItemProcessor();
+ List> itemProcessors = new ArrayList>();
+ itemProcessors.add(processor());
+ itemProcessors.add(processor());
+ cip.setDelegates(itemProcessors);
+ return cip;
+ }
+
+ @Bean
+ public ItemProcessor processor() {
+ return new StatefulItemProcessor();
+ }
+
+ @Bean
+ public ItemWriter writer() {
+ return new StatefulItemWriter();
+ }
+ }
+
+ @Autowired
+ JobLauncherTestUtils jobLauncherTestUtils;
+
+ @Test
+ public void testStepExecution() {
+ JobExecution jobExecution = jobLauncherTestUtils.launchStep("step-under-test");
+ assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
+ }
+}