Package org.springframework.batch.core

Examples of org.springframework.batch.core.Step


  @Test
  public void testReadError() throws Exception{
    reader.failCount = 10;

    Step step = builder.chunk(25).reader(reader).processor(processor).writer(writer).listener((ItemReadListener<String>) readListener).build();

    runStep(step);

    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals(9, processor.count);
View Full Code Here


    writer.setFailures("4", "5");

    factory.setSkipLimit(4);
    factory.setCommitInterval(3); // includes all expected skips

    Step step = factory.getObject();

    step.execute(stepExecution);
    assertEquals(4, stepExecution.getSkipCount());
    assertEquals(2, stepExecution.getReadSkipCount());
    assertEquals(2, stepExecution.getWriteSkipCount());

    // skipped 2,3,4,5
    List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,6,7"));
    assertEquals(expectedOutput, writer.getCommitted());
    assertStepExecutionsAreEqual(stepExecution, repository.getLastStepExecution(jobExecution.getJobInstance(), step
        .getName()));
  }
View Full Code Here

  @Test
  public void testProcessError() throws Exception{
    processor.failCount = 10;

    Step step = builder.chunk(25).reader(reader).processor(processor).writer(writer).listener((ItemReadListener<String>) readListener).build();

    runStep(step);

    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals(10, processor.count);
View Full Code Here

  @Test
  public void testWriteError() throws Exception{
    writer.fail = true;

    Step step = builder.chunk(25).reader(reader).processor(processor).writer(writer).listener((ItemReadListener<String>) readListener).build();

    runStep(step);

    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals(25, processor.count);
View Full Code Here

  }

  @Test
  public void testMultipleChunks() throws Exception{

    Step step = builder.chunk(10).reader(reader).processor(processor).writer(writer).listener((ItemReadListener<String>) readListener).build();

    runStep(step);

    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
    assertEquals(25, processor.count);
View Full Code Here

    reader.setFailures("b");

    factory.setSkippableExceptionClasses(getExceptionMap(Exception.class));
    factory.setSkipLimit(1);

    Step step = factory.getObject();

    step.execute(stepExecution);

    assertEquals(1, stepExecution.getSkipCount());
    assertEquals("[a, c]", reader.getRead().toString());
    assertStepExecutionsAreEqual(stepExecution, repository.getLastStepExecution(jobExecution.getJobInstance(), step
        .getName()));
  }
View Full Code Here

    factory.setCommitInterval(5);
    factory.setSkipLimit(3);
    factory.setSkippableExceptionClasses(getExceptionMap(Exception.class));

    Step step = factory.getObject();

    step.execute(stepExecution);
    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals("bad skip count", 3, stepExecution.getSkipCount());
    assertEquals("bad read skip count", 2, stepExecution.getReadSkipCount());
    assertEquals("bad write skip count", 1, stepExecution.getWriteSkipCount());

    // writer did not skip "6" as it never made it to writer, only "4" did
    assertFalse(reader.getRead().contains("6"));
    assertTrue(reader.getRead().contains("4"));

    // only "1" was ever committed
    List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,2,3,5,7,8,9,10,11"));
    assertEquals(expectedOutput, writer.getCommitted());
    assertStepExecutionsAreEqual(stepExecution, repository.getLastStepExecution(jobExecution.getJobInstance(), step
        .getName()));
  }
View Full Code Here

  public void testReprocessingAfterWriterRollback() throws Exception {
    reader.setItems("1", "2", "3", "4");

    writer.setFailures("4");

    Step step = factory.getObject();
    step.execute(stepExecution);

    assertEquals(1, stepExecution.getSkipCount());
    assertEquals(2, stepExecution.getRollbackCount());

    // 1,2,3,4,3,4 - one scan until the item is
    // identified and finally skipped on the second attempt
    assertEquals("[1, 2, 3, 4, 3, 4]", processor.getProcessed().toString());
    assertStepExecutionsAreEqual(stepExecution, repository.getLastStepExecution(jobExecution.getJobInstance(), step
        .getName()));
  }
View Full Code Here

      }
    }

    factory.setItemWriter(new TestItemListenerWriter());

    Step step = factory.getObject();
    step.execute(stepExecution);

    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
    for (int i = 1; i <= 6; i++) {
      assertTrue("didn't call listener " + i, listenerCalls.contains(i));
    }
View Full Code Here

    };

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

    Step step = factory.getObject();

    step.execute(stepExecution);

    assertTrue(opened);
    assertTrue(closed);
    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.Step

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.