Exemplo n.º 1
0
  @Test
  public void testJobDeployWithParameters() throws InterruptedException {
    logger.info("Create batch job with parameters");

    JobParametersHolder.reset();
    String jobName = generateJobName();
    executeJobCreate(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, false);
    checkForJobInList(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, false);

    final JobParametersHolder jobParametersHolder = new JobParametersHolder();

    CommandResult cr = deployJob(jobName);
    checkForSuccess(cr);
    checkDeployedJobMessage(cr, jobName);
    triggerJobWithParams(jobName, "{\"param1\":\"spring rocks!\"}");
    boolean done = jobParametersHolder.isDone();

    assertTrue("The countdown latch expired and did not count down.", done);

    int numberOfJobParameters = JobParametersHolder.getJobParameters().size();
    assertTrue(
        "Expecting 2 parameters but got " + numberOfJobParameters, numberOfJobParameters == 2);

    assertNotNull(JobParametersHolder.getJobParameters().get("random"));

    final JobParameter parameter1 = JobParametersHolder.getJobParameters().get("param1");

    assertNotNull(parameter1);
    assertEquals("spring rocks!", parameter1.getValue());
  }
Exemplo n.º 2
0
  @Test
  public void testJobDeployWithTypedParameters() throws InterruptedException, ParseException {
    logger.info("Create batch job with typed parameters");
    JobParametersHolder.reset();
    String jobName = generateJobName();
    executeJobCreate(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, false);
    checkForJobInList(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, false);

    final JobParametersHolder jobParametersHolder = new JobParametersHolder();

    final CommandResult cr = deployJob(jobName);
    checkForSuccess(cr);
    checkDeployedJobMessage(cr, jobName);
    triggerJobWithParams(jobName, "{\"-param1(long)\":\"12345\",\"param2(date)\":\"1990/10/03\"}");

    boolean done = jobParametersHolder.isDone();

    assertTrue("The countdown latch expired and did not count down.", done);
    assertTrue("Expecting 3 parameters.", JobParametersHolder.getJobParameters().size() == 3);
    assertNotNull(JobParametersHolder.getJobParameters().get("random"));

    final JobParameter parameter1 = JobParametersHolder.getJobParameters().get("param1");
    final JobParameter parameter2 = JobParametersHolder.getJobParameters().get("param2");

    assertNotNull(parameter1);
    assertNotNull(parameter2);
    assertTrue("parameter1 should be a Long", parameter1.getValue() instanceof Long);
    assertTrue("parameter2 should be a java.util.Date", parameter2.getValue() instanceof Date);

    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
    final Date expectedDate = dateFormat.parse("1990/10/03");

    assertEquals("Was expecting the Long value 12345", Long.valueOf(12345), parameter1.getValue());
    assertEquals("Should be the same dates", expectedDate, parameter2.getValue());

    assertFalse("parameter1 should be non-identifying", parameter1.isIdentifying());
    assertTrue("parameter2 should be identifying", parameter2.isIdentifying());
  }
Exemplo n.º 3
0
  @Test
  public void testLaunchJobWithParameters() throws InterruptedException, ParseException {
    logger.info("Launch batch job with typed parameters");
    String myJobParams = "{\"-param1(long)\":\"12345\",\"param2(date)\":\"1990/10/03\"}";
    JobParametersHolder.reset();
    final JobParametersHolder jobParametersHolder = new JobParametersHolder();
    String jobName = generateJobName();
    executeJobCreate(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR);
    checkForJobInList(jobName, JOB_WITH_PARAMETERS_DESCRIPTOR, true);
    executeJobLaunch(jobName, myJobParams);
    boolean done = jobParametersHolder.isDone();

    assertTrue("The countdown latch expired and did not count down.", done);
    // Make sure the job parameters are set when passing through job launch command
    assertTrue(
        "Expecting 3 parameters, but got: " + JobParametersHolder.getJobParameters(),
        JobParametersHolder.getJobParameters().size() == 3);
    assertNotNull(JobParametersHolder.getJobParameters().get("random"));

    final JobParameter parameter1 = JobParametersHolder.getJobParameters().get("param1");
    final JobParameter parameter2 = JobParametersHolder.getJobParameters().get("param2");

    assertNotNull(parameter1);
    assertNotNull(parameter2);
    assertTrue("parameter1 should be a Long", parameter1.getValue() instanceof Long);
    assertTrue("parameter2 should be a java.util.Date", parameter2.getValue() instanceof Date);

    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
    final Date expectedDate = dateFormat.parse("1990/10/03");

    assertEquals("Was expecting the Long value 12345", Long.valueOf(12345), parameter1.getValue());
    assertEquals("Should be the same dates", expectedDate, parameter2.getValue());

    assertFalse("parameter1 should be non-identifying", parameter1.isIdentifying());
    assertTrue("parameter2 should be identifying", parameter2.isIdentifying());
  }