public void RecoveryTriggerKeyAndGroup()
		{
			IJobExecutionContext ctx = new JobExecutionContextImpl(null, TestUtil.NewMinimalRecoveringTriggerFiredBundle(), null);
			ctx.MergedJobDataMap[SchedulerConstants.FailedJobOriginalTriggerName] = "originalTriggerName";
			ctx.MergedJobDataMap[SchedulerConstants.FailedJobOriginalTriggerGroup] = "originalTriggerGroup";
			var recoveringTriggerKey = ctx.RecoveringTriggerKey;
			Assert.That(recoveringTriggerKey.Name, Is.EqualTo("originalTriggerName"));
			Assert.That(recoveringTriggerKey.Group, Is.EqualTo("originalTriggerGroup"));
		}
        public async Task TestTriggerFiredMessage()
        {
            // arrange
            A.CallTo(() => mockLog.Log(LogLevel.Info, null, null, null)).Returns(true);

            ITrigger t = TriggerBuilder.Create()
                .WithSchedule(SimpleScheduleBuilder.Create())
                .Build();

            IJobExecutionContext ctx = new JobExecutionContextImpl(
                null,
                TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger) t),
                null);

            // act
            await plugin.TriggerFired(t, ctx);

            // assert
            A.CallTo(() => mockLog.Log(A<LogLevel>.That.IsEqualTo(LogLevel.Info), A<Func<string>>.That.IsNull(), A<Exception>.That.IsNull(), A<object[]>.That.Not.IsNull())).MustHaveHappened();
        }
        public void TestTriggerCompleteMessage()
        {
            // arrange
            mockLog.Stub(log => log.IsInfoEnabled).Return(true);

            ITrigger t = TriggerBuilder.Create()
                                        .WithSchedule(SimpleScheduleBuilder.Create())
                                        .Build();

            IJobExecutionContext ctx = new JobExecutionContextImpl(
                null,
                TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger) t),
                null);

            // act
            plugin.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob);

            // assert
            mockLog.AssertWasCalled(log => log.Info(Arg<string>.Is.NotNull));
        }
 public void TestToString()
 {
     // QRTZNET-48
     IJobExecutionContext ctx = new JobExecutionContextImpl(null, TestUtil.NewMinimalTriggerFiredBundle(), null);
     ctx.ToString();
 }
Beispiel #5
0
 /// <summary>
 /// Passivates this instance.
 /// </summary>
 public virtual void Passivate()
 {
     jec = null;
     qs = null;
 }
Beispiel #6
0
        /// <summary>
        /// Initializes the job execution context with given scheduler and bundle.
        /// </summary>
        /// <param name="sched">The scheduler.</param>
        public virtual void Initialize(QuartzScheduler sched)
        {
            qs = sched;

            IJob job;
            IJobDetail jobDetail = firedTriggerBundle.JobDetail;

            try
            {
                job = sched.JobFactory.NewJob(firedTriggerBundle, scheduler);
            }
            catch (SchedulerException se)
            {
                sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.Key), se);
                throw;
            }
            catch (Exception e)
            {
                SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "Problem instantiating type '{0}'", jobDetail.JobType.FullName), e);
                sched.NotifySchedulerListenersError(string.Format(CultureInfo.InvariantCulture, "An error occured instantiating job to be executed. job= '{0}'", jobDetail.Key), se);
                throw se;
            }

            jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);
        }
        protected virtual IJobExecutionContext CreateJobExecutionContext()
        {
            IOperableTrigger t = new SimpleTriggerImpl("name", "group");
            TriggerFiredBundle firedBundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), t);
            IJobExecutionContext ctx = new JobExecutionContextImpl(null,  firedBundle, null);

            return ctx;
        }
Beispiel #8
0
        /// <summary>
        /// Initializes the job execution context with given scheduler and bundle.
        /// </summary>
        /// <param name="sched">The scheduler.</param>
        public virtual async Task Initialize(QuartzScheduler sched)
        {
            qs = sched;

            IJob job;
            IJobDetail jobDetail = firedTriggerBundle.JobDetail;

            try
            {
                job = sched.JobFactory.NewJob(firedTriggerBundle, scheduler);
            }
            catch (SchedulerException se)
            {
                await sched.NotifySchedulerListenersError($"An error occurred instantiating job to be executed. job= '{jobDetail.Key}'", se).ConfigureAwait(false);
                throw;
            }
            catch (Exception e)
            {
                SchedulerException se = new SchedulerException($"Problem instantiating type '{jobDetail.JobType.FullName}'", e);
                await sched.NotifySchedulerListenersError($"An error occurred instantiating job to be executed. job= '{jobDetail.Key}'", se).ConfigureAwait(false);
                throw se;
            }

            jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);
        }