Package org.springframework.batch.core

Examples of org.springframework.batch.core.Step


  public void testSimulatedRestartWithNoBacklog() throws Exception {

    factory.setItemReader(new ListItemReader<String>(Arrays.asList(StringUtils
        .commaDelimitedListToStringArray("1,2,3,4,5,6"))));

    Step step = factory.getObject();

    StepExecution stepExecution = getStepExecution(step);

    // Set up expectation of three messages (chunks) in the backlog
    stepExecution.getExecutionContext().putInt(ChunkMessageChannelItemWriter.EXPECTED, 6);
    stepExecution.getExecutionContext().putInt(ChunkMessageChannelItemWriter.ACTUAL, 3);

    writer.setMaxWaitTimeouts(2);

    /*
     * With no backlog we process all the items, but the listener can't
     * reconcile the expected number of items with the actual. An infinite
     * loop would be bad, so the best we can do is fail as fast as possible.
     */
    step.execute(stepExecution);
    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals(ExitStatus.FAILED.getExitCode(), stepExecution.getExitStatus().getExitCode());
    String message = stepExecution.getExitStatus().getExitDescription();
    assertTrue("Message did not contain 'timed out': " + message, message.toLowerCase().contains("timed out"));

View Full Code Here


  public void testFailureInStepListener() throws Exception {

    factory.setItemReader(new ListItemReader<String>(Arrays.asList(StringUtils
        .commaDelimitedListToStringArray("wait,fail,3,4,5,6"))));

    Step step = factory.getObject();

    StepExecution stepExecution = getStepExecution(step);
    step.execute(stepExecution);

    waitForResults(2, 10);

    // The number of items processed is actually between 1 and 6, because
    // the one that failed might have been processed out of order.
View Full Code Here

        StepLocator locator = (StepLocator) state;
        for (String name : locator.getStepNames()) {
          map.put(name, locator.getStep(name));
        }
      } else if (state instanceof StepHolder) {
        Step step = ((StepHolder) state).getStep();
        String name = step.getName();
        stepMap.put(name, step);
      }
      else if (state instanceof FlowHolder) {
        for (Flow subflow : ((FlowHolder) state).getFlows()) {
          findSteps(subflow, map);
View Full Code Here

  protected void setUp() throws Exception {

    JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters();
    jobInstance = new JobInstance(new Long(0), "testJob");
    JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
    Step step = new StepSupport("bar");
    stepExecution = jobExecution.createStepExecution(step.getName());
    policy.beforeStep(stepExecution);

  }
View Full Code Here

    SkipListener<Integer, String> skipListener = mock(SkipListener.class);
    skipListener.onSkipInWrite("3", exception);
    skipListener.onSkipInWrite("4", exception);

    factory.setListeners(new SkipListener[] { skipListener });
    Step step = factory.getObject();

    StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);
    step.execute(stepExecution);

    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());

    assertEquals(2, stepExecution.getSkipCount());
    assertEquals(0, stepExecution.getReadSkipCount());
View Full Code Here

    factoryBean.setDecider(new DeciderSupport());
    factoryBean.setName("IL");

    factoryBean.afterPropertiesSet();

    Step step = factoryBean.getObject();

    assertEquals("IL", step.getName());
    assertEquals(DecisionStep.class, step.getClass());
  }
View Full Code Here

    reader.setFailures("2");

    // nothing is skippable
    factory.setSkippableExceptionClasses(getExceptionMap(NonExistentException.class));

    Step step = factory.getObject();

    step.execute(stepExecution);
    assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
    assertEquals(ExitStatus.FAILED.getExitCode(), stepExecution.getExitStatus().getExitCode());
    assertTrue(stepExecution.getExitStatus().getExitDescription().contains("Non-skippable exception during read"));

    assertStepExecutionsAreEqual(stepExecution, repository.getLastStepExecution(jobExecution.getJobInstance(), step
        .getName()));
  }
View Full Code Here

  @Test
  @SuppressWarnings("resource")
  public void testCommitIntervalLateBinding() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/batch/core/configuration/xml/ChunkElementLateBindingParserTests-context.xml");
    Step step = context.getBean("s1", Step.class);
    assertNotNull("Step not parsed", step);
  }
View Full Code Here

  @Test
  @SuppressWarnings("resource")
  public void testSkipAndRetryAttributes() throws Exception {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/batch/core/configuration/xml/ChunkElementSkipAndRetryAttributeParserTests-context.xml");
    Step step = context.getBean("s1", Step.class);
    assertNotNull("Step not parsed", step);
  }
View Full Code Here

  @SuppressWarnings("resource")
  public void testIllegalSkipAndRetryAttributes() throws Exception {
    try {
      ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/batch/core/configuration/xml/ChunkElementIllegalSkipAndRetryAttributeParserTests-context.xml");
    Step step = context.getBean("s1", Step.class);
    assertNotNull("Step not parsed", step);
    fail("Expected BeanCreationException");
    } catch (BeanCreationException e) {
      // expected
    }
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.