Example usage for org.springframework.batch.item.support AbstractItemStreamItemReader AbstractItemStreamItemReader

List of usage examples for org.springframework.batch.item.support AbstractItemStreamItemReader AbstractItemStreamItemReader

Introduction

In this page you can find the example usage for org.springframework.batch.item.support AbstractItemStreamItemReader AbstractItemStreamItemReader.

Prototype

AbstractItemStreamItemReader

Source Link

Usage

From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanTests.java

/**
 * Check ItemStream is opened//ww w .  j a  v  a2s .  c o  m
 */
@Test
public void testItemStreamOpenedEvenWithTaskExecutor() throws Exception {
    writer.setFailures("4");

    ItemReader<String> reader = new AbstractItemStreamItemReader<String>() {
        @Override
        public void close() {
            super.close();
            closed = true;
        }

        @Override
        public void open(ExecutionContext executionContext) {
            super.open(executionContext);
            opened = true;
        }

        @Override
        public String read() {
            return null;
        }
    };

    factory.setItemReader(reader);
    factory.setTaskExecutor(new ConcurrentTaskExecutor());

    Step step = factory.getObject();

    step.execute(stepExecution);

    assertTrue(opened);
    assertTrue(closed);
    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
}