Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobParameters


  /**
   * Test method for {@link SimpleJobService#launch(String, JobParameters)}.
   */
  @Test
  public void testLaunchFailedExecution() throws Exception {
    JobParameters jobParameters = new JobParameters();
    Job job = new JobSupport("job") {
      @Override
      public JobParametersIncrementer getJobParametersIncrementer() {
        return new RunIdIncrementer();
      }
View Full Code Here


  public void testRestart() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(
        MetaDataInstanceFactory.createJobInstance());
    JobParameters jobParameters = new JobParameters();
    Job job = new JobSupport("job");
    EasyMock.expect(jobLocator.getJob("job")).andReturn(job);
    EasyMock.expect(jobLauncher.run(job, jobParameters))
    .andReturn(MetaDataInstanceFactory.createJobExecution(124L));
    EasyMock.replay(jobInstanceDao, jobExecutionDao, jobLauncher, jobLocator);
View Full Code Here

  public JobParameters getNext(JobParameters parameters) {
    Map<String, JobParameter> map = new HashMap<String, JobParameter>(
        parameters.getParameters());
    map.put("run.count", new JobParameter(parameters
        .getLong("run.count", -1)+1));
    return new JobParameters(map);
  }
View Full Code Here

  @ServiceActivator
  public JobLaunchRequest adapt(String jobName) throws NoSuchJobException,
  JobParametersNotFoundException {
    jobName = jobName.trim();
    Job job = jobLocator.getJob(jobName);
    JobParameters jobParameters = getLastFailedJobParameters(jobName);
    return new JobLaunchRequest(job, jobParameters);
  }
View Full Code Here

    int start = 0;
    int count = 100;
    List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobName,
        start, count);

    JobParameters jobParameters = null;

    if (lastInstances.isEmpty()) {
      throw new JobParametersNotFoundException(
          "No job instance found for job=" + jobName);
    }
View Full Code Here

    context.refresh();

    ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(
        new String[] { "classpath:/test-job-context.xml" }, parent);
    Job job = child.getBean(Job.class);
    final JobExecution jobExecution = parent.getBean(JobLauncher.class).run(job, new JobParameters());

    new DirectPoller<BatchStatus>(100).poll(new Callable<BatchStatus>() {
      public BatchStatus call() throws Exception {
        BatchStatus status = jobExecution.getStatus();
        if (status.isLessThan(BatchStatus.STOPPED) && status != BatchStatus.COMPLETED) {
View Full Code Here

  @DirtiesContext
  public void testSmallLaunch() throws Exception {

    int before = jdbcTemplate.queryForInt("SELECT COUNT(1) from LEAD_INPUTS");

    JobParameters jobParameters = new JobParametersBuilder().addString("input.file", "classpath:data/test.txt")
        .addLong("timestamp", System.currentTimeMillis()).toJobParameters();
    JobExecution jobExecution = jobLauncher.run(job, jobParameters);

    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
View Full Code Here

    jobRepositoryTestUtils.removeJobExecutions();

    List<JobExecution> list = new ArrayList<JobExecution>(jobRepositoryTestUtils.createJobExecutions("test-job",
        new String[0], 1));

    JobParameters jobParameters = new JobParametersBuilder().addLong("timestamp", System.currentTimeMillis())
        .toJobParameters();
    try {
      // Simulate a job starting without using jobLauncher
      jobRepository.createJobExecution("test-job", jobParameters);
      fail("Expected: JobExecutionAlreadyRunningException");
View Full Code Here

  }

  @ServiceActivator
  public JobExecution launch(JobLaunchRequest request) throws JobExecutionException {
    Job job = request.getJob();
    JobParameters jobParameters = request.getJobParameters();

    return jobLauncher.run(job, jobParameters);
  }
View Full Code Here

  }

  @Test
  @DirtiesContext
  public void testFailedStep() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
        new JobParameter("unsupported"))));
    assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    assertEquals(9, stepExecution.getReadCount());
    // In principle the write count could be more than 2 and less than 9...
View Full Code Here

TOP

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

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.