Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobParametersBuilder


  }

  @Test
  @DirtiesContext
  public void testSkipsInWriter() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder().addString("item.three", "fail")
        .addLong("run.id", 1L).toJobParameters());
    // System.err.println(new SimpleJdbcTemplate(dataSource).queryForList("SELECT * FROM INT_MESSAGE_GROUP"));
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    assertEquals(9, stepExecution.getReadCount());
View Full Code Here


  private StepExecution getStepExecution(Step step) throws JobExecutionAlreadyRunningException, JobRestartException,
  JobInstanceAlreadyCompleteException {
    SimpleJob job = new SimpleJob();
    job.setName("job");
    JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParametersBuilder().addLong(
        "job.counter", jobCounter++).toJobParameters());
    StepExecution stepExecution = jobExecution.createStepExecution(step.getName());
    jobRepository.add(stepExecution);
    return stepExecution;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  @DirtiesContext
  public void testReply() {
    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("dontclash", "12");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.REPLY_CHANNEL, "response");
    MessageHeaders headers = new MessageHeaders(map);
    GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(job,
        builder.toJobParameters()), headers);
    requestChannel.send(trigger);
    Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);

    assertNotNull("No response received", executionMessage);
    JobExecution execution = executionMessage.getPayload();
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  @DirtiesContext
  public void testReply() {
    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("dontclash", "12");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.REPLY_CHANNEL, "response");
    MessageHeaders headers = new MessageHeaders(map);
    GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(job,
        builder.toJobParameters()), headers);
    requestChannel.send(trigger);
    Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);

    assertNotNull("No response received", executionMessage);
    JobExecution execution = executionMessage.getPayload();
View Full Code Here

  @SuppressWarnings("unchecked")
  public void testExceptionRaised() throws InterruptedException {

    this.tasklet.setFail(true);

    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addString("dontclash", "12");
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(MessageHeaders.REPLY_CHANNEL, "response");
    MessageHeaders headers = new MessageHeaders(map);
    GenericMessage<JobLaunchRequest> trigger = new GenericMessage<JobLaunchRequest>(new JobLaunchRequest(testJob,
        builder.toJobParameters()), headers);
    requestChannel.send(trigger);

    Message<JobExecution> executionMessage = (Message<JobExecution>) responseChannel.receive(1000);

    assertNotNull("No response received", executionMessage);
View Full Code Here

   */

  @Override
  protected void setUp() throws Exception {

    JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters();
    jobInstance = new JobInstance(new Long(0), "testJob");
    JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
    Step step = new StepSupport("bar");
    stepExecution = jobExecution.createStepExecution(step.getName());
    policy.beforeStep(stepExecution);
View Full Code Here

      this.jdbcTemplate.update("insert into FOO values (?,?,?)", 0, "zero", 0);
      this.jdbcTemplate.update("insert into FOO values (?,?,?)", 1, "one", 1);
      this.jdbcTemplate.update("insert into FOO values (?,?,?)", 2, "two", 2);
      this.jdbcTemplate.update("insert into FOO values (?,?,?)", 3, "three", 3);

      JobParametersBuilder builder = new JobParametersBuilder().addLong("min.id", 1L).addLong("max.id", 2L);
      JobExecution jobExecution = this.jobLauncher.run(this.job, builder.toJobParameters());
      assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());

      List<Foo> foos = fooStoringItemWriter.getFoos();
      assertEquals(2, foos.size());
      System.err.println(foos.get(0));
View Full Code Here

    assertEquals(9, stepExecution.getWriteCount());
  }

  @Test
  public void testSkipsInWriter() throws Exception {
    JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder().addString("item.three", "fail")
        .addLong("run.id", 1L).toJobParameters());
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    assertEquals(9, stepExecution.getReadCount());
    assertEquals(7, stepExecution.getWriteCount());
View Full Code Here

    assertTrue(result.contains("job2"));
  }

  @Test
  public void testGetParametersRoseyScenario() {
    JobExecution jobExecution = new JobExecution(5L, new JobParametersBuilder().addString("key1", "value1").addLong(JsrJobParametersConverter.JOB_RUN_ID, 5L).toJobParameters());

    when(jobExplorer.getJobExecution(5L)).thenReturn(jobExecution);

    Properties params = jsrJobOperator.getParameters(5L);
View Full Code Here

  @Test
  public void testGetRestartJobParameters() {
    JsrJobOperator jobOperator = (JsrJobOperator) jsrJobOperator;

    JobExecution jobExecution = new JobExecution(1L,
        new JobParametersBuilder().addString("prevKey1", "prevVal1").toJobParameters());

    Properties userProperties = new Properties();
    userProperties.put("userKey1", "userVal1");

    Properties properties = jobOperator.getJobRestartProperties(userProperties, jobExecution);
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.