diff --git a/spring-batch-core/.settings/com.springsource.sts.config.flow.prefs b/spring-batch-core/.settings/com.springsource.sts.config.flow.prefs index b0ce728e1..b9cbc174d 100644 --- a/spring-batch-core/.settings/com.springsource.sts.config.flow.prefs +++ b/spring-batch-core/.settings/com.springsource.sts.config.flow.prefs @@ -1,8 +1,9 @@ -#Mon Jan 31 13:34:48 GMT 2011 +#Tue Feb 01 21:15:00 GMT 2011 //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobExecutionListenerMethodAttributeParserTests-context.xml=\n\n\n\n\n\n //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobRepositoryDefaultParserTests-context.xml=\n //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerInStepParserTests-context.xml=\n\n\n\n\n\n //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerMethodAttributeParserTests-context.xml=\n\n\n\n\n\n +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerParserTests-context.xml=\n\n\n\n\n\n //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepWithPojoListenerJobParserTests-context.xml=\n\n\n\n\n\n //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletParserAdapterTests-context.xml=\n\n\n\n\n\n\n\n\n\n //com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletParserBeanPropertiesTests-context.xml=\n\n\n\n\n\n\n\n\n\n diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepListenerParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepListenerParserTests.java index 57db07e06..8297bed5b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepListenerParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepListenerParserTests.java @@ -27,6 +27,7 @@ import org.springframework.aop.framework.Advised; import org.springframework.batch.core.Step; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.listener.CompositeStepExecutionListener; +import org.springframework.batch.core.listener.ItemListenerSupport; import org.springframework.batch.core.listener.StepExecutionListenerSupport; import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.beans.factory.annotation.Autowired; @@ -51,6 +52,10 @@ public class StepListenerParserTests { @Qualifier("s2") private Step step2; + @Autowired + @Qualifier("s3") + private Step step3; + @Test public void testInheritListeners() throws Exception { @@ -96,6 +101,26 @@ public class StepListenerParserTests { assertTrue(b); } + @Test + public void testInheritListenersNoMergeFaultTolerant() throws Exception { + + List list = getListeners(step3); + + assertEquals(2, list.size()); + boolean a = false; + boolean b = false; + for (Object listener : list) { + if (listener instanceof DummyAnnotationStepExecutionListener) { + a = true; + } + else if (listener instanceof ItemListenerSupport) { + b = true; + } + } + assertTrue(a); + assertTrue(b); + } + @SuppressWarnings("unchecked") private List getListeners(Step step) throws Exception { assertTrue(step instanceof TaskletStep); @@ -111,6 +136,32 @@ public class StepListenerParserTests { } r.add(listener); } + compositeListener = ReflectionTestUtils.getField(step, "chunkListener"); + composite = ReflectionTestUtils.getField(compositeListener, "listeners"); + proxiedListeners = (List) ReflectionTestUtils.getField(composite, "list"); + for (Object listener : proxiedListeners) { + while (listener instanceof Advised) { + listener = ((Advised) listener).getTargetSource().getTarget(); + } + r.add(listener); + } + try { + compositeListener = ReflectionTestUtils.getField( + ReflectionTestUtils.getField(ReflectionTestUtils.getField( + ReflectionTestUtils.getField(step, "tasklet"), "chunkProvider"), "listener"), + "itemReadListener"); + composite = ReflectionTestUtils.getField(compositeListener, "listeners"); + proxiedListeners = (List) ReflectionTestUtils.getField(composite, "list"); + for (Object listener : proxiedListeners) { + while (listener instanceof Advised) { + listener = ((Advised) listener).getTargetSource().getTarget(); + } + r.add(listener); + } + } + catch (IllegalArgumentException e) { + // ignore (not a chunk oriented step) + } return r; } diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerParserTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerParserTests-context.xml index 4dc934cd1..7896a9e0d 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerParserTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepListenerParserTests-context.xml @@ -5,43 +5,61 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + - + - + - + - +