Exemplo n.º 1
0
        public void TestTriggerStates()
        {
            Trigger trigger =
                new SimpleTrigger("trigger1", "triggerGroup1", fJobDetail.Name, fJobDetail.Group,
                                  DateTime.Now.AddSeconds(100), DateTime.Now.AddSeconds(200), 2, TimeSpan.FromSeconds(2));

            trigger.ComputeFirstFireTimeUtc(null);
            Assert.AreEqual(TriggerState.None, fJobStore.GetTriggerState(null, trigger.Name, trigger.Group));
            fJobStore.StoreTrigger(null, trigger, false);
            Assert.AreEqual(TriggerState.Normal, fJobStore.GetTriggerState(null, trigger.Name, trigger.Group));

            fJobStore.PauseTrigger(null, trigger.Name, trigger.Group);
            Assert.AreEqual(TriggerState.Paused, fJobStore.GetTriggerState(null, trigger.Name, trigger.Group));

            fJobStore.ResumeTrigger(null, trigger.Name, trigger.Group);
            Assert.AreEqual(TriggerState.Normal, fJobStore.GetTriggerState(null, trigger.Name, trigger.Group));

            trigger = fJobStore.AcquireNextTrigger(null,
                                                   trigger.GetNextFireTimeUtc().Value.AddSeconds(10));
            Assert.IsNotNull(trigger);
            fJobStore.ReleaseAcquiredTrigger(null, trigger);
            trigger = fJobStore.AcquireNextTrigger(null,
                                                   trigger.GetNextFireTimeUtc().Value.AddSeconds(10));
            Assert.IsNotNull(trigger);
            Assert.IsNull(fJobStore.AcquireNextTrigger(null,
                                                       trigger.GetNextFireTimeUtc().Value.AddSeconds(10)));
        }
Exemplo n.º 2
0
        public void TestRemoveCalendarWhenTriggersPresent()
        {
            // QRTZNET-29

            Trigger trigger = new SimpleTrigger("trigger1", "triggerGroup1", fJobDetail.Name, fJobDetail.Group,
                                                DateTime.Now.AddSeconds(100), DateTime.Now.AddSeconds(200), 2, TimeSpan.FromSeconds(2));

            trigger.ComputeFirstFireTimeUtc(null);
            ICalendar cal = new MonthlyCalendar();

            fJobStore.StoreTrigger(null, trigger, false);
            fJobStore.StoreCalendar(null, "cal", cal, false, true);

            fJobStore.RemoveCalendar(null, "cal");
        }
Exemplo n.º 3
0
        public void TestGetFireTimeAfter_WithCalendar()
        {
            DailyCalendar dailyCalendar = new DailyCalendar("1:20", "14:50");
            SimpleTrigger simpleTrigger = new SimpleTrigger();

            simpleTrigger.RepeatInterval = TimeSpan.FromMilliseconds(10);
            simpleTrigger.RepeatCount    = 1;
            DateTime neverFireTime = TriggerUtils.GetEvenMinuteDateBefore(dailyCalendar.GetTimeRangeStartingTimeUtc(DateTime.Now));

            simpleTrigger.StartTimeUtc = neverFireTime;

            simpleTrigger.ComputeFirstFireTimeUtc(dailyCalendar);
            NullableDateTime fireTimeAfter = simpleTrigger.GetNextFireTimeUtc();

            Assert.IsNull(fireTimeAfter);
        }
Exemplo n.º 4
0
        public void TestAcquireNextTrigger()
        {
            DateTime d        = DateTime.UtcNow;
            Trigger  trigger1 =
                new SimpleTrigger("trigger1", "triggerGroup1", fJobDetail.Name,
                                  fJobDetail.Group, d.AddSeconds(200),
                                  d.AddSeconds(200), 2, TimeSpan.FromSeconds(2));
            Trigger trigger2 =
                new SimpleTrigger("trigger2", "triggerGroup1", fJobDetail.Name,
                                  fJobDetail.Group, d.AddSeconds(-100),
                                  d.AddSeconds(20), 2, TimeSpan.FromSeconds(2));
            Trigger trigger3 =
                new SimpleTrigger("trigger1", "triggerGroup2", fJobDetail.Name,
                                  fJobDetail.Group, d.AddSeconds(100),
                                  d.AddSeconds(200), 2, TimeSpan.FromSeconds(2));

            trigger1.ComputeFirstFireTimeUtc(null);
            trigger2.ComputeFirstFireTimeUtc(null);
            trigger3.ComputeFirstFireTimeUtc(null);
            fJobStore.StoreTrigger(null, trigger1, false);
            fJobStore.StoreTrigger(null, trigger2, false);
            fJobStore.StoreTrigger(null, trigger3, false);

            Trigger t = fJobStore.AcquireNextTrigger(null, d.AddMilliseconds(10));

            Assert.IsNull(t);
            Assert.AreEqual(
                trigger2,
                fJobStore.AcquireNextTrigger(null, trigger1.GetNextFireTimeUtc().Value.AddSeconds(10)));
            Assert.AreEqual(
                trigger3,
                fJobStore.AcquireNextTrigger(null, trigger1.GetNextFireTimeUtc().Value.AddSeconds(10)));
            Assert.AreEqual(
                trigger1,
                fJobStore.AcquireNextTrigger(null, trigger1.GetNextFireTimeUtc().Value.AddSeconds(10)));
            Assert.IsNull(
                fJobStore.AcquireNextTrigger(null, trigger1.GetNextFireTimeUtc().Value.AddSeconds(10)));

            // because of trigger2
            Assert.AreEqual(1, fSignaler.fMisfireCount);

            // release trigger3
            fJobStore.ReleaseAcquiredTrigger(null, trigger3);
            Assert.AreEqual(
                trigger3,
                fJobStore.AcquireNextTrigger(null, trigger1.GetNextFireTimeUtc().Value.AddSeconds(10)));
        }