updated unit test to use top level <step/> element to define a step

This commit is contained in:
dhgarrette
2009-03-25 14:56:39 +00:00
parent 945c0d91df
commit 94c467e919
4 changed files with 16 additions and 21 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,22 +43,21 @@ public class StopRestartOnCompletedStepJobParserTests extends AbstractJobParserT
//
// First Launch
//
launchAndAssert();
launchAndAssert("[s0, s1]");
//
// Second Launch
//
stepNamesList.clear();
launchAndAssert();
launchAndAssert("[s1]");
}
private void launchAndAssert() throws JobInstanceAlreadyCompleteException, JobRestartException,
private void launchAndAssert(String stepNames) throws JobInstanceAlreadyCompleteException, JobRestartException,
JobExecutionAlreadyRunningException {
JobExecution jobExecution = createJobExecution();
job.execute(jobExecution);
assertEquals(1, stepNamesList.size());
assertTrue(stepNamesList.contains("s1"));
assertEquals(stepNames, stepNamesList.toString());
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode());

View File

@@ -16,7 +16,6 @@
package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,22 +43,21 @@ public class StopRestartOnFailedStepJobParserTests extends AbstractJobParserTest
//
// First Launch
//
launchAndAssert();
launchAndAssert("[s0, fail]");
//
// Second Launch
//
stepNamesList.clear();
launchAndAssert();
launchAndAssert("[fail]");
}
private void launchAndAssert() throws JobInstanceAlreadyCompleteException, JobRestartException,
private void launchAndAssert(String stepNames) throws JobInstanceAlreadyCompleteException, JobRestartException,
JobExecutionAlreadyRunningException {
JobExecution jobExecution = createJobExecution();
job.execute(jobExecution);
assertEquals(1, stepNamesList.size());
assertTrue(stepNamesList.contains("fail"));
assertEquals(stepNames, stepNamesList.toString());
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode());

View File

@@ -7,6 +7,7 @@
<beans:import resource="common-context.xml" />
<job id="job">
<step id="s0" ref="step2" next="s1"/>
<step id="s1" ref="taskletStep">
<!-- On normal step status: stop the job, but restart with the same step. -->
<stop on="COMPLETED" restart="s1"/>
@@ -14,9 +15,8 @@
</step>
</job>
<beans:bean id="taskletStep" parent="step1">
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<beans:property name="allowStartIfComplete" value="true"/>
</beans:bean>
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<step id="taskletStep" parent="step1" allow-start-if-complete="true"/>
</beans:beans>

View File

@@ -7,6 +7,7 @@
<beans:import resource="common-context.xml" />
<job id="job">
<step id="s0" ref="step2" next="fail"/>
<step id="fail" ref="taskletStep">
<!-- On failure: stop the job, but restart with the same step. -->
<stop on="FAILED" restart="fail"/>
@@ -14,9 +15,7 @@
</step>
</job>
<beans:bean id="taskletStep" parent="failingStep">
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<beans:property name="allowStartIfComplete" value="true"/>
</beans:bean>
<!-- On restart this step will be re-executed: effect is infinitely re-runnable job -->
<step id="taskletStep" parent="failingStep" allow-start-if-complete="true"/>
</beans:beans>