@Test public void testExecuteRestart() throws Exception { DefaultJobParametersExtractor jobParametersExtractor = new DefaultJobParametersExtractor(); jobParametersExtractor.setKeys(new String[] {"foo"}); ExecutionContext executionContext = stepExecution.getExecutionContext();
@Test public void testStoppedChild() throws Exception { DefaultJobParametersExtractor jobParametersExtractor = new DefaultJobParametersExtractor(); jobParametersExtractor.setKeys(new String[] {"foo"}); ExecutionContext executionContext = stepExecution.getExecutionContext(); executionContext.put("foo", "bar"); step.setJobParametersExtractor(jobParametersExtractor); step.setJob(new JobSupport("child") { @Override public void execute(JobExecution execution) { assertEquals(1, execution.getJobParameters().getParameters().size()); execution.setStatus(BatchStatus.STOPPED); execution.setEndTime(new Date()); jobRepository.update(execution); } @Override public boolean isRestartable() { return true; } }); step.afterPropertiesSet(); step.execute(stepExecution); JobExecution jobExecution = stepExecution.getJobExecution(); jobExecution.setEndTime(new Date()); jobRepository.update(jobExecution); assertEquals(BatchStatus.STOPPED, stepExecution.getStatus()); }
@Test public void testDontUseParentParameters() throws Exception { DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor(); extractor.setUseAllParentParameters(false); JobExecution jobExecution = new JobExecution(0L, new JobParametersBuilder() .addString("parentParam", "val") .toJobParameters()); StepExecution stepExecution = new StepExecution("step", jobExecution); stepExecution.getExecutionContext().putDouble("foo", 11.1); extractor.setKeys(new String[] {"foo(double)"}); JobParameters jobParameters = extractor.getJobParameters(null, stepExecution); assertEquals("{foo=11.1}", jobParameters.toString()); } }