示例#1
0
  @Test
  public void timeout() {
    Jcl jcl =
        JclFactory.compileJcl(
            JOB
                + "## run at 2016-2-10 18:24 timeout 1 minute\n"
                + "## run at 2016/2/10 18:24 timeout 1 hour\n"
                + "## run every minute timeout minute\n"
                + "## run every 10 minutes timeout 5 minutes\n");
    test(jcl);

    System.out.println(jcl.getSchedule().replace("><", ">\n<"));

    assertSame(JclType.SCHEDULABLE, jcl.getType());

    LocalDateTime dt = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
    String now = dt.toLocalDate().toString() + " " + dt.toLocalTime().toString();

    assertEquals(
        "Schedule",
        "<schedule>"
            + "<once at=\"2016-02-10 18:24\" timeout=\"1 minute\"/>"
            + "<once at=\"2016-02-10 18:24\" timeout=\"1 hour\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 minute\" timeout=\"1 minute\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"10 minute\" timeout=\"5 minute\"/>"
            + "</schedule>",
        jcl.getSchedule());
  }
示例#2
0
 @Test
 public void deletejob() {
   for (String job : DELETEJOB) {
     Jcl jcl = JclFactory.compileJcl(job);
     test(jcl);
     assertSame(job, JclType.DELETE, jcl.getType());
   }
 }
示例#3
0
 @Test
 public void subjob() {
   for (String job : SUBJOB) {
     Jcl jcl = JclFactory.compileJcl(job);
     test(jcl);
     assertSame(job, JclType.SUBROUTINE, jcl.getType());
   }
 }
示例#4
0
  /** Test we schedule to run at a specific date/time */
  @Test
  public void runAt() {
    Jcl jcl =
        JclFactory.compileJcl(
            JOB
                + "## run at 2016-2-10 18:24\n"
                + "## run at 2016/2/10 18:24\n"
                + "## run at 2016-2-10\n"
                + "## run at 18:24\n"
                // retry on failure after 1 hour
                + "## run at 18:24 retry 1 hour\n"
                + "## run at 18:24 retry 1 hour maximum 3\n"
                + "## run at 2016/2/10 18:24 retry every 1 hour\n"
                + "## run at 2016/2/10 18:24 retry every 1 hour maximum 3 times\n");
    test(jcl);

    System.out.println("runat\n" + jcl.getSchedule().replace("><", ">\n<"));

    assertSame(JclType.SCHEDULABLE, jcl.getType());

    String today = LocalDate.now().toString();
    String now = LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString();

    assertEquals(
        "Schedule",
        "<schedule>"
            + "<once at=\"2016-02-10 18:24\"/>"
            + "<once at=\"2016-02-10 18:24\"/>"
            + "<once at=\"2016-02-10 "
            + now
            + "\"/>"
            + "<once at=\""
            + today
            + " 18:24\"/>"
            // retry on failure after 1 hour
            + "<once at=\""
            + today
            + " 18:24\" retry=\"1 hour\"/>"
            + "<once at=\""
            + today
            + " 18:24\" retry=\"1 hour\" max=\"3\"/>"
            + "<once at=\"2016-02-10 18:24\" retry=\"1 hour\"/>"
            + "<once at=\"2016-02-10 18:24\" retry=\"1 hour\" max=\"3\"/>"
            + "</schedule>",
        jcl.getSchedule());
  }
示例#5
0
 /** Test that a Jcl actually gets populated. This is the bare minimum Jcl */
 @Test
 public void job() {
   Jcl jcl = JclFactory.compileJcl(JOB);
   test(jcl);
   assertSame(JclType.EXECUTABLE, jcl.getType());
 }
示例#6
0
  @Test
  public void runEvery() {
    Jcl jcl =
        JclFactory.compileJcl(
            JOB
                + "## run every minute\n"
                + "## run every 10 minutes\n"
                + "## run every hour\n"
                + "## run every 3 hours\n"
                + "## run every day\n"
                + "## run every 2 days\n"
                + "## run every 2 day\n"
                // retry on failure after 1 hour
                + "## run every day retry 1 hour\n"
                + "## run every day retry 1 hour maximum 3 times\n"
                + "## run every day retry every 1 hour\n"
                + "## run every day retry every 1 hour maximum 3\n"
                // Between
                + "## run every hour between 00:00 and 06:00\n"
                + "## run every hour between 00:00 and 06:00 retry 10 minutes maximum 3 times\n"
                + "## run every hour between 21:00 and 03:00\n"
                + "## run every hour between 21:00 and 03:00 retry 10 minutes maximum 3 times\n");
    test(jcl);

    System.out.println(jcl.getSchedule().replace("><", ">\n<"));

    assertSame(JclType.SCHEDULABLE, jcl.getType());

    LocalDateTime dt = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
    String now = dt.toLocalDate().toString() + " " + dt.toLocalTime().toString();

    assertEquals(
        "Schedule",
        "<schedule>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 minute\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"10 minute\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 hour\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"3 hour\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 day\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"2 day\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"2 day\"/>"
            // retry on failure after 1 hour
            + "<repeat next=\""
            + now
            + "\" step=\"1 day\" retry=\"1 hour\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 day\" retry=\"1 hour\" max=\"3\"/>"
            // same but with every keyword
            + "<repeat next=\""
            + now
            + "\" step=\"1 day\" retry=\"1 hour\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 day\" retry=\"1 hour\" max=\"3\"/>"
            // Between
            + "<repeat next=\""
            + now
            + "\" step=\"1 hour\" between=\"00:00-06:00\"/>"
            + "<repeat next=\""
            + now
            + "\" step=\"1 hour\" retry=\"10 minute\" max=\"3\" between=\"00:00-06:00\"/>"
            // Between 2100-0300 crossing midnight
            + "<repeat next=\""
            + now
            + "\" step=\"1 hour\" between=\"21:00-03:00\"/>"
            // Between 2100-0300 crossing midnight retry 10 minutes max 3
            + "<repeat next=\""
            + now
            + "\" step=\"1 hour\" retry=\"10 minute\" max=\"3\" between=\"21:00-03:00\"/>"
            + "</schedule>",
        jcl.getSchedule());
  }