1. Fabian Kraemer
  2. quartz

Commits

bayard  committed a5792b9

Fixing setDaysExcluded(Calendar,boolean) so the boolean variable is actually used as per QUARTZ-589

git-svn-id: http://svn.opensymphony.com/svn/quartz/branches/quartz_1-6@71869f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 97b0677
  • Branches quartz_1-6

Comments (0)

Files changed (2)

File src/java/org/quartz/impl/calendar/AnnualCalendar.java

View file
      * </p>
      */
     public void setDayExcluded(java.util.Calendar day, boolean exclude) {
-        if (isDayExcluded(day)) {
-            return;
-        }
+        if (exclude) {
+            if (isDayExcluded(day)) {
+                return;
+            }
 
-        excludeDays.add(day);
-        dataSorted = false;
+            excludeDays.add(day);
+            dataSorted = false;
+        } else {
+            if (!isDayExcluded(day)) {
+                return;
+            }
+
+            excludeDays.remove(day);
+        }
     }
 
     /**

File src/test/java/org/quartz/AnnualCalendarTest.java

View file
 		
 		assertNotNull("Annual calendar daysExcluded property should have been set to empty ArrayList, not null.",annualCalendar.getDaysExcluded());
     }
+
+    /**
+     * Tests the parameter <code>exclude</code> in a method <code>setDaysExcluded</code>
+     * of class <code>org.quartz.impl.calendar.AnnualCalendar</code>
+     */
+    public void testExclude() {
+        AnnualCalendar annualCalendar = new AnnualCalendar();
+        Calendar day = Calendar.getInstance();
+
+        day.set(Calendar.MONTH, 10);
+        day.set(Calendar.DAY_OF_MONTH, 15);
+        annualCalendar.setDayExcluded(day, false);
+
+        assertTrue("The day 15 October is not expected to be excluded but it is", !annualCalendar.isDayExcluded(day));
+
+        day.set(Calendar.MONTH, 10);
+        day.set(Calendar.DAY_OF_MONTH, 15);
+        annualCalendar.setDayExcluded(day, true);
+
+        day.set(Calendar.MONTH, 11);
+        day.set(Calendar.DAY_OF_MONTH, 12);
+        annualCalendar.setDayExcluded(day, true);
+
+        day.set(Calendar.MONTH, 9);
+        day.set(Calendar.DAY_OF_MONTH, 1);
+        annualCalendar.setDayExcluded(day, true);
+
+        assertTrue("The day 15 October is expected to be excluded but it is not", annualCalendar.isDayExcluded(day));
+
+        day.set(Calendar.MONTH, 10);
+        day.set(Calendar.DAY_OF_MONTH, 15);
+        annualCalendar.setDayExcluded(day, false);
+
+        assertTrue("The day 15 October is not expected to be excluded but it is", !annualCalendar.isDayExcluded(day));
+    }
+
 }