org.quartz.impl.calendar.HolidayCalendar Java Examples

The following examples show how to use org.quartz.impl.calendar.HolidayCalendar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StoreCalendarTest.java    From quartz-redis-jobstore with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example #2
Source File: SchedulerAdapterTest.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSchedulerCalendarNamesToXml() throws SchedulerException {
	schedulerHelper.getScheduler().addCalendar("DummyCalendar A", new HolidayCalendar(), false, false);
	schedulerHelper.getScheduler().addCalendar("DummyCalendar B", new HolidayCalendar(), false, false);

	String result = schedulerAdapter.getSchedulerCalendarNamesToXml(schedulerHelper.getScheduler()).toXML();
	assertTrue(result.contains("DummyCalendar A") && result.contains("DummyCalendar B"));
}