StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setEndTime(new Date()); stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution);
@Test public void testVanillaStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set<StepExecution> executions = stepSplitter.split(stepExecution, 2); for (StepExecution execution : executions) { execution.setStatus(BatchStatus.COMPLETED); execution.setExitStatus(ExitStatus.COMPLETED); } return executions; } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); // one master and two workers assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size()); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); }
@Test public void testFailedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set<StepExecution> executions = stepSplitter.split(stepExecution, 2); for (StepExecution execution : executions) { execution.setStatus(BatchStatus.FAILED); execution.setExitStatus(ExitStatus.FAILED); } return executions; } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); // one master and two workers assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size()); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); }
@Test public void testStoppedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set<StepExecution> executions = stepSplitter.split(stepExecution, 2); for (StepExecution execution : executions) { execution.setStatus(BatchStatus.STOPPED); execution.setExitStatus(ExitStatus.STOPPED); } return executions; } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); // one master and two workers assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size()); assertEquals(BatchStatus.STOPPED, stepExecution.getStatus()); }
@Test public void testStepAggregator() throws Exception { step.setStepExecutionAggregator(new DefaultStepExecutionAggregator() { @Override public void aggregate(StepExecution result, Collection<StepExecution> executions) { super.aggregate(result, executions); result.getExecutionContext().put("aggregated", true); } }); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { return Arrays.asList(stepExecution); } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); assertEquals(true, stepExecution.getExecutionContext().get("aggregated")); }