public async Task TestSchedulerWithTaskExecutor() { CountingTaskExecutor taskExecutor = new CountingTaskExecutor(); DummyJob.count = 0; JobDetailImpl jobDetail = new JobDetailImpl(); jobDetail.JobType = typeof(DummyJob); jobDetail.Name = "myJob"; SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = "myTrigger"; trigger.JobDetail = jobDetail; trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = 1; trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.TaskExecutor = taskExecutor; factoryObject.Triggers = new ITrigger[] { trigger }; factoryObject.JobDetails = new IJobDetail[] { jobDetail }; factoryObject.AfterPropertiesSet(); await factoryObject.Start(); await Task.Delay(TimeSpan.FromSeconds(1)); Assert.IsTrue(DummyJob.count > 0); Assert.AreEqual(DummyJob.count, taskExecutor.count); factoryObject.Dispose(); }
public async Task TestSchedulerWithRunnable() { DummyRunnable.count = 0; JobDetailImpl jobDetail = new JobDetailObject(); jobDetail.JobType = typeof(DummyRunnable); jobDetail.Name = "myJob"; SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = "myTrigger"; trigger.JobDetail = jobDetail; trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = 1; trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.Triggers = new ITrigger[] { trigger }; factoryObject.JobDetails = new IJobDetail[] { jobDetail }; factoryObject.AfterPropertiesSet(); await factoryObject.Start(); DummyRunnable.runEvent.WaitOne(1000); Assert.IsTrue(DummyRunnable.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithQuartzJobObject() { DummyJob.param = 0; DummyJob.count = 0; JobDetailImpl jobDetail = new JobDetailImpl(); jobDetail.JobType = typeof(DummyJobObject); jobDetail.Name = "myJob"; jobDetail.JobDataMap.Put("param", "10"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = "myTrigger"; trigger.JobDetail = jobDetail; trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = 1; trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.Triggers = new ITrigger[] { trigger }; factoryObject.JobDetails = new IJobDetail[] { jobDetail }; factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.AreEqual(10, DummyJobObject.param); Assert.IsTrue(DummyJobObject.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithSpringObjectJobFactoryAndRunnable() { DummyRunnable.param = 0; DummyRunnable.count = 0; JobDetailObject jobDetail = new JobDetailObject(); jobDetail.JobType = typeof(DummyRunnable); jobDetail.Name = ("myJob"); jobDetail.JobDataMap.Add("param", "10"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = ("myTrigger"); trigger.JobDetail = (jobDetail); trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = (1); trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.JobFactory = (new SpringObjectJobFactory()); factoryObject.Triggers = (new ITrigger[] { trigger }); factoryObject.JobDetails = (new IJobDetail[] { jobDetail }); factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.AreEqual(10, DummyRunnable.param); Assert.IsTrue(DummyRunnable.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithRunnable() { DummyRunnable.count = 0; JobDetail jobDetail = new JobDetailObject(); jobDetail.JobType = typeof(DummyRunnable); jobDetail.Name = ("myJob"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = ("myTrigger"); trigger.JobDetail = (jobDetail); trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = (1); trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.Triggers = (new Trigger[] { trigger }); factoryObject.JobDetails = (new JobDetail[] { jobDetail }); factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.IsTrue(DummyRunnable.count > 0); factoryObject.Dispose(); }
public async Task TestSchedulerWithSpringObjectJobFactoryAndQuartzJobObject() { DummyJobObject.param = 0; DummyJobObject.count = 0; JobDetailImpl jobDetail = new JobDetailImpl(); jobDetail.JobType = typeof(DummyJobObject); jobDetail.Name = "myJob"; jobDetail.JobDataMap.Add("param", "10"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = "myTrigger"; trigger.JobDetail = jobDetail; trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = 1; trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.JobFactory = new SpringObjectJobFactory(); factoryObject.Triggers = new ITrigger[] { trigger }; factoryObject.JobDetails = new IJobDetail[] { jobDetail }; factoryObject.AfterPropertiesSet(); await factoryObject.Start(); await Task.Delay(TimeSpan.FromSeconds(1)); Assert.AreEqual(10, DummyJobObject.param); Assert.IsTrue(DummyJobObject.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithTaskExecutor() { CountingTaskExecutor taskExecutor = new CountingTaskExecutor(); DummyJob.count = 0; JobDetailImpl jobDetail = new JobDetailImpl(); jobDetail.JobType = typeof(DummyJob); jobDetail.Name = ("myJob"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = ("myTrigger"); trigger.JobDetail = (jobDetail); trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = (1); trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.TaskExecutor = (taskExecutor); factoryObject.Triggers = (new ITrigger[] { trigger }); factoryObject.JobDetails = (new IJobDetail[] { jobDetail }); factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.IsTrue(DummyJob.count > 0); Assert.AreEqual(DummyJob.count, taskExecutor.count); factoryObject.Dispose(); }
public async Task TestSchedulerWithSpringObjectJobFactoryAndJobSchedulingData() { DummyJob.param = 0; DummyJob.count = 0; SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.JobFactory = new SpringObjectJobFactory(); factoryObject.JobSchedulingDataLocation = "job-scheduling-data.xml"; // TODO bean.ResourceLoader = (new FileSystemResourceLoader()); factoryObject.AfterPropertiesSet(); await factoryObject.Start(); Thread.Sleep(500); Assert.AreEqual(10, DummyJob.param); Assert.IsTrue(DummyJob.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithSpringObjectJobFactoryAndParamMismatchNotIgnored() { DummyJob.param = 0; DummyJob.count = 0; JobDetailImpl jobDetail = new JobDetailImpl(); jobDetail.JobType = typeof(DummyJob); jobDetail.Name = "myJob"; jobDetail.JobDataMap.Add("para", "10"); jobDetail.JobDataMap.Add("ignoredParam", "10"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = "myTrigger"; trigger.JobDetail = jobDetail; trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = 1; trigger.AfterPropertiesSet(); SchedulerFactoryObject bean = new SchedulerFactoryObject(); SpringObjectJobFactory jobFactory = new SpringObjectJobFactory(); jobFactory.IgnoredUnknownProperties = new String[] { "ignoredParam" }; bean.JobFactory = jobFactory; bean.Triggers = new ITrigger[] { trigger }; bean.JobDetails = new IJobDetail[] { jobDetail }; bean.AfterPropertiesSet(); Thread.Sleep(500); Assert.AreEqual(0, DummyJob.param); Assert.IsTrue(DummyJob.count == 0); bean.Dispose(); }
private void MethodInvokingConcurrency(bool concurrent) { // Test the concurrency flag. // Method invoking job with two triggers. // If the concurrent flag is false, the triggers are NOT allowed // to interfere with each other. TestMethodInvokingTask task1 = new TestMethodInvokingTask(); MethodInvokingJobDetailFactoryObject mijdfb = new MethodInvokingJobDetailFactoryObject(); // set the concurrency flag! mijdfb.Concurrent = concurrent; mijdfb.ObjectName = "myJob1"; mijdfb.TargetObject = task1; mijdfb.TargetMethod = "doWait"; mijdfb.AfterPropertiesSet(); IJobDetail jobDetail1 = (IJobDetail)mijdfb.GetObject(); SimpleTriggerObject trigger0 = new SimpleTriggerObject(); trigger0.ObjectName = "myTrigger1"; trigger0.JobDetail = jobDetail1; trigger0.StartDelay = TimeSpan.FromMilliseconds(0); trigger0.RepeatInterval = TimeSpan.FromMilliseconds(1); trigger0.RepeatCount = 1; trigger0.AfterPropertiesSet(); SimpleTriggerObject trigger1 = new SimpleTriggerObject(); trigger1.ObjectName = "myTrigger1"; trigger1.JobDetail = jobDetail1; trigger1.StartDelay = TimeSpan.FromMilliseconds(1000L); trigger1.RepeatInterval = TimeSpan.FromMilliseconds(1); trigger1.RepeatCount = 1; trigger1.AfterPropertiesSet(); SchedulerFactoryObject schedulerFactoryObject = new SchedulerFactoryObject(); schedulerFactoryObject.JobDetails = new IJobDetail[] { jobDetail1 }; schedulerFactoryObject.Triggers = new ITrigger[] { trigger1, trigger0 }; schedulerFactoryObject.AfterPropertiesSet(); // ok scheduler is set up... let's wait for like 4 seconds try { Thread.Sleep(4000); } catch (ThreadInterruptedException) { // fall through } if (concurrent) { Assert.AreEqual(2, task1.counter); task1.Stop(); // we're done, both jobs have ran, let's call it a day return; } else { Assert.AreEqual(1, task1.counter); task1.Stop(); // we need to check whether or not the test succeed with non-concurrent jobs } try { Thread.Sleep(4000); } catch (ThreadInterruptedException) { // fall through } task1.Stop(); Assert.AreEqual(2, task1.counter); // Although we're destroying the scheduler, it does seem to keep things in memory: // When executing both tests (concurrent and non-concurrent), the second test always // fails. schedulerFactoryObject.Dispose(); }
/*public void TestMethodInvocationWithConcurrency() { methodInvokingConcurrency(true); }*/ // We can't test both since Quartz somehow seems to keep things in memory // enable both and one of them will fail (order doesn't matter). /*public void TestMethodInvocationWithoutConcurrency() { methodInvokingConcurrency(false); }*/ private void methodInvokingConcurrency(bool concurrent) { // Test the concurrency flag. // Method invoking job with two triggers. // If the concurrent flag is false, the triggers are NOT allowed // to interfere with each other. TestMethodInvokingTask task1 = new TestMethodInvokingTask(); MethodInvokingJobDetailFactoryObject mijdfb = new MethodInvokingJobDetailFactoryObject(); // set the concurrency flag! mijdfb.Concurrent = (concurrent); mijdfb.ObjectName = ("myJob1"); mijdfb.TargetObject = (task1); mijdfb.TargetMethod = ("doWait"); mijdfb.AfterPropertiesSet(); JobDetail jobDetail1 = (JobDetail) mijdfb.GetObject(); SimpleTriggerObject trigger0 = new SimpleTriggerObject(); trigger0.ObjectName = ("myTrigger1"); trigger0.JobDetail = (jobDetail1); trigger0.StartDelay = TimeSpan.FromMilliseconds(0); trigger0.RepeatInterval = TimeSpan.FromMilliseconds(1); trigger0.RepeatCount = (1); trigger0.AfterPropertiesSet(); SimpleTriggerObject trigger1 = new SimpleTriggerObject(); trigger1.ObjectName = ("myTrigger1"); trigger1.JobDetail = (jobDetail1); trigger1.StartDelay = TimeSpan.FromMilliseconds(1000L); trigger1.RepeatInterval = TimeSpan.FromMilliseconds(1); trigger1.RepeatCount = (1); trigger1.AfterPropertiesSet(); SchedulerFactoryObject schedulerFactoryObject = new SchedulerFactoryObject(); schedulerFactoryObject.JobDetails = (new JobDetail[] {jobDetail1}); schedulerFactoryObject.Triggers = (new Trigger[] {trigger1, trigger0}); schedulerFactoryObject.AfterPropertiesSet(); // ok scheduler is set up... let's wait for like 4 seconds try { Thread.Sleep(4000); } catch (ThreadInterruptedException) { // fall through } if (concurrent) { Assert.AreEqual(2, task1.counter); task1.Stop(); // we're done, both jobs have ran, let's call it a day return; } else { Assert.AreEqual(1, task1.counter); task1.Stop(); // we need to check whether or not the test succeed with non-concurrent jobs } try { Thread.Sleep(4000); } catch (ThreadInterruptedException) { // fall through } task1.Stop(); Assert.AreEqual(2, task1.counter); // Although we're destroying the scheduler, it does seem to keep things in memory: // When executing both tests (concurrent and non-concurrent), the second test always // fails. schedulerFactoryObject.Dispose(); }
public void TestSchedulerWithTaskExecutor() { CountingTaskExecutor taskExecutor = new CountingTaskExecutor(); DummyJob.count = 0; JobDetail jobDetail = new JobDetail(); jobDetail.JobType = typeof (DummyJob); ; jobDetail.Name = ("myJob"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = ("myTrigger"); trigger.JobDetail = (jobDetail); trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = (1); trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.TaskExecutor = (taskExecutor); factoryObject.Triggers = (new Trigger[] {trigger}); factoryObject.JobDetails = (new JobDetail[] {jobDetail}); factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.IsTrue(DummyJob.count > 0); Assert.AreEqual(DummyJob.count, taskExecutor.count); factoryObject.Dispose(); }
public void TestSchedulerWithSpringObjectJobFactoryAndRunnable() { DummyRunnable.param = 0; DummyRunnable.count = 0; JobDetail jobDetail = new JobDetailObject(); jobDetail.JobType = typeof (DummyRunnable); jobDetail.Name = ("myJob"); jobDetail.JobDataMap.Add("param", "10"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = ("myTrigger"); trigger.JobDetail = (jobDetail); trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = (1); trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.JobFactory = (new SpringObjectJobFactory()); factoryObject.Triggers = (new Trigger[] {trigger}); factoryObject.JobDetails = (new JobDetail[] {jobDetail}); factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.AreEqual(10, DummyRunnable.param); Assert.IsTrue(DummyRunnable.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithSpringObjectJobFactoryAndParamMismatchNotIgnored() { DummyJob.param = 0; DummyJob.count = 0; JobDetail jobDetail = new JobDetail(); jobDetail.JobType = typeof(DummyJob); jobDetail.Name = ("myJob"); jobDetail.JobDataMap.Add("para", "10"); jobDetail.JobDataMap.Add("ignoredParam", "10"); SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = ("myTrigger"); trigger.JobDetail = (jobDetail); trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = (1); trigger.AfterPropertiesSet(); SchedulerFactoryObject bean = new SchedulerFactoryObject(); SpringObjectJobFactory jobFactory = new SpringObjectJobFactory(); jobFactory.IgnoredUnknownProperties = (new String[] {"ignoredParam"}); bean.JobFactory = (jobFactory); bean.Triggers = (new Trigger[] {trigger}); bean.JobDetails = (new JobDetail[] {jobDetail}); bean.AfterPropertiesSet(); Thread.Sleep(500); Assert.AreEqual(0, DummyJob.param); Assert.IsTrue(DummyJob.count == 0); bean.Dispose(); }
public void TestSchedulerWithSpringObjectJobFactoryAndJobSchedulingData() { DummyJob.param = 0; DummyJob.count = 0; SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.JobFactory = new SpringObjectJobFactory(); factoryObject.JobSchedulingDataLocation = "job-scheduling-data.xml"; // TODO bean.ResourceLoader = (new FileSystemResourceLoader()); factoryObject.AfterPropertiesSet(); factoryObject.Start(); Thread.Sleep(500); Assert.AreEqual(10, DummyJob.param); Assert.IsTrue(DummyJob.count > 0); factoryObject.Dispose(); }
public void TestSchedulerWithRunnable() { DummyRunnable.count = 0; JobDetail jobDetail = new JobDetailObject(); jobDetail.JobType = typeof (DummyRunnable); jobDetail.Name = "myJob"; SimpleTriggerObject trigger = new SimpleTriggerObject(); trigger.Name = "myTrigger"; trigger.JobDetail = jobDetail; trigger.StartDelay = TimeSpan.FromMilliseconds(1); trigger.RepeatInterval = TimeSpan.FromMilliseconds(500); trigger.RepeatCount = 1; trigger.AfterPropertiesSet(); SchedulerFactoryObject factoryObject = new SchedulerFactoryObject(); factoryObject.Triggers = new Trigger[] {trigger}; factoryObject.JobDetails = new JobDetail[] {jobDetail}; factoryObject.AfterPropertiesSet(); factoryObject.Start(); DummyRunnable.runEvent.WaitOne(500); Assert.IsTrue(DummyRunnable.count > 0); factoryObject.Dispose(); }
public void TestAfterPropertiesSet_Defaults() { factory.AfterPropertiesSet(); }
public void TestAfterPropertiesSet_Defaults() { factory.AfterPropertiesSet(); TestSchedulerFactory.Mockery.ReplayAll(); }