Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobParametersBuilder


  //The API that sets the persisted user data is on the JsrStepContext so the key within the ExecutionContext is JsrStepContext
  private ExecutionContextUserSupport executionContextUserSupport = new ExecutionContextUserSupport(ClassUtils.getShortName(JsrStepContext.class));

  @Before
  public void setUp() throws Exception {
    JobExecution jobExecution = new JobExecution(1L, new JobParametersBuilder().addString("key", "value").toJobParameters());

    stepExecution = new StepExecution("testStep", jobExecution);
    stepExecution.setId(5L);
    stepExecution.setStatus(BatchStatus.STARTED);
    stepExecution.setExitStatus(new ExitStatus("customExitStatus"));
View Full Code Here


  }

  @Test
  public void testRepeatedFlowStep() throws Exception {
    assertNotNull(job1);
    JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParametersBuilder()
    .addLong("gridSize", 1L).toJobParameters());
    job1.execute(jobExecution);
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    Collections.sort(savedStepNames);
    assertEquals("[s2, s2, s2, s2, s3, s3, s3, s3]", savedStepNames.toString());
View Full Code Here

  @Test
  public void testLaunchJob() throws Exception {

    // Force failure in one of the parallel steps
    ExampleItemReader.fail = true;
    JobParameters jobParameters = new JobParametersBuilder().addString("restart", "yes").toJobParameters();

    int beforeMaster = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:master'", Integer.class);
    int beforePartition = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME like 'step1:partition%'", Integer.class);

    ExampleItemWriter.clear();
View Full Code Here

    stepExecutionDao = mock(StepExecutionDao.class);
    ecDao = mock(ExecutionContextDao.class);

    jobRepository = new SimpleJobRepository(jobInstanceDao, jobExecutionDao, stepExecutionDao, ecDao);

    jobParameters = new JobParametersBuilder().toJobParameters();

    job = new JobSupport();
    job.setBeanName("RepositoryTest");
    job.setRestartable(true);
View Full Code Here

    step.afterPropertiesSet();
    job.addStep(step);
    job.setJobRepository(jobRepository);
    job.afterPropertiesSet();

    jobLauncher.run(job, new JobParametersBuilder().addString("test", getClass().getName()).toJobParameters());

    Thread.sleep(500L);
    JobExplorer explorer = new MapJobExplorerFactoryBean(repositoryFactory).getObject();
    Set<JobExecution> executions = explorer.findRunningJobExecutions("job");
    assertEquals(1, executions.size());
View Full Code Here

    String scheduledJob = "ScheduledJob";
    jobInstanceDao.createJobInstance(scheduledJob, jobParameters);

    // Modifying the key should bring back a completely different
    // JobInstance
    JobParameters tempProps = new JobParametersBuilder().addString("job.key", "testKey1").toJobParameters();

    JobInstance instance;
    instance = jobInstanceDao.getJobInstance(scheduledJob, jobParameters);
    assertNotNull(instance);
View Full Code Here

    assertEquals("{foo="+date.getTime()+"}", jobParameters.toString());
  }

  @Test
  public void testUseParentParameters() throws Exception {
    JobExecution jobExecution = new JobExecution(0L, new JobParametersBuilder()
        .addString("parentParam", "val")
        .toJobParameters());

    StepExecution stepExecution = new StepExecution("step", jobExecution);
View Full Code Here

  @Test
  public void testDontUseParentParameters() throws Exception {
    DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor();
    extractor.setUseAllParentParameters(false);

    JobExecution jobExecution = new JobExecution(0L, new JobParametersBuilder()
        .addString("parentParam", "val")
        .toJobParameters());

    StepExecution stepExecution = new StepExecution("step", jobExecution);
View Full Code Here

  /**
   * @see JobParametersExtractor#getJobParameters(Job, StepExecution)
   */
  @Override
  public JobParameters getJobParameters(Job job, StepExecution stepExecution) {
    JobParametersBuilder builder = new JobParametersBuilder();
    Map<String, JobParameter> jobParameters = stepExecution.getJobParameters().getParameters();
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    if (useAllParentParameters) {
      for (String key : jobParameters.keySet()) {
        builder.addParameter(key, jobParameters.get(key));
      }
    }
    for (String key : keys) {
      if (key.endsWith("(long)")) {
        key = key.replace("(long)", "");
        if (executionContext.containsKey(key)) {
          builder.addLong(key, executionContext.getLong(key));
        }
        else if (jobParameters.containsKey(key)) {
          builder.addLong(key, (Long) jobParameters.get(key).getValue());
        }
      }
      else if (key.endsWith("(int)")) {
        key = key.replace("(int)", "");
        if (executionContext.containsKey(key)) {
          builder.addLong(key, (long) executionContext.getInt(key));
        }
        else if (jobParameters.containsKey(key)) {
          builder.addLong(key, (Long) jobParameters.get(key).getValue());
        }
      }
      else if (key.endsWith("(double)")) {
        key = key.replace("(double)", "");
        if (executionContext.containsKey(key)) {
          builder.addDouble(key, executionContext.getDouble(key));
        }
        else if (jobParameters.containsKey(key)) {
          builder.addDouble(key, (Double) jobParameters.get(key).getValue());
        }
      }
      else if (key.endsWith("(string)")) {
        key = key.replace("(string)", "");
        if (executionContext.containsKey(key)) {
          builder.addString(key, executionContext.getString(key));
        }
        else if (jobParameters.containsKey(key)) {
          builder.addString(key, (String) jobParameters.get(key).getValue());
        }
      }
      else if (key.endsWith("(date)")) {
        key = key.replace("(date)", "");
        if (executionContext.containsKey(key)) {
          builder.addDate(key, (Date) executionContext.get(key));
        }
        else if (jobParameters.containsKey(key)) {
          builder.addDate(key, (Date) jobParameters.get(key).getValue());
        }
      }
      else {
        if (executionContext.containsKey(key)) {
          builder.addString(key, executionContext.get(key).toString());
        }
        else if (jobParameters.containsKey(key)) {
          builder.addString(key, jobParameters.get(key).getValue().toString());
        }
      }
    }
    return builder.toJobParameters();
  }
View Full Code Here

@ContextConfiguration(locations = "/jobs/iosample/delimited.xml")
public class DelimitedFunctionalTests extends AbstractIoSampleTests {

  @Override
  protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) {
    JobParameters jobParameters = new JobParametersBuilder(super.getUniqueJobParameters()).addString("inputFile",
        "file:./build/test-outputs/delimitedOutput.csv").toJobParameters();
    StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(jobParameters);
    StepSynchronizationManager.close();
    StepSynchronizationManager.register(stepExecution);
  }
View Full Code Here

TOP

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

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.