/** * StepExecution should fail immediately on error. */ @Test public void testStepExecutionFails() throws Exception { throttleLimit = 1; concurrencyLimit = 1; items = Arrays.asList("one", "fail", "three", "four"); setUp(); JobExecution jobExecution = jobRepository.createJobExecution("JOB", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution(step.getName()); step.execute(stepExecution); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(2, stepExecution.getReadCount()); assertEquals(2, processed.size()); }
/** * StepExecution should fail immediately on error. */ @Test public void testStepExecutionFailsOnLastItem() throws Exception { throttleLimit = 1; concurrencyLimit = 1; items = Arrays.asList("one", "two", "three", "fail"); setUp(); JobExecution jobExecution = jobRepository.createJobExecution("JOB", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution(step.getName()); step.execute(stepExecution); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(4, stepExecution.getReadCount()); assertEquals(4, processed.size()); }
.commaDelimitedListToStringArray("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25"))); setUp();
/** * StepExecution should fail immediately on error in processor. */ @Test public void testStepExecutionFailsWithProcessor() throws Exception { throttleLimit = 1; concurrencyLimit = 1; items = Arrays.asList("one", "barf", "three", "four"); itemProcessor = new ItemProcessor<String, String>() { @Override public String process(String item) throws Exception { logger.info("Item: "+item); processed.add(item); if (item.equals("barf")) { throw new RuntimeException("Planned processor error"); } return item; } }; setUp(); JobExecution jobExecution = jobRepository.createJobExecution("JOB", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution(step.getName()); step.execute(stepExecution); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); assertEquals(2, stepExecution.getReadCount()); assertEquals(2, processed.size()); }