BATCH-1004: parser now uses the step name for bean references to step bean definitions

This commit is contained in:
trisberg
2009-01-27 02:20:06 +00:00
parent c5da264dae
commit e68d9a246a
3 changed files with 601 additions and 568 deletions

View File

@@ -15,13 +15,14 @@
*/
package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Map;
import org.junit.Test;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean;
import org.springframework.batch.core.step.tasklet.TaskletStep;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
@@ -45,6 +46,16 @@ public class StepParserTests {
TaskletStep bean = (TaskletStep) factory.getObject();
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
}
@SuppressWarnings("unchecked")
@Test
public void testStepParserBeanName() throws Exception {
ConfigurableApplicationContext ctx =
new ClassPathXmlApplicationContext("org/springframework/batch/core/configuration/xml/StepParserBeanNameTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
assertTrue("'step1' bean not found", beans.containsKey("step1"));
assertTrue("'step2' bean not found", beans.containsKey("step2"));
}
@Test
public void testTaskletStepWithBadStepListener() throws Exception {

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<job id="job">
<step name="step1" next="step2">
<tasklet reader="reader" writer="writer" commit-interval="10"/>
</step>
<step name="step2" tasklet="tasklet"/>
</job>
<beans:bean id="tasklet" class="org.springframework.batch.core.configuration.xml.TestTasklet"/>
<beans:bean id="reader" class="org.springframework.batch.core.configuration.xml.TestReader"/>
<beans:bean id="writer" class="org.springframework.batch.core.configuration.xml.TestWriter"/>
<beans:bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<beans:bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<beans:property name="transactionManager" ref="transactionManager" />
</beans:bean>
</beans:beans>