public async Task TestScheduling_QuartzNet250()
        {
            Stream s = ReadJobXmlFromEmbeddedResource("QRTZNET250.xml");
            await processor.ProcessStreamAndScheduleJobs(s, mockScheduler);

            A.CallTo(() => mockScheduler.AddJob(A <IJobDetail> .That.Not.IsNull(), A <bool> .Ignored, A <bool> .That.IsEqualTo(true), A <CancellationToken> ._)).MustHaveHappened(2, Times.Exactly);
            A.CallTo(() => mockScheduler.ScheduleJob(A <ITrigger> .That.Not.IsNull(), A <CancellationToken> ._)).MustHaveHappened(2, Times.Exactly);
        }
Example #2
0
        public void TestScheduling_QuartzNet250()
        {
            Stream s = ReadJobXmlFromEmbeddedResource("QRTZNET250.xml");

            processor.ProcessStreamAndScheduleJobs(s, mockScheduler);
            mockScheduler.AssertWasCalled(x => x.AddJob(Arg <IJobDetail> .Is.NotNull, Arg <bool> .Is.Anything, Arg <bool> .Is.Equal(true)), constraints => constraints.Repeat.Twice());
            mockScheduler.AssertWasCalled(x => x.ScheduleJob(Arg <ITrigger> .Is.NotNull), constraints => constraints.Repeat.Twice());
        }
        public void TestRemoveJobTypeNotFound()
        {
            var scheduler = CreateDbBackedScheduler();

            try
            {
                string     jobName   = "testjob1";
                IJobDetail jobDetail = JobBuilder.Create <NoOpJob>()
                                       .WithIdentity(jobName, "DEFAULT")
                                       .UsingJobData("foo", "foo")
                                       .Build();
                ITrigger trigger = TriggerBuilder.Create()
                                   .WithIdentity(jobName, "DEFAULT")
                                   .WithSchedule(CronScheduleBuilder.CronSchedule("* * * * * ?"))
                                   .Build();

                scheduler.ScheduleJob(jobDetail, trigger);

                IJobDetail jobDetail2 = scheduler.GetJobDetail(jobDetail.Key);
                ITrigger   trigger2   = scheduler.GetTrigger(trigger.Key);
                Assert.That(jobDetail2.JobDataMap.GetString("foo"), Is.EqualTo("foo"));
                Assert.That(trigger2, Is.InstanceOf <ICronTrigger>());

                ModifyStoredJobType();

                XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(new SimpleTypeLoadHelper());

                // when
                processor.ProcessStreamAndScheduleJobs(ReadJobXmlFromEmbeddedResource("delete-no-job-class.xml"), scheduler);

                jobDetail2 = scheduler.GetJobDetail(jobDetail.Key);
                trigger2   = scheduler.GetTrigger(trigger.Key);
                Assert.That(trigger2, Is.Null);
                Assert.That(jobDetail2, Is.Null);

                jobDetail2 = scheduler.GetJobDetail(new JobKey("job1", "DEFAULT"));
                trigger2   = scheduler.GetTrigger(new TriggerKey("job1", "DEFAULT"));
                Assert.That(jobDetail2.JobDataMap.GetString("foo"), Is.EqualTo("bar"));
                Assert.That(trigger2, Is.InstanceOf <ISimpleTrigger>());
            }
            finally
            {
                scheduler.Shutdown(false);
            }
        }
        public void TestOverwriteJobTypeNotFound()
        {
            IScheduler scheduler = CreateDbBackedScheduler();
            try
            {
                string jobName = "job1";
                IJobDetail jobDetail = JobBuilder.Create<NoOpJob>()
                    .WithIdentity(jobName, "DEFAULT")
                    .UsingJobData("foo", "foo")
                    .Build();
                ITrigger trigger = TriggerBuilder.Create()
                    .WithIdentity(jobName, "DEFAULT")
                    .WithSchedule(CronScheduleBuilder.CronSchedule("* * * * * ?"))
                    .Build();

                scheduler.ScheduleJob(jobDetail, trigger);

                IJobDetail jobDetail2 = scheduler.GetJobDetail(jobDetail.Key);
                ITrigger trigger2 = scheduler.GetTrigger(trigger.Key);
                Assert.That(jobDetail2.JobDataMap.GetString("foo"), Is.EqualTo("foo"));
                Assert.That(trigger2, Is.InstanceOf<ICronTrigger>());

                ModifyStoredJobType();

                XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(new SimpleTypeLoadHelper());

                processor.ProcessStreamAndScheduleJobs(ReadJobXmlFromEmbeddedResource("overwrite-no-jobclass.xml"), scheduler);

                jobDetail2 = scheduler.GetJobDetail(jobDetail.Key);
                trigger2 = scheduler.GetTrigger(trigger.Key);
                Assert.That(jobDetail2.JobDataMap.GetString("foo"), Is.EqualTo("bar"));
                Assert.That(trigger2, Is.InstanceOf<ISimpleTrigger>());
            }
            finally
            {
                scheduler.Shutdown(false);
            }
        }