Example usage for org.springframework.batch.core JobExecution createStepExecution

List of usage examples for org.springframework.batch.core JobExecution createStepExecution

Introduction

In this page you can find the example usage for org.springframework.batch.core JobExecution createStepExecution.

Prototype

public StepExecution createStepExecution(String stepName) 

Source Link

Document

Register a step execution with the current job execution.

Usage

From source file:org.springframework.batch.core.step.tasklet.AsyncTaskletStepTests.java

/**
 * StepExecution should fail immediately on error.
 *///from   www  .  j  ava2s .c o  m
@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());

}