diff --git a/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java b/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java index 042e69c38..dfdd84a18 100644 --- a/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java +++ b/quartz/src/main/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImpl.java @@ -389,7 +389,7 @@ public int getRepeatInterval() { * if repeatInterval is < 1 */ public void setRepeatInterval( int repeatInterval) { - if (repeatInterval < 0) { + if (repeatInterval < 1) { throw new IllegalArgumentException( "Repeat interval must be >= 1"); } diff --git a/quartz/src/test/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImplTest.java b/quartz/src/test/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImplTest.java index b2acad571..af9b3b68e 100755 --- a/quartz/src/test/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImplTest.java +++ b/quartz/src/test/java/org/quartz/impl/triggers/DailyTimeIntervalTriggerImplTest.java @@ -28,6 +28,8 @@ import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.quartz.DailyTimeIntervalScheduleBuilder; import org.quartz.DailyTimeIntervalTrigger; import org.quartz.DateBuilder; @@ -623,7 +625,7 @@ void testExtraConstructors() { assertEquals("jobName", trigger.getJobName()); assertEquals("jobGroup", trigger.getJobGroup()); assertEquals(dateOf(8, 0, 0, 1, 1, 2012), trigger.getStartTime()); - assertNull(trigger.getEndTime()); + assertNull(trigger.getEndTime()); assertEquals(new TimeOfDay(8, 0, 0), trigger.getStartTimeOfDay()); assertEquals(new TimeOfDay(17, 0, 0), trigger.getEndTimeOfDay()); assertEquals(IntervalUnit.HOUR, trigger.getRepeatIntervalUnit()); @@ -637,13 +639,20 @@ void testExtraConstructors() { assertEquals("triggerName", trigger.getName()); assertEquals("triggerGroup", trigger.getGroup()); - assertNull(trigger.getJobName()); + assertNull(trigger.getJobName()); assertEquals("DEFAULT", trigger.getJobGroup()); assertEquals(dateOf(8, 0, 0, 1, 1, 2012), trigger.getStartTime()); - assertNull(trigger.getEndTime()); + assertNull(trigger.getEndTime()); assertEquals(new TimeOfDay(8, 0, 0), trigger.getStartTimeOfDay()); assertEquals(new TimeOfDay(17, 0, 0), trigger.getEndTimeOfDay()); assertEquals(IntervalUnit.HOUR, trigger.getRepeatIntervalUnit()); assertEquals(1, trigger.getRepeatInterval()); } + + @ParameterizedTest + @ValueSource(ints = { Integer.MIN_VALUE, 0}) + void testSetRepeatIntervalWithInvalidValues(int repeatInterval) { + DailyTimeIntervalTriggerImpl trigger = new DailyTimeIntervalTriggerImpl(); + assertThrows(IllegalArgumentException.class, () -> trigger.setRepeatInterval(repeatInterval)); + } }