From 4433e2bd198f28c850a1b61b8c12160ccb81d8cb Mon Sep 17 00:00:00 2001 From: Will Schipp Date: Wed, 16 Jan 2013 21:07:48 -0500 Subject: [PATCH 1/7] BATCH-1745 - added new spring-batch-2.2.xsd and schema pointers including new attributeGroup for "allow-start-if-complete" flag and appropriate parsers. --- .../configuration/xml/AbstractStepParser.java | 9 + .../main/resources/META-INF/spring.schemas | 3 +- .../configuration/xml/spring-batch-2.2.xsd | 1328 +++++++++++++++++ 3 files changed, 1339 insertions(+), 1 deletion(-) create mode 100644 spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd 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 5a0f0cfac..5f53e4425 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 @@ -52,6 +52,8 @@ public abstract class AbstractStepParser { private static final String PARENT_ATTR = "parent"; private static final String REF_ATTR = "ref"; + + private static final String ALLOW_START_ATTR = "allow-start-if-complete"; private static final String TASKLET_ELE = "tasklet"; @@ -176,6 +178,13 @@ public abstract class AbstractStepParser { bd.setAttribute("jobParserJobFactoryBeanRef", jobFactoryRef); } + //add the allow parser here + String isAllowStart = stepElement.getAttribute(ALLOW_START_ATTR); + if (StringUtils.hasText(isAllowStart)) { + //set the value as a property + bd.getPropertyValues().add("allowStartIfComplete", Boolean.valueOf(isAllowStart)); + } + stepListenerParser.handleListenersElement(stepElement, bd, parserContext); return bd; } diff --git a/spring-batch-core/src/main/resources/META-INF/spring.schemas b/spring-batch-core/src/main/resources/META-INF/spring.schemas index df18c6979..a75ad5775 100644 --- a/spring-batch-core/src/main/resources/META-INF/spring.schemas +++ b/spring-batch-core/src/main/resources/META-INF/spring.schemas @@ -1,3 +1,4 @@ -http\://www.springframework.org/schema/batch/spring-batch.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd +http\://www.springframework.org/schema/batch/spring-batch.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd +http\://www.springframework.org/schema/batch/spring-batch-2.2.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd http\://www.springframework.org/schema/batch/spring-batch-2.1.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd http\://www.springframework.org/schema/batch/spring-batch-2.0.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd new file mode 100644 index 000000000..d50f6fdc8 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd @@ -0,0 +1,1328 @@ + + + + + + + + + + + + + + Defines a job composed of a set of steps and + transitions between steps. The job will be exposed in + the enclosing + bean factory as a component of type Job + that can be launched using a + JobLauncher. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines a stage in job processing backed by a + Step. The id attribute must be specified since this + step definition + will be referred to from other elements + to form a Job flow. + + + + + + + + + + + + + + + + + Defines a flow composed of a set of steps and + transitions between steps. + + + + + + + + + + + + + + + + + + A reference to a JobExecutionListener (or a POJO + if using before-job-method / after-job-method or + source level + annotations). + + + + + + + + + + + + + + + A bean definition for a step listener (or POJO if + using *-method attributes or source level + annotations) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines a stage in job processing backed by a + Step. The id attribute must be specified. The + step + requires either + a chunk definition, + a tasklet reference, or a reference to a + (possibly abstract) parent step. + + + + + + + + + + + + + + + + Declares job should split here into two or more + subflows. + + + + + + + + A subflow within a job, having the same + format as a job, but without a separate identity. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Declares job should include an externalized flow + here. + + + + + + + + + + + + + + + + + + + + + + Declares job should query a decider to determine + where execution should go next. + + + + + + + + + The decider is a reference to a + JobExecutionDecider that can produce a status to base + the next + transition on. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The tasklet is a reference to another bean + definition that implements + the Tasklet interface. + + + + + + + + + + If the tasklet is specified as a bean definition, then a method can be specified and a POJO + will + be adapted to the Tasklet interface. The method suggested should have the same arguments + as Tasklet.execute (or a subset), and have a compatible return type (boolean, void or RepeatStatus). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An exception class name. + + + + + + + + + + + + + + + + + Classify an exception as "included" in the set. Exceptions of this type or a subclass are + included. + + + + + + + + + + + + + + + + Classify an exception as "excluded" from the + set. Exceptions of this type or a subclass are + excluded + + + + + + + + + + + + + + + A reference to a listener, a POJO with a + listener-annotated method, or a POJO with + a method + referenced by a + *-method attribute. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines a transition from this step to the + next + one depending on the value of the exit + status. + + + + + + A pattern to match against the exit status + code. Use * and ? as wildcard characters. When a + step finishes + the most + specific match will be chosen to select the next step. + Hint: + always include a default + transition with on="*". + + + + + + + The name of the step to go to next. Must + resolve to one of the other steps in this job. + + + + + + + + + Declares job should be stop at this point and + provides pointer where execution should continue + when + the job is + restarted. + + + + + + A pattern to match against the exit status + code. Use * and ? as wildcard characters. + When a step + finishes + the most specific match will be chosen to + select the next step. + + + + + + The name of the step to start on when the + stopped job is restarted. + Must resolve to one of the + other steps + in this job. + + + + + + + + + Declares job should end at this point, without + the possibility of restart. + BatchStatus will be + COMPLETED. + ExitStatus is configurable. + + + + + + A pattern to match against the exit status + code. Use * and ? as wildcard characters. + When a step + finishes + the most specific match will be chosen to + select the next step. + + + + + + The exit code value to end on, defaults to + COMPLETED. + + + + + + + + Declares job should fail at this point. + BatchStatus will be FAILED. ExitStatus is configurable. + + + + + + A pattern to match against the exit status + code. Use * and ? as wildcard characters. + When a step + finishes + the most specific match will be chosen to + select the next step. + + + + + + The exit code value to end on, defaults to + FAILED. + + + + + + + + + + + + + + + + + + + + + + + + + The name of the parent bean from which the + configuration should inherit. + + + + + + + + + + + + + Is this bean "abstract", that is, not meant to be + instantiated itself + but rather just serving as + parent for concrete + child bean definitions? + The default is "false". Specify "true" to + tell the bean factory to not + try + to instantiate that particular bean + in any case. + + Note: This attribute will not be inherited by child + bean definitions. + Hence, it needs to be specified per abstract bean + definition. + + + + + + + + + + Should this list be merged with the corresponding + list provided + by the parent? If not, it will + overwrite the parent + list. + + + + + + + + + + This attribute indicates the method from the + class that should + be used to dynamically create a + proxy. + + + + + + + + + + + + + From 85c1d06a7d8c9fe11210d115a04e410104915c6e Mon Sep 17 00:00:00 2001 From: Will Schipp Date: Wed, 16 Jan 2013 21:35:13 -0500 Subject: [PATCH 2/7] BATCH-1745 - removed excessive schema, added test and cleaned up schema mappings --- .../main/resources/META-INF/spring.schemas | 3 +- .../configuration/xml/spring-batch-2.1.xsd | 19 +- .../configuration/xml/spring-batch-2.2.xsd | 1328 ----------------- .../xml/AbstractStepParserTest.java | 28 + .../xml/AbstractStepParserTest-context.xml | 33 + 5 files changed, 74 insertions(+), 1337 deletions(-) delete mode 100644 spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd create mode 100644 spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java create mode 100644 spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/AbstractStepParserTest-context.xml diff --git a/spring-batch-core/src/main/resources/META-INF/spring.schemas b/spring-batch-core/src/main/resources/META-INF/spring.schemas index a75ad5775..df18c6979 100644 --- a/spring-batch-core/src/main/resources/META-INF/spring.schemas +++ b/spring-batch-core/src/main/resources/META-INF/spring.schemas @@ -1,4 +1,3 @@ -http\://www.springframework.org/schema/batch/spring-batch.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd -http\://www.springframework.org/schema/batch/spring-batch-2.2.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd +http\://www.springframework.org/schema/batch/spring-batch.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd http\://www.springframework.org/schema/batch/spring-batch-2.1.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.1.xsd http\://www.springframework.org/schema/batch/spring-batch-2.0.xsd=/org/springframework/batch/core/configuration/xml/spring-batch-2.0.xsd \ No newline at end of file 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 5bff17301..bb58e2cbb 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 @@ -286,6 +286,7 @@ ref" is not required, and only needs to be specified explicitly + @@ -623,13 +624,6 @@ ref" is not required, and only needs to be specified explicitly ]]> - - - - - + @@ -985,6 +980,16 @@ ref" is not required, and only needs to be specified explicitly + + + + + + + + diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd b/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd deleted file mode 100644 index d50f6fdc8..000000000 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/configuration/xml/spring-batch-2.2.xsd +++ /dev/null @@ -1,1328 +0,0 @@ - - - - - - - - - - - - - - Defines a job composed of a set of steps and - transitions between steps. The job will be exposed in - the enclosing - bean factory as a component of type Job - that can be launched using a - JobLauncher. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Defines a stage in job processing backed by a - Step. The id attribute must be specified since this - step definition - will be referred to from other elements - to form a Job flow. - - - - - - - - - - - - - - - - - Defines a flow composed of a set of steps and - transitions between steps. - - - - - - - - - - - - - - - - - - A reference to a JobExecutionListener (or a POJO - if using before-job-method / after-job-method or - source level - annotations). - - - - - - - - - - - - - - - A bean definition for a step listener (or POJO if - using *-method attributes or source level - annotations) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Defines a stage in job processing backed by a - Step. The id attribute must be specified. The - step - requires either - a chunk definition, - a tasklet reference, or a reference to a - (possibly abstract) parent step. - - - - - - - - - - - - - - - - Declares job should split here into two or more - subflows. - - - - - - - - A subflow within a job, having the same - format as a job, but without a separate identity. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Declares job should include an externalized flow - here. - - - - - - - - - - - - - - - - - - - - - - Declares job should query a decider to determine - where execution should go next. - - - - - - - - - The decider is a reference to a - JobExecutionDecider that can produce a status to base - the next - transition on. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The tasklet is a reference to another bean - definition that implements - the Tasklet interface. - - - - - - - - - - If the tasklet is specified as a bean definition, then a method can be specified and a POJO - will - be adapted to the Tasklet interface. The method suggested should have the same arguments - as Tasklet.execute (or a subset), and have a compatible return type (boolean, void or RepeatStatus). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - An exception class name. - - - - - - - - - - - - - - - - - Classify an exception as "included" in the set. Exceptions of this type or a subclass are - included. - - - - - - - - - - - - - - - - Classify an exception as "excluded" from the - set. Exceptions of this type or a subclass are - excluded - - - - - - - - - - - - - - - A reference to a listener, a POJO with a - listener-annotated method, or a POJO with - a method - referenced by a - *-method attribute. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Defines a transition from this step to the - next - one depending on the value of the exit - status. - - - - - - A pattern to match against the exit status - code. Use * and ? as wildcard characters. When a - step finishes - the most - specific match will be chosen to select the next step. - Hint: - always include a default - transition with on="*". - - - - - - - The name of the step to go to next. Must - resolve to one of the other steps in this job. - - - - - - - - - Declares job should be stop at this point and - provides pointer where execution should continue - when - the job is - restarted. - - - - - - A pattern to match against the exit status - code. Use * and ? as wildcard characters. - When a step - finishes - the most specific match will be chosen to - select the next step. - - - - - - The name of the step to start on when the - stopped job is restarted. - Must resolve to one of the - other steps - in this job. - - - - - - - - - Declares job should end at this point, without - the possibility of restart. - BatchStatus will be - COMPLETED. - ExitStatus is configurable. - - - - - - A pattern to match against the exit status - code. Use * and ? as wildcard characters. - When a step - finishes - the most specific match will be chosen to - select the next step. - - - - - - The exit code value to end on, defaults to - COMPLETED. - - - - - - - - Declares job should fail at this point. - BatchStatus will be FAILED. ExitStatus is configurable. - - - - - - A pattern to match against the exit status - code. Use * and ? as wildcard characters. - When a step - finishes - the most specific match will be chosen to - select the next step. - - - - - - The exit code value to end on, defaults to - FAILED. - - - - - - - - - - - - - - - - - - - - - - - - - The name of the parent bean from which the - configuration should inherit. - - - - - - - - - - - - - Is this bean "abstract", that is, not meant to be - instantiated itself - but rather just serving as - parent for concrete - child bean definitions? - The default is "false". Specify "true" to - tell the bean factory to not - try - to instantiate that particular bean - in any case. - - Note: This attribute will not be inherited by child - bean definitions. - Hence, it needs to be specified per abstract bean - definition. - - - - - - - - - - Should this list be merged with the corresponding - list provided - by the parent? If not, it will - overwrite the parent - list. - - - - - - - - - - This attribute indicates the method from the - class that should - be used to dynamically create a - proxy. - - - - - - - - - - - - - diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java new file mode 100644 index 000000000..f5381cc3b --- /dev/null +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java @@ -0,0 +1,28 @@ +package org.springframework.batch.core.configuration.xml; + +import static org.junit.Assert.assertTrue; + +import javax.annotation.Resource; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.batch.core.step.AbstractStep; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +public class AbstractStepParserTest { + + @Resource + private ApplicationContext context; + + @Test + public void test() throws Exception { + //retrieve the step from the context and see that it's allow is set + AbstractStep abstractStep = context.getBean(AbstractStep.class); + assertTrue(abstractStep.isAllowStartIfComplete()); + } + +} diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/AbstractStepParserTest-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/AbstractStepParserTest-context.xml new file mode 100644 index 000000000..e4290033b --- /dev/null +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/AbstractStepParserTest-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8ae4cae14a2e1c283ad71290cb3d626bd8c4fc32 Mon Sep 17 00:00:00 2001 From: Will Schipp Date: Thu, 17 Jan 2013 10:11:58 -0500 Subject: [PATCH 3/7] renamed test and corresponding text context --- ...rserTest.java => TaskletStepAllowStartIfCompleteTest.java} | 4 +++- ...xt.xml => TaskletStepAllowStartIfCompleteTest-context.xml} | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/{AbstractStepParserTest.java => TaskletStepAllowStartIfCompleteTest.java} (86%) rename spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/{AbstractStepParserTest-context.xml => TaskletStepAllowStartIfCompleteTest-context.xml} (100%) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java similarity index 86% rename from spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java index f5381cc3b..6a1318f25 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/AbstractStepParserTest.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java @@ -8,12 +8,14 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.step.AbstractStep; import org.springframework.context.ApplicationContext; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +@DirtiesContext @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration -public class AbstractStepParserTest { +public class TaskletStepAllowStartIfCompleteTest { @Resource private ApplicationContext context; diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/AbstractStepParserTest-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml similarity index 100% rename from spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/AbstractStepParserTest-context.xml rename to spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml From 525699532ead37cd6983cc99f46140fc9832ed85 Mon Sep 17 00:00:00 2001 From: Will Schipp Date: Thu, 17 Jan 2013 10:30:19 -0500 Subject: [PATCH 4/7] trial ignore --- .../xml/TaskletStepAllowStartIfCompleteTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java index 6a1318f25..bfaba1fa6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java @@ -4,15 +4,16 @@ import static org.junit.Assert.assertTrue; import javax.annotation.Resource; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.step.AbstractStep; import org.springframework.context.ApplicationContext; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -@DirtiesContext + +@Ignore @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class TaskletStepAllowStartIfCompleteTest { From 5e8c1b568448155180ec190cd49a04623a6da41a Mon Sep 17 00:00:00 2001 From: Will Schipp Date: Thu, 17 Jan 2013 11:37:33 -0500 Subject: [PATCH 5/7] test changes --- .../core/configuration/xml/AbstractStepParser.java | 10 +++++----- .../xml/TaskletStepAllowStartIfCompleteTest.java | 1 - 2 files changed, 5 insertions(+), 6 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 5f53e4425..5729f56f0 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 @@ -179,11 +179,11 @@ public abstract class AbstractStepParser { } //add the allow parser here - String isAllowStart = stepElement.getAttribute(ALLOW_START_ATTR); - if (StringUtils.hasText(isAllowStart)) { - //set the value as a property - bd.getPropertyValues().add("allowStartIfComplete", Boolean.valueOf(isAllowStart)); - } +// String isAllowStart = stepElement.getAttribute(ALLOW_START_ATTR); +// if (StringUtils.hasText(isAllowStart)) { +// //set the value as a property +// bd.getPropertyValues().add("allowStartIfComplete", Boolean.valueOf(isAllowStart)); +// } stepListenerParser.handleListenersElement(stepElement, bd, parserContext); return bd; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java index bfaba1fa6..6dc0f6e6f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java @@ -12,7 +12,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - @Ignore @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration From c6d7a4abd69b8e3f51733351dc1d98da1b7249ec Mon Sep 17 00:00:00 2001 From: Will Schipp Date: Thu, 17 Jan 2013 13:53:25 -0500 Subject: [PATCH 6/7] additional logic to support if already set by a tasklet - the step value is ignored --- .../core/configuration/xml/AbstractStepParser.java | 13 ++++++++----- .../xml/TaskletStepAllowStartIfCompleteTest.java | 2 +- 2 files changed, 9 insertions(+), 6 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 5729f56f0..8d33cb0b1 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 @@ -179,11 +179,14 @@ public abstract class AbstractStepParser { } //add the allow parser here -// String isAllowStart = stepElement.getAttribute(ALLOW_START_ATTR); -// if (StringUtils.hasText(isAllowStart)) { -// //set the value as a property -// bd.getPropertyValues().add("allowStartIfComplete", Boolean.valueOf(isAllowStart)); -// } + String isAllowStart = stepElement.getAttribute(ALLOW_START_ATTR); + if (StringUtils.hasText(isAllowStart)) { + //check if the value is already set from an inner element + if (!bd.getPropertyValues().contains("allowStartIfComplete")) { + //set the value as a property + bd.getPropertyValues().add("allowStartIfComplete", Boolean.valueOf(isAllowStart)); + }//end if + } stepListenerParser.handleListenersElement(stepElement, bd, parserContext); return bd; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java index 6dc0f6e6f..e401ca832 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java @@ -12,7 +12,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -@Ignore +//@Ignore @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class TaskletStepAllowStartIfCompleteTest { From 4c9204759d4b36cd68744230270e47cb04579df4 Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Tue, 22 Jan 2013 13:14:48 -0600 Subject: [PATCH 7/7] BATCH-1745: Added test to verify restart behavior --- .../TaskletStepAllowStartIfCompleteTest.java | 54 +++++++++++++++++++ ...etStepAllowStartIfCompleteTest-context.xml | 23 ++++++++ 2 files changed, 77 insertions(+) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java index e401ca832..a32354c4e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest.java @@ -1,5 +1,22 @@ package org.springframework.batch.core.configuration.xml; +<<<<<<< HEAD +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Date; + +import javax.annotation.Resource; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.AbstractStep; +import org.springframework.beans.factory.annotation.Autowired; +======= import static org.junit.Assert.assertTrue; import javax.annotation.Resource; @@ -8,15 +25,51 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.step.AbstractStep; +>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72 import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +<<<<<<< HEAD +======= //@Ignore +>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class TaskletStepAllowStartIfCompleteTest { +<<<<<<< HEAD + @Autowired + Job job; + + @Autowired + JobRepository jobRepository; + + @Resource + private ApplicationContext context; + + @Test + public void test() throws Exception { + //retrieve the step from the context and see that it's allow is set + AbstractStep abstractStep = (AbstractStep) context.getBean("simpleJob.step1"); + assertTrue(abstractStep.isAllowStartIfComplete()); + } + + @Test + public void testRestart() throws Exception { + JobParametersBuilder paramBuilder = new JobParametersBuilder(); + paramBuilder.addDate("value", new Date()); + JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters()); + + job.execute(jobExecution); + + jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters()); + job.execute(jobExecution); + + int count = jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), "simpleJob.step1"); + assertEquals(2, count); + } +======= @Resource private ApplicationContext context; @@ -27,4 +80,5 @@ public class TaskletStepAllowStartIfCompleteTest { assertTrue(abstractStep.isAllowStartIfComplete()); } +>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72 } diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml index e4290033b..a3aa712fe 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/TaskletStepAllowStartIfCompleteTest-context.xml @@ -8,7 +8,11 @@ +<<<<<<< HEAD + +======= +>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72 @@ -20,6 +24,21 @@ +<<<<<<< HEAD + + + + + + + + + + + + +======= +>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72 @@ -27,7 +46,11 @@ +<<<<<<< HEAD + +======= +>>>>>>> a9edfc18765552d54ac46f721d128260ceaf1e72