/// <summary> /// Initializes the job execution context with given scheduler and bundle. /// </summary> /// <param name="sched">The scheduler.</param> /// <param name="cancellationToken">The cancellation instruction.</param> public virtual async Task Initialize( QuartzScheduler sched, CancellationToken cancellationToken = default(CancellationToken)) { 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, cancellationToken).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, cancellationToken).ConfigureAwait(false); throw se; } jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job); }
/// <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); }
private static IJobExecutionContext CreateMinimalJobExecutionContext() { IScheduler sched = A.Fake <IScheduler>(); IJobExecutionContext ctx = new JobExecutionContextImpl(sched, ConstructMinimalTriggerFiredBundle(), null); return(ctx); }
public void TestToString() { // QRTZNET-48 IJobExecutionContext ctx = new JobExecutionContextImpl(null, TestUtil.NewMinimalTriggerFiredBundle(), null); ctx.ToString(); }
private static IJobExecutionContext CreateMinimalJobExecutionContext() { MockRepository repo = new MockRepository(); IScheduler sched = (IScheduler)repo.DynamicMock(typeof(IScheduler)); IJobExecutionContext ctx = new JobExecutionContextImpl(sched, ConstructMinimalTriggerFiredBundle(), null); return(ctx); }
protected virtual ICancellableJobExecutionContext CreateJobExecutionContext() { IOperableTrigger t = new SimpleTriggerImpl("name", "group"); TriggerFiredBundle firedBundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), t); ICancellableJobExecutionContext ctx = new JobExecutionContextImpl(null, firedBundle, null); return(ctx); }
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 TestTriggerCompleteMessage() { ITrigger t = TriggerBuilder.Create() .WithSchedule(SimpleScheduleBuilder.Create()) .Build(); IJobExecutionContext ctx = new JobExecutionContextImpl( null, TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob), (IOperableTrigger)t), null); await plugin.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob); Assert.That(plugin.InfoMessages.Count, Is.EqualTo(1)); }
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 async Task TestTriggerCompleteMessage() { // 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.TriggerComplete(t, ctx, SchedulerInstruction.ReExecuteJob); // 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)); }
/// <summary> /// Passivates this instance. /// </summary> public virtual void Passivate() { jec = null; qs = null; }
private static IJobExecutionContext CreateMinimalJobExecutionContext() { MockRepository repo = new MockRepository(); IScheduler sched = (IScheduler)repo.DynamicMock(typeof(IScheduler)); IJobExecutionContext ctx = new JobExecutionContextImpl(sched, ConstructMinimalTriggerFiredBundle(), null); return ctx; }
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; }