Package org.springframework.scheduling

Examples of org.springframework.scheduling.TriggerContext


  public void testSpecificDayOfMonthSecond() throws Exception {
    CronTrigger trigger = new CronTrigger("55 * * 3 * *", timeZone);
    calendar.set(Calendar.DAY_OF_MONTH, 2);
    calendar.set(Calendar.SECOND, 54);
    Date date = calendar.getTime();
    TriggerContext context1 = getTriggerContext(date);
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 55);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
    calendar.add(Calendar.MINUTE, 1);
    TriggerContext context2 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
  }
View Full Code Here


  public void testSpecificDate() throws Exception {
    CronTrigger trigger = new CronTrigger("* * * 3 11 *", timeZone);
    calendar.set(Calendar.DAY_OF_MONTH, 2);
    calendar.set(Calendar.MONTH, 9);
    Date date = calendar.getTime();
    TriggerContext context1 = getTriggerContext(date);
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MONTH, 10); // 10=November
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
    calendar.add(Calendar.SECOND, 1);
    TriggerContext context2 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
  }
View Full Code Here

    // TODO: maybe try and detect this as a special case in parser?
    CronTrigger trigger = new CronTrigger("0 0 0 31 6 *", timeZone);
    calendar.set(Calendar.DAY_OF_MONTH, 10);
    calendar.set(Calendar.MONTH, 2);
    Date date = calendar.getTime();
    TriggerContext context1 = getTriggerContext(date);
    trigger.nextExecutionTime(context1);
    // new CronTrigger("0 0 0 30 1 ?", timeZone);
  }
View Full Code Here

    CronTrigger trigger = new CronTrigger("0 0 0 29 2 *", timeZone);
    calendar.set(Calendar.YEAR, 2007);
    calendar.set(Calendar.DAY_OF_MONTH, 10);
    calendar.set(Calendar.MONTH, 1); // 2=February
    Date date = calendar.getTime();
    TriggerContext context1 = getTriggerContext(date);
    calendar.set(Calendar.YEAR, 2008);
    calendar.set(Calendar.DAY_OF_MONTH, 29);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
    calendar.add(Calendar.YEAR, 4);
    TriggerContext context2 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
  }
View Full Code Here

    calendar.set(Calendar.HOUR_OF_DAY, 7);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    // Add two days because we start on Saturday
    calendar.add(Calendar.DAY_OF_MONTH, 2);
    TriggerContext context1 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
    // Next day is a week day so add one
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    TriggerContext context2 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
    calendar.add(Calendar.DAY_OF_MONTH, 1);
    TriggerContext context3 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context3));
  }
View Full Code Here

    // set expected next trigger time
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 30);
    calendar.set(Calendar.SECOND, 0);
    calendar.add(Calendar.MONTH, 1);
    TriggerContext context1 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context1));
    // Next trigger is 3 months latter
    calendar.add(Calendar.MONTH, 3);
    TriggerContext context2 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context2));
    // Next trigger is 3 months latter
    calendar.add(Calendar.MONTH, 3);
    TriggerContext context3 = getTriggerContext(date);
    assertEquals(calendar.getTime(), date = trigger.nextExecutionTime(context3));
  }
View Full Code Here

    calendar.set(Calendar.MONTH, Calendar.MARCH);
    calendar.set(Calendar.YEAR, 2013);
    calendar.set(Calendar.HOUR_OF_DAY, 1);
    calendar.set(Calendar.SECOND, 54);
    Date date = calendar.getTime();
    TriggerContext context1 = getTriggerContext(date);
    if (timeZone.equals(TimeZone.getTimeZone("CET"))) {
      // Clocks go forward an hour so 2am doesn't exist in CET for this date
      calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
    calendar.add(Calendar.HOUR_OF_DAY, 1);
View Full Code Here

  }

  private void assertMatchesNextSecond(CronTrigger trigger, Calendar calendar) {
    Date date = calendar.getTime();
    roundup(calendar);
    TriggerContext context = getTriggerContext(date);
    assertEquals(calendar.getTime(), trigger.nextExecutionTime(context));
  }
View Full Code Here

  }

  @Test
  public void testMatchAll() throws Exception {
    CronTrigger trigger = new CronTrigger("* * * * * *", timeZone);
    TriggerContext context = getTriggerContext(date);
    assertEquals(calendar.getTime(), trigger.nextExecutionTime(context));
  }
View Full Code Here

  public void testIncrementSecondByOne() throws Exception {
    CronTrigger trigger = new CronTrigger("11 * * * * *", timeZone);
    calendar.set(Calendar.SECOND, 10);
    Date date = calendar.getTime();
    calendar.add(Calendar.SECOND, 1);
    TriggerContext context = getTriggerContext(date);
    assertEquals(calendar.getTime(), trigger.nextExecutionTime(context));
  }
View Full Code Here

TOP

Related Classes of org.springframework.scheduling.TriggerContext

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.