Package org.springframework.batch.integration.launch

Examples of org.springframework.batch.integration.launch.JobLaunchRequest


    assertEquals("foo", request.getJob().getName());
  }

  @Test
  public void testSimpleJobWithHyphen() throws Exception {
    JobLaunchRequest request = adapter.adapt("foo-bar");
    assertEquals("foo-bar", request.getJob().getName());
  }
View Full Code Here


    assertEquals("foo-bar", request.getJob().getName());
  }

  @Test
  public void testJobParameter() throws Exception {
    JobLaunchRequest request = adapter.adapt("foo[bar=spam]");
    assertEquals("foo", request.getJob().getName());
    assertEquals(1, request.getJobParameters().getParameters().size());
    assertEquals("spam", request.getJobParameters().getString("bar"));
  }
View Full Code Here

    assertEquals("spam", request.getJobParameters().getString("bar"));
  }

  @Test
  public void testJobParameters() throws Exception {
    JobLaunchRequest request = adapter.adapt("foo[bar=spam,count(long)=123]");
    assertEquals("foo", request.getJob().getName());
    assertEquals(2, request.getJobParameters().getParameters().size());
    assertEquals("spam", request.getJobParameters().getString("bar"));
    assertEquals(123l, request.getJobParameters().getLong("count").intValue());
  }
View Full Code Here

  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

  public void testLaunchFromSimpleRequestString() throws Exception {

    TestMessagingGateway gateway = new TestMessagingGateway(requests, replies);


    JobLaunchRequest jobLaunchRequest = new JobLaunchRequest(job, new JobParametersBuilder().addString(
        "input.file", "classpath:data/test.txt").addLong("timestamp", System.currentTimeMillis())
        .toJobParameters());

    JobExecution result = (JobExecution) gateway.sendAndReceive(jobLaunchRequest);
View Full Code Here

    adapter.setJob(new SimpleJob("foo"));
  }

  @Test
  public void testSimpleJob() throws Exception {
    JobLaunchRequest request = adapter.adapt(new File("src/test/resources/data/test.txt"));
    assertEquals("foo", request.getJob().getName());
    String fileName = request.getJobParameters().getString("input.file");
    Resource resource = new DefaultResourceLoader().getResource(fileName);
    assertTrue("File does not exist: " + fileName, resource.exists());
    assertNotNull("File is empty", IOUtils.toString(resource.getInputStream()));
  }
View Full Code Here

      jobParameters = job.getJobParametersIncrementer().getNext(jobParameters);
    }

    jobParameters = jobParametersConverter.removeRestartParameterIfExists(jobParameters);

    return new JobLaunchRequest(job, jobParameters);
  }
View Full Code Here

  @Test
  public void createJobParametersWithUniqueParam() throws Exception {

    final Message<String> message = MessageBuilder.withPayload("{\"param1\":\"Kenny\", \"param2\":\"Cartman\"}").build();

    final JobLaunchRequest jobLaunchRequest = transformer.toJobLaunchRequest(message);

    assertNotNull(jobLaunchRequest.getJobParameters());
    assertTrue(jobLaunchRequest.getJobParameters().getParameters().size() == 3);

    assertEquals("Kenny", jobLaunchRequest.getJobParameters().getString("param1"));
    assertEquals("Cartman", jobLaunchRequest.getJobParameters().getString("param2"));
    assertNotNull(jobLaunchRequest.getJobParameters().getString("random"));

  }
View Full Code Here

    properties.put("param1", "Kenny");
    properties.put("param2", "Cartman");

    final Message<Properties> message = MessageBuilder.withPayload(properties).build();

    final JobLaunchRequest jobLaunchRequest = transformer.toJobLaunchRequest(message);

    assertNotNull(jobLaunchRequest.getJobParameters());
    assertTrue(jobLaunchRequest.getJobParameters().getParameters().size() == 3);

    assertEquals("Kenny", jobLaunchRequest.getJobParameters().getString("param1"));
    assertEquals("Cartman", jobLaunchRequest.getJobParameters().getString("param2"));
    assertNotNull(jobLaunchRequest.getJobParameters().getString("random"));

  }
View Full Code Here

    map.put("param1", "Kenny");
    map.put("param2", "Cartman");

    final Message<Map<String, String>> message = MessageBuilder.withPayload(map).build();

    final JobLaunchRequest jobLaunchRequest = transformer.toJobLaunchRequest(message);

    assertNotNull(jobLaunchRequest.getJobParameters());
    assertTrue(jobLaunchRequest.getJobParameters().getParameters().size() == 3);

    assertEquals("Kenny", jobLaunchRequest.getJobParameters().getString("param1"));
    assertEquals("Cartman", jobLaunchRequest.getJobParameters().getString("param2"));
    assertNotNull(jobLaunchRequest.getJobParameters().getString("random"));

  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.integration.launch.JobLaunchRequest

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.