/** * Convenient method for subclasses to grab a {@link StepRunner} for running * steps by name. * * @return a {@link StepRunner} */ protected StepRunner getStepRunner() { if (this.stepRunner == null) { this.stepRunner = new StepRunner(getJobLauncher(), getJobRepository()); } return this.stepRunner; }
/** * Convenient method for subclasses to grab a {@link StepRunner} for running * steps by name. * * @return a {@link StepRunner} */ protected StepRunner getStepRunner() { if (this.stepRunner == null) { this.stepRunner = new StepRunner(getJobLauncher(), getJobRepository()); } return this.stepRunner; }
/** * Create a {@link StepExecution} with default parameters. * * @return a {@link StepExecution} with stepName="step" and * id=DEFAULT_STEP_EXECUTION_ID */ public static StepExecution createStepExecution() { return createStepExecution(DEFAULT_STEP_NAME, DEFAULT_STEP_EXECUTION_ID); }
/** * Launch the entire job, including all steps. * * @return JobExecution, so that the test can validate the exit status * @throws Exception thrown if error occurs launching the job. */ public JobExecution launchJob() throws Exception { return this.launchJob(this.getUniqueJobParameters()); }
/** * Create a {@link StepExecution} with the parameters provided. * * @param stepName the stepName for the {@link StepExecution} * @param executionId the id for the {@link StepExecution} * @return a {@link StepExecution} with a {@link JobExecution} having * default properties */ public static StepExecution createStepExecution(String stepName, Long executionId) { return createStepExecution(createJobExecution(), stepName, executionId); }
@Bean public JobLauncherTestUtils testUtils() { JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils(); jobLauncherTestUtils.setJob(job()); return jobLauncherTestUtils; } }
/** * 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 as its own job. A unique set of * JobParameters will automatically be generated. An IllegalStateException * is thrown if there is no Step with the given name. * * @param step The step to launch * @return JobExecution */ public JobExecution launchStep(Step step) { return this.launchStep(step, this.makeUniqueJobParameters(), null); }
private void initialize() { if (!this.initialized) { destroy(); if (this.initScripts != null) { for (Resource initScript : this.initScripts) { doExecuteScript(initScript); } } this.initialized = true; } }
/** * Launch the entire job, including all steps. * * @return JobExecution, so that the test can validate the exit status * * @throws Exception is thrown if error occurs. */ protected JobExecution launchJob() throws Exception { return this.launchJob(this.getUniqueJobParameters()); }
/** * 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); }
/** * Create a {@link JobExecution} with default parameters. * * @return a {@link JobExecution} with id=DEFAULT_JOB_EXECUTION_ID */ public static JobExecution createJobExecution() { return createJobExecution(DEFAULT_JOB_EXECUTION_ID); }
/** * Launch just the specified step as its own job. An IllegalStateException * is thrown if there is no Step with the given name. * * @param step The step to launch * @param jobParameters The JobParameters to use during the launch * @return JobExecution */ public JobExecution launchStep(Step step, JobParameters jobParameters) { return this.launchStep(step, jobParameters, null); }
/** * 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); }
/** * Create a {@link JobRepositoryTestUtils} with all its mandatory * properties. * * @param jobRepository a {@link JobRepository} backed by a database * @param dataSource a {@link DataSource} */ public JobRepositoryTestUtils(JobRepository jobRepository, DataSource dataSource) { super(); this.jobRepository = jobRepository; setDataSource(dataSource); }
@Test public void testWithParameters() throws Exception { testJobParameters(new WithJobExecutionFactory()); }
@Test public void testWithParameters() throws Exception { testJobParameters(new WithStepExecutionFactory()); }
/** * 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 * @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); }
/** * Create a {@link JobExecution} with the parameters provided. * * @param executionId the id for the {@link JobExecution} * @return a {@link JobExecution} with valid {@link JobInstance} */ public static JobExecution createJobExecution(Long executionId) { return createJobExecution(DEFAULT_JOB_NAME, DEFAULT_JOB_INSTANCE_ID, executionId); }