Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobParameter


  private Job job;

  @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


  }

  @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

  }

  @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

   */
  private void insertJobParameters(Long executionId, JobParameters jobParameters) {

    for (Entry<String, JobParameter> entry : jobParameters.getParameters()
        .entrySet()) {
      JobParameter jobParameter = entry.getValue();
      insertParameter(executionId, jobParameter.getType(), entry.getKey(),
          jobParameter.getValue(), jobParameter.isIdentifying());
    }
  }
View Full Code Here

    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();
      Object value = jobParameter.getValue();
      if (value != null) {
        key = (!jobParameter.isIdentifying()? NON_IDENTIFYING_FLAG : "") + key;
        if (jobParameter.getType() == ParameterType.DATE) {
          synchronized (dateFormat) {
            result.setProperty(key + DATE_TYPE, dateFormat.format(value));
          }
        }
        else if (jobParameter.getType() == ParameterType.LONG) {
          synchronized (longNumberFormat) {
            result.setProperty(key + LONG_TYPE, longNumberFormat.format(value));
          }
        }
        else if (jobParameter.getType() == ParameterType.DOUBLE) {
          result.setProperty(key + DOUBLE_TYPE, decimalFormat((Double)value));
        }
        else {
          result.setProperty(key, "" + value);
        }
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...
    assertEquals(7, stepExecution.getWriteCount());
View Full Code Here

    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

  @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

  @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

  }

  @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

TOP

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

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.