diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java index b0529abc9..e8ef63dfd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBean.java @@ -29,7 +29,6 @@ import org.springframework.batch.core.job.flow.FlowStep; import org.springframework.batch.core.partition.PartitionHandler; import org.springframework.batch.core.partition.support.PartitionStep; import org.springframework.batch.core.partition.support.Partitioner; -import org.springframework.batch.core.partition.support.SimplePartitioner; import org.springframework.batch.core.partition.support.SimpleStepExecutionSplitter; import org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler; import org.springframework.batch.core.repository.JobRepository; @@ -248,8 +247,7 @@ class StepParserStepFactoryBean implements FactoryBean, BeanNameAware { partitionHandler.setTaskExecutor(taskExecutor); ts.setPartitionHandler(partitionHandler); } - SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, step, - new SimplePartitioner()); + SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, step, partitioner); ts.setStepExecutionSplitter(splitter); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java index 76e6cb210..87233b6fc 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserStepFactoryBeanTests.java @@ -24,7 +24,11 @@ import java.util.HashMap; import org.junit.Test; import org.springframework.batch.core.StepListener; import org.springframework.batch.core.listener.StepExecutionListenerSupport; +import org.springframework.batch.core.partition.support.PartitionStep; +import org.springframework.batch.core.partition.support.SimplePartitioner; +import org.springframework.batch.core.partition.support.TaskExecutorPartitionHandler; import org.springframework.batch.core.step.JobRepositorySupport; +import org.springframework.batch.core.step.StepSupport; import org.springframework.batch.core.step.item.ChunkOrientedTasklet; import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.item.ItemStream; @@ -215,4 +219,24 @@ public class StepParserStepFactoryBeanTests { assertTrue(tasklet instanceof ChunkOrientedTasklet); } + @Test + public void testPartitionStep() throws Exception { + StepParserStepFactoryBean fb = new StepParserStepFactoryBean(); + fb.setBeanName("step1"); + fb.setAllowStartIfComplete(true); + fb.setJobRepository(new JobRepositorySupport()); + fb.setStartLimit(5); + fb.setListeners(new StepListener[] { new StepExecutionListenerSupport() }); + fb.setTaskExecutor(new SyncTaskExecutor()); + + SimplePartitioner partitioner = new SimplePartitioner(); + fb.setPartitioner(partitioner); + fb.setStep(new StepSupport("foo")); + + Object step = fb.getObject(); + assertTrue(step instanceof PartitionStep); + Object handler = ReflectionTestUtils.getField(step, "partitionHandler"); + assertTrue(handler instanceof TaskExecutorPartitionHandler); + } + }