diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java
index 1c053e714..187fa215c 100644
--- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java
+++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/StepParser.java
@@ -201,14 +201,20 @@ public class StepParser {
String readerBeanId = element.getAttribute("reader");
if (StringUtils.hasText(readerBeanId)) {
- RuntimeBeanReference taskletRef = new RuntimeBeanReference(readerBeanId);
- bd.getPropertyValues().addPropertyValue("itemReader", taskletRef);
+ RuntimeBeanReference readerRef = new RuntimeBeanReference(readerBeanId);
+ bd.getPropertyValues().addPropertyValue("itemReader", readerRef);
+ }
+
+ String processorBeanId = element.getAttribute("processor");
+ if (StringUtils.hasText(processorBeanId)) {
+ RuntimeBeanReference processorRef = new RuntimeBeanReference(processorBeanId);
+ bd.getPropertyValues().addPropertyValue("itemProcessor", processorRef);
}
String writerBeanId = element.getAttribute("writer");
if (StringUtils.hasText(writerBeanId)) {
- RuntimeBeanReference taskletRef = new RuntimeBeanReference(writerBeanId);
- bd.getPropertyValues().addPropertyValue("itemWriter", taskletRef);
+ RuntimeBeanReference writerRef = new RuntimeBeanReference(writerBeanId);
+ bd.getPropertyValues().addPropertyValue("itemWriter", writerRef);
}
String jobRepository = element.getAttribute("job-repository");
diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
index 3d5bb49c1..51b5dc4b5 100644
--- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
+++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd
@@ -171,7 +171,7 @@
-
+
@@ -212,7 +212,7 @@
-
+
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractTestComponent.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractTestComponent.java
new file mode 100644
index 000000000..539d081aa
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractTestComponent.java
@@ -0,0 +1,15 @@
+package org.springframework.batch.core.configuration.xml;
+
+public class AbstractTestComponent {
+
+ protected boolean executed = false;
+
+ public AbstractTestComponent() {
+ super();
+ }
+
+ public boolean isExecuted() {
+ return executed;
+ }
+
+}
\ No newline at end of file
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithChunkOrientedJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithChunkOrientedJobParserTests.java
new file mode 100644
index 000000000..ffa669af7
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithChunkOrientedJobParserTests.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2006-2007 the original author or authors.
+ *
+ * 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.
+ */
+package org.springframework.batch.core.configuration.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.batch.core.BatchStatus;
+import org.springframework.batch.core.Job;
+import org.springframework.batch.core.JobExecution;
+import org.springframework.batch.core.JobParameters;
+import org.springframework.batch.core.repository.JobRepository;
+import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+
+/**
+ * @author Thomas Risberg
+ *
+ */
+@ContextConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+public class StepWithChunkOrientedJobParserTests {
+
+ @Autowired
+ private Job job;
+
+ @Autowired
+ private JobRepository jobRepository;
+
+ @Autowired
+ private TestReader reader;
+
+ @Autowired
+ private TestProcessor processor;
+
+ @Autowired
+ private TestWriter writer;
+
+ @Before
+ public void setUp() {
+ MapJobRepositoryFactoryBean.clear();
+ }
+
+ @Test
+ public void testStepWithTask() throws Exception {
+ assertNotNull(job);
+ JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
+ job.execute(jobExecution);
+ assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
+ assertEquals(1, jobExecution.getStepExecutions().size());
+ assertTrue(reader.isExecuted());
+ assertTrue(processor.isExecuted());
+ assertTrue(writer.isExecuted());
+ }
+}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests.java
index 1bb07f7e4..405d89437 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests.java
@@ -17,6 +17,7 @@ package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@@ -33,7 +34,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
- * @author Dave Syer
+ * @author Thomas Risberg
*
*/
@ContextConfiguration
@@ -46,6 +47,9 @@ public class StepWithTaskJobParserTests {
@Autowired
private JobRepository jobRepository;
+ @Autowired
+ private AbstractTestComponent tasklet;
+
@Before
public void setUp() {
MapJobRepositoryFactoryBean.clear();
@@ -57,6 +61,7 @@ public class StepWithTaskJobParserTests {
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
job.execute(jobExecution);
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
- assertEquals(3, jobExecution.getStepExecutions().size());
+ assertEquals(2, jobExecution.getStepExecutions().size());
+ assertTrue(tasklet.isExecuted());
}
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java
new file mode 100644
index 000000000..61f6ba641
--- /dev/null
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java
@@ -0,0 +1,12 @@
+package org.springframework.batch.core.configuration.xml;
+
+import org.springframework.batch.item.ItemProcessor;
+
+public class TestProcessor extends AbstractTestComponent implements ItemProcessor{
+
+ public String process(String item) throws Exception {
+ executed = true;
+ return item;
+ }
+
+}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java
index ae27884e3..ca3b8ad72 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java
@@ -8,7 +8,7 @@ import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
-public class TestReader implements ItemReader {
+public class TestReader extends AbstractTestComponent implements ItemReader {
List items = null;
@@ -21,6 +21,7 @@ public class TestReader implements ItemReader {
public String read() throws Exception, UnexpectedInputException,
ParseException {
+ executed = true;
if (items.size() > 0) {
String item = items.remove(0);
return item;
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java
similarity index 81%
rename from spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java
rename to spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java
index abeb34114..41ba9c50c 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java
@@ -5,10 +5,11 @@ import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.core.AttributeAccessor;
-public class DummyTasklet implements Tasklet {
+public class TestTasklet extends AbstractTestComponent implements Tasklet {
public ExitStatus execute(StepContribution contribution,
AttributeAccessor attributes) throws Exception {
+ executed = true;
return ExitStatus.FINISHED;
}
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java
index c0946f70f..7c13f96db 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestWriter.java
@@ -4,9 +4,10 @@ import java.util.List;
import org.springframework.batch.item.ItemWriter;
-public class TestWriter implements ItemWriter {
+public class TestWriter extends AbstractTestComponent implements ItemWriter {
public void write(List extends String> items) throws Exception {
+ executed = true;
}
}
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithChunkOrientedJobParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithChunkOrientedJobParserTests-context.xml
new file mode 100644
index 000000000..d47c41207
--- /dev/null
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithChunkOrientedJobParserTests-context.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests-context.xml
index 2826dd54b..d673a038f 100644
--- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests-context.xml
+++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithTaskJobParserTests-context.xml
@@ -11,18 +11,11 @@
-
+
-
-
-
-
-
-
-
-
+
\ No newline at end of file