微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,false);
    couchdbStore.storeCalendar(calendarName,new HolidayCalendar(),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,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,false);
    assertEquals(startTime.toDate(),triggerWithEmptyCalendar.getNextFireTime());

    couchdbStore.storeCalendar(calendarName,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,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",false);
    couchdbStore.storeCalendar("testCalendar",false);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。