From 0cc77cf6ca32ea44dc0afc8a256ed62ce4d14e4f Mon Sep 17 00:00:00 2001 From: dsyer Date: Fri, 4 Sep 2009 12:26:41 +0000 Subject: [PATCH] OPEN - issue BATCH-1392: Throttle limit is not parsed in ChunkElementParser Fixed in 2.1 --- .../configuration/xml/AbstractStepParser.java | 4 ++++ .../configuration/xml/spring-batch-2.1.xsd | 18 +++++++++--------- .../xml/StepParserStepFactoryBeanTests.java | 8 ++++++-- .../configuration/xml/StepParserTests.java | 2 ++ ...tepParserTaskletAttributesTests-context.xml | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java index 8d32d1f0b..49d1c5625 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/AbstractStepParser.java @@ -243,6 +243,10 @@ public abstract class AbstractStepParser { RuntimeBeanReference taskExecutorRef = new RuntimeBeanReference(taskExecutorBeanId); propertyValues.addPropertyValue("taskExecutor", taskExecutorRef); } + String throttleLimit = taskletElement.getAttribute("throttle-limit"); + if (StringUtils.hasText(throttleLimit)) { + propertyValues.addPropertyValue("throttleLimit", throttleLimit); + } } @SuppressWarnings("unchecked") diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd index 563290991..0d30980fc 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd @@ -352,6 +352,15 @@ + + + + + @@ -585,15 +594,6 @@ ]]> - - - - - fb = new StepParserStepFactoryBean(); fb.setBeanName("step1"); fb.setAllowStartIfComplete(true); @@ -202,13 +202,17 @@ public class StepParserStepFactoryBeanTests { fb.setIsReaderTransactionalQueue(true); fb.setRetryLimit(5); fb.setSkipLimit(100); + fb.setThrottleLimit(10); fb.setRetryListeners(new RetryListenerSupport()); fb.setSkippableExceptionClasses(new HashMap, Boolean>()); fb.setRetryableExceptionClasses(new HashMap, Boolean>()); Object step = fb.getObject(); assertTrue(step instanceof TaskletStep); + Object throttleLimit = ReflectionTestUtils.getField(ReflectionTestUtils.getField(step, "stepOperations"), "throttleLimit"); + assertEquals(new Integer(10), throttleLimit); Object tasklet = ReflectionTestUtils.getField(step, "tasklet"); assertTrue(tasklet instanceof ChunkOrientedTasklet); } + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java index 925258561..f109f955d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StepParserTests.java @@ -88,6 +88,8 @@ public class StepParserTests { StepParserStepFactoryBean factory = beans.get(factoryName); TaskletStep bean = (TaskletStep) factory.getObject(); assertEquals("wrong start-limit:", 25, bean.getStartLimit()); + Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit"); + assertEquals(new Integer(10), throttleLimit); } @Test diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml index 7a8b4c1cb..0c77af0a7 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml @@ -6,7 +6,7 @@ - +