BATCH-1213: Added test to ensure that if a <step/> with a <tasklet/> will always be a StepParserStepFactoryBean, even if its parent has a different class declared.

This commit is contained in:
dhgarrette
2009-05-22 00:41:13 +00:00
parent 232f2a0644
commit ded9ede29e
2 changed files with 26 additions and 13 deletions

View File

@@ -52,6 +52,9 @@ import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
*/
public class StepParserTests {
private static final ApplicationContext stepParserParentAttributeTestsCtx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
@SuppressWarnings("unchecked")
@Test
public void testTaskletStepAttributes() throws Exception {
@@ -134,8 +137,7 @@ public class StepParserTests {
@Test
public void testParentStep() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
// Inline Step
assertTrue(getListener("s1", ctx) instanceof StepExecutionListenerSupport);
@@ -152,8 +154,7 @@ public class StepParserTests {
@Test
public void testInheritTransactionAttributes() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
// On Inline - No Merge
validateTransactionAttributesInherited("s1", ctx);
@@ -215,8 +216,7 @@ public class StepParserTests {
@Test
public void testInheritFromBean() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
assertTrue(getTasklet("s9", ctx) instanceof DummyTasklet);
assertTrue(getTasklet("s10", ctx) instanceof DummyTasklet);
@@ -233,8 +233,7 @@ public class StepParserTests {
@Test
public void testJobRepositoryDefaults() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
assertTrue(getJobRepository("defaultRepoStep", ctx) instanceof SimpleJobRepository);
@@ -261,8 +260,7 @@ public class StepParserTests {
@Test
public void testTransactionManagerDefaults() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
assertTrue(getTransactionManager("defaultTxMgrStep", ctx) instanceof ResourcelessTransactionManager);
@@ -311,11 +309,23 @@ public class StepParserTests {
@Test
public void testNonAbstractStep() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
assertTrue(ctx.containsBean("s11"));
Object bean = ctx.getBean("s11");
assertTrue(bean instanceof DummyStep);
}
@Test
public void testTaskletElementOverridesParentBeanClass() {
ApplicationContext ctx = stepParserParentAttributeTestsCtx;
assertTrue(ctx.containsBean("&s12"));
Object factoryBean = ctx.getBean("&s12");
assertTrue(factoryBean instanceof StepParserStepFactoryBean);
assertTrue(ctx.containsBean("s12"));
Object bean = ctx.getBean("s12");
assertTrue(bean instanceof TaskletStep);
}
}

View File

@@ -35,7 +35,10 @@
<step id="s8" parent="standalone8" next="s9" />
<step id="s9" parent="standalone9" next="s10" />
<step id="s10" parent="standalone10" next="s11"/>
<step id="s11" parent="dummyStep" />
<step id="s11" parent="dummyStep"/>
<step id="s12" parent="dummyStep">
<tasklet ref="dummyTasklet"/>
</step>
</job>
<step id="standalone2" parent="baseStep">