public void testGetParametersWithDateFormat() throws Exception {

    String[] args = new String[] {"schedule.date=2008/23/01"};

    factory.setDateFormat(new SimpleDateFormat("yyyy/dd/MM"));
    JobParameters props =
        factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
    assertNotNull(props);
    Date date = dateFormat.parse("01/23/2008");
    assertEquals(date, props.getDate("schedule.date"));
  }
  public void testGetParametersWithBogusDate() throws Exception {

    String[] args = new String[] {"schedule.date=20080123"};

    try {
      factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
    } catch (IllegalArgumentException e) {
      String message = e.getMessage();
      assertTrue("Message should contain wrong date: " + message, contains(message, "20080123"));
    }
  }
  public void testGetProperties() throws Exception {

    JobParameters parameters =
        new JobParametersBuilder()
            .addDate("schedule.date", dateFormat.parse("01/23/2008"))
            .addString("job.key", "myKey")
            .addString("vendor.id", "33243243")
            .toJobParameters();

    Properties props = factory.getProperties(parameters);
    assertNotNull(props);
    assertEquals("myKey", props.getProperty("job.key"));
    assertEquals("33243243", props.getProperty("vendor.id"));
    assertEquals("2008/01/23", props.getProperty("schedule.date"));
  }
  public void testGetParameters() throws Exception {

    String jobKey = "job.key=myKey";
    String scheduleDate = "schedule.date=2008/01/23";
    String vendorId = "vendor.id=33243243";

    String[] args = new String[] {jobKey, scheduleDate, vendorId};

    JobParameters props =
        factory.getJobParameters(StringUtils.splitArrayElementsIntoProperties(args, "="));
    assertNotNull(props);
    assertEquals("myKey", props.getString("job.key"));
    assertEquals("33243243", props.getString("vendor.id"));
    Date date = dateFormat.parse("01/23/2008");
    assertEquals(date, props.getDate("schedule.date"));
  }
 public void testNullArgs() {
   assertEquals(new JobParameters(), factory.getJobParameters(null));
   assertEquals(new Properties(), factory.getProperties(null));
 }
  public void testEmptyArgs() {

    JobParameters props = factory.getJobParameters(new Properties());
    assertTrue(props.getParameters().isEmpty());
  }