Java 类org.quartz.impl.calendar.HolidayCalendar 实例源码

项目:Camel    文件:QuartzCustomCalendarFireTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();

    HolidayCalendar cal = new HolidayCalendar();
    java.util.Calendar tomorrow = java.util.Calendar.getInstance();
    tomorrow.setTime(new Date());
    tomorrow.add(java.util.Calendar.DAY_OF_MONTH, 1);
    cal.addExcludedDate(tomorrow.getTime());

    jndi.bind("calendar", cal);
    return jndi;
}
项目:Camel    文件:QuartzCustomCalendarNoFireTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();

    HolidayCalendar cal = new HolidayCalendar();
    cal.addExcludedDate(new Date());

    jndi.bind("calendar", cal);
    return jndi;
}
项目:quartz-redis-jobstore    文件:StoreCalendarTest.java   
@Test
public void holidayCalendar() throws Exception {
    // HolidayCalendar sets the time of any given Date to 00:00:00
    java.util.Calendar cal = java.util.Calendar.getInstance();
    cal.set(java.util.Calendar.HOUR_OF_DAY, 0);
    cal.set(java.util.Calendar.MINUTE, 0);
    cal.set(java.util.Calendar.SECOND, 0);
    cal.set(java.util.Calendar.MILLISECOND, 0);
    final Date excludedDate = cal.getTime();

    HolidayCalendar calendar = new HolidayCalendar();
    calendar.addExcludedDate(excludedDate);
    final String name = "holidayCalendar";
    jobStore.storeCalendar(name, calendar, true, true);

    final String calendarHashKey = schema.calendarHashKey(name);
    Map<String, String> calendarMap = jedis.hgetAll(calendarHashKey);

    assertThat(calendarMap, hasKey("calendar_class"));
    assertThat(calendarMap.get("calendar_class"), equalTo(HolidayCalendar.class.getName()));
    assertThat(calendarMap, hasKey("calendar_json"));
    String json = calendarMap.get("calendar_json");
    assertThat(json, containsString("\"dates\":["));
    assertThat(json, not(containsString("\"excludedDates\":")));

    Calendar retrieved = jobStore.retrieveCalendar(name);
    assertThat(retrieved, notNullValue());
    assertThat(retrieved, instanceOf(HolidayCalendar.class));
    HolidayCalendar retrievedHoliday = (HolidayCalendar) retrieved;
    assertThat(retrievedHoliday.getExcludedDates(), hasItem(excludedDate));
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test
public void shouldStoreAndRetrieveCalendar() throws Exception {
    DateTime now = new DateTime();
    HolidayCalendar testCalendar = new HolidayCalendar();
    testCalendar.addExcludedDate(now.plusDays(1).toDate());

    String calendarName = id("testCalendar");
    couchdbStore.storeCalendar(calendarName, testCalendar, false, false);

    Calendar dbCalendar = couchdbStore.retrieveCalendar(calendarName);
    assertEquals(testCalendar.getClass(), dbCalendar.getClass());
    assertEquals(testCalendar.getExcludedDates(), ((HolidayCalendar) dbCalendar).getExcludedDates());
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test
public void shouldReplaceExistingCalendar() throws Exception {
    HolidayCalendar testCalendar = new HolidayCalendar();
    testCalendar.addExcludedDate(new Date());

    String calendarName = id("testCalendar");
    couchdbStore.storeCalendar(calendarName, testCalendar, false, false);
    couchdbStore.storeCalendar(calendarName, new HolidayCalendar(), true, false);

    HolidayCalendar dbCalendar = (HolidayCalendar) couchdbStore.retrieveCalendar(calendarName);
    assertEquals(0, dbCalendar.getExcludedDates().size());
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test
public void shouldNotUpdateExistingTriggers() throws Exception {
    String triggerName = id("triggerName");
    String triggerGroup = id("triggerGroup");
    String calendarName = id("testCalendar");

    couchdbStore.storeCalendar(calendarName, new HolidayCalendar(), false, false);

    final DateTime startTime = new DateTime().plusDays(1);
    OperableTrigger trigger = (SimpleTriggerImpl) newTrigger()
            .withIdentity(triggerName, triggerGroup)
            .forJob(JobKey.jobKey(id("jobName"), id("jobGroup")))
            .startAt(startTime.toDate())
            .withSchedule(simpleSchedule()
                    .withIntervalInHours(24)
                    .repeatForever())
            .modifiedByCalendar(calendarName)
            .build();
    trigger.computeFirstFireTime(couchdbStore.retrieveCalendar(calendarName));
    couchdbStore.storeTrigger(trigger, false);

    OperableTrigger triggerWithEmptyCalendar = couchdbStore.retrieveTrigger(TriggerKey.triggerKey(triggerName, triggerGroup));
    assertEquals(startTime.toDate(), triggerWithEmptyCalendar.getNextFireTime());

    HolidayCalendar testCalendar = new HolidayCalendar();
    testCalendar.addExcludedDate(startTime.toDate());
    couchdbStore.storeCalendar(calendarName, testCalendar, true, false);
    assertEquals(startTime.toDate(), triggerWithEmptyCalendar.getNextFireTime());

    couchdbStore.storeCalendar(calendarName, testCalendar, true, true);
    OperableTrigger triggerWithTestCalendar = couchdbStore.retrieveTrigger(TriggerKey.triggerKey(triggerName, triggerGroup));
    assertEquals(startTime.plusDays(1).toDate(), triggerWithTestCalendar.getNextFireTime());
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test
public void shouldRemoveCalendar() throws JobPersistenceException {
    HolidayCalendar testCalendar = new HolidayCalendar();

    String calendarName = id("testCalendar");
    couchdbStore.storeCalendar(calendarName, testCalendar, false, false);

    assertTrue(couchdbStore.removeCalendar(calendarName));

    assertNull(couchdbStore.retrieveCalendar(calendarName));
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test(expected = ObjectAlreadyExistsException.class)
public void shouldNotReplaceExistingCalendar() throws Exception {
    couchdbStore.storeCalendar("testCalendar", new HolidayCalendar(), false, false);
    couchdbStore.storeCalendar("testCalendar", new HolidayCalendar(), false, false);
}