Examples of JobParameter


Examples of org.springframework.batch.core.JobParameter

    final Map<String, JobParameter> map = new HashMap<String, JobParameter>();
    RowCallbackHandler handler = new RowCallbackHandler() {
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        ParameterType type = ParameterType.valueOf(rs.getString(3));
        JobParameter value = null;

        if (type == ParameterType.STRING) {
          value = new JobParameter(rs.getString(4), rs.getString(8).equalsIgnoreCase("Y"));
        } else if (type == ParameterType.LONG) {
          value = new JobParameter(rs.getLong(6), rs.getString(8).equalsIgnoreCase("Y"));
        } else if (type == ParameterType.DOUBLE) {
          value = new JobParameter(rs.getDouble(7), rs.getString(8).equalsIgnoreCase("Y"));
        } else if (type == ParameterType.DATE) {
          value = new JobParameter(rs.getTimestamp(5), rs.getString(8).equalsIgnoreCase("Y"));
        }

        // No need to assert that value is not null because it's an enum
        map.put(rs.getString(2), value);
      }
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

  @Test
  @DirtiesContext
  public void testFailedStepOnError() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
        new JobParameter("error"))));
    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...
    assertEquals(7, stepExecution.getWriteCount());
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

  @Test
  @DirtiesContext
  public void testSunnyDayFaultTolerant() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
        new JobParameter("3"))));
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    assertEquals(9, stepExecution.getReadCount());
    assertEquals(9, stepExecution.getWriteCount());
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

  }

  @Test
  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...
    assertEquals(7, stepExecution.getWriteCount());
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

  }

  @Test
  public void testFailedStepOnError() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
        new JobParameter("error"))));
    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...
    assertEquals(7, stepExecution.getWriteCount());
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

  }

  @Test
  public void testSunnyDayFaultTolerant() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
        new JobParameter("3"))));
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    assertEquals(9, stepExecution.getReadCount());
    assertEquals(9, stepExecution.getWriteCount());
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

        written.addAll(data);
      }
    }, chunkOperations));

    final JobExecution jobExecution = jobRepository.createJobExecution(job.getName(),
        new JobParameters(Collections.singletonMap("run.id", new JobParameter(getClass().getName() + ".1"))));
    StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);

    jobRepository.add(stepExecution);
    step.execute(stepExecution);
    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

        });
      }
    }, chunkOperations));

    JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters(Collections
        .singletonMap("run.id", new JobParameter(getClass().getName() + ".1"))));
    StepExecution stepExecution = new StepExecution(step.getName(), jobExecution);

    stepExecution.setExecutionContext(new ExecutionContext() {
      {
        put("foo", "bar");
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

    Map<String, JobParameter> parameters = params.getParameters();
    Properties result = new Properties();
    for (Entry<String, JobParameter> entry : parameters.entrySet()) {
      String key = entry.getKey();
      JobParameter jobParameter = entry.getValue();
      if (key.equals(SCHEDULE_DATE_KEY)) {
        result.setProperty(key, dateFormat.format(jobParameter.getValue()));
      } else {
        result.setProperty(key, "" + jobParameter.getValue());
      }
    }
    return result;
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameter

   * @return a new JobParameters object containing only a parameter for the
   * current timestamp, to ensure that the job instance will be unique.
   */
  public JobParameters getUniqueJobParameters() {
    Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
    parameters.put("random", new JobParameter((long) (Math.random() * JOB_PARAMETER_MAXIMUM)));
    return new JobParameters(parameters);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.