Package org.springframework.batch.core

Examples of org.springframework.batch.core.Step


    return steps.keySet();
  }

  @Override
  public Step getStep(String stepName) throws NoSuchStepException {
    final Step step = steps.get(stepName);
    if (step == null) {
      throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]");
    }
    return step;
  }
View Full Code Here


        ExecutionContext ctx = new ExecutionContext();
        ctx.putLong("crashedPosition", 7);
        JobExecution jobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        jobExec.setStartTime(new Date(0));
        jobExec.setExecutionContext(ctx);
        Step step = new StepSupport("step1");
        StepExecution stepExec = new StepExecution(step.getName(), jobExec);
        stepExec.setExecutionContext(ctx);

        jobRepository.add(stepExec);

        StepExecution retrievedStepExec = jobRepository.getLastStepExecution(jobExec.getJobInstance(), step.getName());
        assertEquals(stepExec, retrievedStepExec);
        assertEquals(ctx, retrievedStepExec.getExecutionContext());

    }
View Full Code Here

    if(log.isDebugEnabled()) {
      log.debug("Got StepExecution: " + stepExecution);
      log.debug("Locating Step: " + stepName);
    }

    Step step = getStepLocator().getStep(stepName);
    if(log.isDebugEnabled()) {
      log.debug("Located step: " + step);
    }

    if (step == null) {
      throw new NoSuchStepException(String.format("No Step with name [%s] could be located.", stepName));
    }

    try {
      if(log.isDebugEnabled()) {
        log.debug("Executing step: " + step + " / " + stepExecution);
      }
      step.execute(stepExecution);
    } catch (JobInterruptedException e) {
      log.error("error executing step 1", e);
      stepExecution.setStatus(BatchStatus.STOPPED);
    } catch (Throwable e) {
      log.error("error executing step 2", e);
View Full Code Here

        super();
    }

    @Test
    public void testExecute() throws JobInterruptedException {
        Step step = createTestStep("testExecute");
        JobExecution jobData = TestDummyJobRepository.createJobExecutionInstance(step.getName());
        StepExecution stepData = new StepExecution(step.getName(), jobData);
        step.execute(stepData);
        assertOperationDetails(getLastEntered(), "execute", step.getName());
    }
View Full Code Here

        return op;
    }

    protected Step createTestStep(final String name) {
        return new Step() {
            public String getName() {
                return name;
            }

            public boolean isAllowStartIfComplete() {
View Full Code Here

    }

    @Test
    public void testExecuteStep()
            throws JobInterruptedException, JobRestartException, StartLimitExceededException {
        Step step = createTestStep("testExecuteStep");
        String stepName = step.getName();
        FlowExecutor executor = createFlowExecutor("testExecuteJob", stepName);

        executor.executeStep(step);

        Operation op = assertOperationDetails(getFirstEntered(), "executeStep", step.getName());
        assertOperationPath(op, null, stepName);
    }
View Full Code Here

   * @param jobExecutionContext An ExecutionContext whose values will be
   * loaded into the Job ExecutionContext prior to launching the step.
   * @return JobExecution
   */
  public JobExecution launchStep(String stepName, JobParameters jobParameters, ExecutionContext jobExecutionContext) {
    Step step = this.job.getStep(stepName);
    if (step == null) {
      step = this.job.getStep(this.job.getName() + "." + stepName);
    }
    if (step == null) {
      throw new IllegalStateException("No Step found with name: [" + stepName + "]");
View Full Code Here

    if (stepExecution == null) {
      throw new NoSuchStepException("No StepExecution could be located for this request: " + request);
    }

    String stepName = request.getStepName();
    Step step = stepLocator.getStep(stepName);
    if (step == null) {
      throw new NoSuchStepException(String.format("No Step with name [%s] could be located.", stepName));
    }

    try {
      step.execute(stepExecution);
    }
    catch (JobInterruptedException e) {
      stepExecution.setStatus(BatchStatus.STOPPED);
      // The receiver should update the stepExecution in repository
    }
View Full Code Here

   * .
   * @throws NoSuchJobException
   */
  @Test
  public void testGetStep() throws NoSuchJobException {
    Step step = EasyMock.createMock(Step.class);
    JobStepLocator job = EasyMock.createMock(JobStepLocator.class);
    EasyMock.expect(jobLocator.getJob("job")).andReturn(job);
    EasyMock.expect(job.getStepNames()).andReturn(Arrays.asList("step"));
    EasyMock.expect(job.getStep("step")).andReturn(step);
    EasyMock.replay(jobLocator, job);
View Full Code Here

    EasyMock.verify(jobLocator, job);
  }

  @Test
  public void testGetStepWithJobPrefix() throws NoSuchJobException {
    Step step = EasyMock.createMock(Step.class);
    JobStepLocator job = EasyMock.createMock(JobStepLocator.class);
    EasyMock.expect(jobLocator.getJob("job")).andReturn(job);
    EasyMock.expect(job.getStepNames()).andReturn(Arrays.asList("job.step")).anyTimes();
    EasyMock.expect(job.getStep("job.step")).andReturn(step);
    EasyMock.replay(jobLocator, job);
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.