Ejemplo n.º 1
0
 @Test
 public void testAllAvailableManagers() throws Exception {
   final Set<String> aSupportedCountryCodes = HolidayManagerFactory.getSupportedCountryCodes();
   assertNotNull(aSupportedCountryCodes);
   assertFalse(aSupportedCountryCodes.isEmpty());
   for (final String sCountry : aSupportedCountryCodes) {
     final IHolidayManager manager = HolidayManagerFactory.getHolidayManager(sCountry);
     assertNotNull(manager);
   }
 }
Ejemplo n.º 2
0
 @Test
 public void testLevel11() throws Exception {
   final IHolidayManager m = HolidayManagerFactory.getHolidayManager("test");
   final HolidayMap holidays = m.getHolidays(2010, "level11");
   assertNotNull(holidays);
   assertDates(test_days_l11, holidays);
 }
Ejemplo n.º 3
0
 @Test
 public void testMissingCountry() throws Exception {
   try {
     HolidayManagerFactory.getHolidayManager("XXX");
     fail("Expected some IllegalArgumentException for this missing country.");
   } catch (final IllegalArgumentException e) {
   }
 }
Ejemplo n.º 4
0
 @Test
 public void testFail() {
   try {
     HolidayManagerFactory.getHolidayManager("test_fail");
     fail("Should have thrown an IllegalArgumentException.");
   } catch (final IllegalArgumentException e) {
   }
 }
Ejemplo n.º 5
0
 @Test
 public void testLevel2() throws Exception {
   final IHolidayManager m = HolidayManagerFactory.getHolidayManager("test");
   final HolidayMap holidays = m.getHolidays(2010, "level1", "level2");
   assertNotNull(holidays);
   assertEquals("Wrong number of dates.", test_days_l2.size(), holidays.size());
   assertDates(test_days_l2, holidays);
 }
Ejemplo n.º 6
0
 @Test
 public void testChronology() throws Exception {
   final IHolidayManager aMgr = HolidayManagerFactory.getHolidayManager("test");
   final HolidayMap aHolidays = aMgr.getHolidays(2010);
   for (final LocalDate aDate : aHolidays.getMap().keySet()) {
     assertEquals(
         "Wrong chronology for date " + aDate,
         PDTConfig.getDefaultChronologyUTC(),
         aDate.getChronology());
   }
 }
Ejemplo n.º 7
0
 @Test
 public void testCalendarChronology() throws Exception {
   final AbstractHolidayManager m =
       (AbstractHolidayManager) HolidayManagerFactory.getHolidayManager("test");
   final Calendar c = Calendar.getInstance();
   c.set(Calendar.YEAR, 2010);
   c.set(Calendar.MONTH, Calendar.FEBRUARY);
   c.set(Calendar.DAY_OF_MONTH, 16);
   assertFalse("This date should NOT be a holiday.", m.isHoliday(c));
   c.add(Calendar.DAY_OF_YEAR, 1);
   assertTrue("This date should be a holiday.", m.isHoliday(c));
 }
Ejemplo n.º 8
0
 @Test
 public void testBaseStructure() throws Exception {
   final AbstractHolidayManager m =
       (AbstractHolidayManager) HolidayManagerFactory.getHolidayManager("test");
   final CalendarHierarchy h = m.getHierarchy();
   assertEquals("Wrong id.", "test", h.getID());
   assertEquals("Wrong number of children on first level.", 2, h.getChildren().size());
   for (final CalendarHierarchy hi : h.getChildren().values()) {
     if (hi.getID().equalsIgnoreCase("level1")) {
       assertEquals(
           "Wrong number of children on second level of level 1.", 1, hi.getChildren().size());
     } else if (hi.getID().equalsIgnoreCase("level11")) {
       assertEquals(
           "Wrong number of children on second level of level 11.", 0, hi.getChildren().size());
     }
   }
 }
Ejemplo n.º 9
0
 @Test
 public void testIsHolidayPerformance() throws Exception {
   LocalDate date = PDTFactory.createLocalDate(2010, 1, 1);
   int count = 0;
   long sumDuration = 0;
   while (date.getYear() < 2011) {
     final StopWatch aSW = new StopWatch(true);
     final IHolidayManager m = HolidayManagerFactory.getHolidayManager("test");
     m.isHoliday(date);
     long duration = aSW.stopAndGetMillis();
     if (duration > 0) s_aLogger.info("isHoliday took " + duration + " millis.");
     aSW.start();
     date = date.plusDays(1);
     duration = aSW.stopAndGetMillis();
     count++;
     sumDuration += duration;
   }
   if (sumDuration > 0)
     s_aLogger.info("isHoliday took " + sumDuration / count + " millis average.");
 }