Example #1
0
        public void TestStoreAndRetrieveTriggers()
        {
            var store = new RavenJobStore();

            store.SchedulerStarted();

            // Store jobs and triggers.
            for (int i = 0; i < 10; i++)
            {
                IJobDetail job = JobBuilder.Create <NoOpJob>().WithIdentity("job" + i).Build();
                store.StoreJob(job, true);
                SimpleScheduleBuilder schedule = SimpleScheduleBuilder.Create();
                ITrigger trigger = TriggerBuilder.Create().WithIdentity("trigger" + i).WithSchedule(schedule).ForJob(job).Build();
                store.StoreTrigger((IOperableTrigger)trigger, true);
            }
            // Retrieve job and trigger.
            for (int i = 0; i < 10; i++)
            {
                JobKey     jobKey    = JobKey.Create("job" + i);
                IJobDetail storedJob = store.RetrieveJob(jobKey);
                Assert.AreEqual(jobKey, storedJob.Key);

                TriggerKey triggerKey    = new TriggerKey("trigger" + i);
                ITrigger   storedTrigger = store.RetrieveTrigger(triggerKey);
                Assert.AreEqual(triggerKey, storedTrigger.Key);
            }
        }
        public async Task TestStoreAndRetrieveTriggers()
        {
            var store = new RavenJobStore
            {
                Database = "QuartzTest",
                Urls     = "[\"http://localhost:8080\"]"
            };
            await store.Initialize(null, fSignaler);

            await store.SchedulerStarted();

            // Store jobs and triggers.
            for (var i = 0; i < 10; i++)
            {
                var job = JobBuilder.Create <NoOpJob>().WithIdentity("job" + i).Build();
                await store.StoreJob(job, true);

                var schedule = SimpleScheduleBuilder.Create();
                var trigger  = TriggerBuilder.Create().WithIdentity("trigger" + i).WithSchedule(schedule).ForJob(job)
                               .Build();
                await store.StoreTrigger((IOperableTrigger)trigger, true);
            }

            // Retrieve job and trigger.
            for (var i = 0; i < 10; i++)
            {
                var jobKey    = JobKey.Create("job" + i);
                var storedJob = await store.RetrieveJob(jobKey);

                Assert.AreEqual(jobKey, storedJob.Key);

                var      triggerKey    = new TriggerKey("trigger" + i);
                ITrigger storedTrigger = await store.RetrieveTrigger(triggerKey);

                Assert.AreEqual(triggerKey, storedTrigger.Key);
            }
        }