/** * Launch just the specified step in the job. An IllegalStateException is * thrown if there is no Step with the given name. * * @param stepName The name of the step to launch * @param jobParameters The JobParameters to use during the launch * @return JobExecution */ public JobExecution launchStep(String stepName, JobParameters jobParameters) { return this.launchStep(stepName, jobParameters, null); }
/** * Launch just the specified step in the job. A unique set of JobParameters * will automatically be generated. An IllegalStateException is thrown if * there is no Step with the given name. * * @param stepName The name of the step to launch * @return JobExecution */ public JobExecution launchStep(String stepName) { return this.launchStep(stepName, this.getUniqueJobParameters(), null); }
/** * Launch just the specified step in the job. A unique set of JobParameters * will automatically be generated. An IllegalStateException is thrown if * there is no Step with the given name. * * @param stepName The name of the step to launch * @param jobExecutionContext An ExecutionContext whose values will be * loaded into the Job ExecutionContext prior to launching the step. * @return JobExecution */ public JobExecution launchStep(String stepName, ExecutionContext jobExecutionContext) { return this.launchStep(stepName, this.getUniqueJobParameters(), jobExecutionContext); }
@Test(expected = IllegalStateException.class) public void testNonExistentStep() { jobLauncherTestUtils.launchStep("nonExistent"); }
@Test public void testStepExecutionWithJavaConfig() { ApplicationContext context = new AnnotationConfigApplicationContext(TestJobConfiguration.class); JobLauncherTestUtils testUtils = context.getBean(JobLauncherTestUtils.class); JobExecution execution = testUtils.launchStep("step1"); assertEquals(ExitStatus.COMPLETED, execution.getExitStatus()); }
@Test public void test() { JobExecution jobExecution = jobLauncherTestUtils.launchStep("step-under-test"); assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); }
@Test public void testStep1Execution() { assertEquals(BatchStatus.COMPLETED, jobLauncherTestUtils.launchStep("step1").getStatus()); this.verifyTasklet(1); }
@Test @Repeat(10) public void testStep3Execution() throws Exception { // logging only, may complete in < 1ms (repeat so that it's likely to for at least one of those times) assertEquals(BatchStatus.COMPLETED, jobLauncherTestUtils.launchStep("step3").getStatus()); }
@Test public void testStep2Execution() { assertEquals(BatchStatus.COMPLETED, jobLauncherTestUtils.launchStep("step2").getStatus()); this.verifyTasklet(2); }
@Test public void testStepLaunchJobContextEntry() { ExecutionContext jobContext = new ExecutionContext(); jobContext.put("key1", "value1"); assertEquals(BatchStatus.COMPLETED, jobLauncherTestUtils.launchStep("step2", jobContext).getStatus()); this.verifyTasklet(2); assertTrue(tasklet2.jobContextEntryFound); }
@ContextConfiguration( locations= {"classpath:META-INF/application-conext","classpath: test-context.xml"} ) @RunWith(SpringJUnit4ClassRunner.class) public class StepWithSkipTest { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; @Test public void testStepWithSkip() throws JobInterruptedException{ JobExecution execution = jobLauncherTestUtils.launchStep("importPersonStep"); } }