Пример #1
0
        public void TestSchedulerFactoryObjectWithListeners()
        {
            IJobFactory jobFactory = new AdaptableJobFactory();

            IScheduler scheduler = (IScheduler)mockery.CreateMock(typeof(IScheduler));

            ISchedulerListener schedulerListener     = new TestSchedulerListener();
            IJobListener       globalJobListener     = new TestJobListener();
            IJobListener       jobListener           = new TestJobListener();
            ITriggerListener   globalTriggerListener = new TestTriggerListener();
            ITriggerListener   triggerListener       = new TestTriggerListener();

            Expect.Call(scheduler.JobFactory = (jobFactory));
            scheduler.AddSchedulerListener(schedulerListener);
            scheduler.AddGlobalJobListener(globalJobListener);
            scheduler.AddJobListener(jobListener);
            scheduler.AddGlobalTriggerListener(globalTriggerListener);
            scheduler.AddTriggerListener(triggerListener);
            scheduler.Start();
            scheduler.Shutdown(false);

            mockery.ReplayAll();

            SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler);

            schedulerFactoryObject.JobFactory             = (jobFactory);
            schedulerFactoryObject.SchedulerListeners     = (new ISchedulerListener[] { schedulerListener });
            schedulerFactoryObject.GlobalJobListeners     = (new IJobListener[] { globalJobListener });
            schedulerFactoryObject.JobListeners           = (new IJobListener[] { jobListener });
            schedulerFactoryObject.GlobalTriggerListeners = (new ITriggerListener[] { globalTriggerListener });
            schedulerFactoryObject.TriggerListeners       = (new ITriggerListener[] { triggerListener });
            try
            {
                schedulerFactoryObject.AfterPropertiesSet();
                schedulerFactoryObject.Start();
            }
            finally
            {
                schedulerFactoryObject.Dispose();
            }

            mockery.VerifyAll();
        }
        public void TestManagementOfJobListeners()
        {
            TestJobListener tl1 = new TestJobListener("tl1");
            TestJobListener tl2 = new TestJobListener("tl2");

            ListenerManagerImpl manager = new ListenerManagerImpl();

            // test adding listener without matcher
            manager.AddJobListener(tl1);
            Assert.AreEqual(1, manager.GetJobListeners().Count, "Unexpected size of listener list");

            // test adding listener with matcher
            manager.AddJobListener(tl2, GroupMatcher <JobKey> .GroupEquals("foo"));
            Assert.AreEqual(2, manager.GetJobListeners().Count, "Unexpected size of listener list");

            // test removing a listener
            manager.RemoveJobListener("tl1");
            Assert.AreEqual(1, manager.GetJobListeners().Count, "Unexpected size of listener list");

            // test adding a matcher
            manager.AddJobListenerMatcher("tl2", NameMatcher <JobKey> .NameContains("foo"));
            Assert.AreEqual(2, manager.GetJobListenerMatchers("tl2").Count, "Unexpected size of listener's matcher list");
        }
        public void TestManagementOfJobListeners()
        {
            TestJobListener tl1 = new TestJobListener("tl1");
            TestJobListener tl2 = new TestJobListener("tl2");

            ListenerManagerImpl manager = new ListenerManagerImpl();

            // test adding listener without matcher
            manager.AddJobListener(tl1);
            Assert.AreEqual(1, manager.GetJobListeners().Count, "Unexpected size of listener list");

            // test adding listener with matcher
            manager.AddJobListener(tl2, GroupMatcher<JobKey>.GroupEquals("foo"));
            Assert.AreEqual(2, manager.GetJobListeners().Count, "Unexpected size of listener list");

            // test removing a listener
            manager.RemoveJobListener("tl1");
            Assert.AreEqual(1, manager.GetJobListeners().Count, "Unexpected size of listener list");

            // test adding a matcher
            manager.AddJobListenerMatcher("tl2", NameMatcher<JobKey>.NameContains("foo"));
            Assert.AreEqual(2, manager.GetJobListenerMatchers("tl2").Count, "Unexpected size of listener's matcher list");
        }
Пример #4
0
        public void TestSchedulerFactoryObjectWithListeners()
        {
            IJobFactory jobFactory = new AdaptableJobFactory();

            IScheduler scheduler = MockRepository.GenerateMock<IScheduler>();

            ISchedulerListener schedulerListener = new TestSchedulerListener();
            IJobListener globalJobListener = new TestJobListener();
            IJobListener jobListener = new TestJobListener();
            ITriggerListener globalTriggerListener = new TestTriggerListener();
            ITriggerListener triggerListener = new TestTriggerListener();

            Expect.Call(scheduler.JobFactory = (jobFactory));
            scheduler.AddSchedulerListener(schedulerListener);
            scheduler.AddGlobalJobListener(globalJobListener);
            scheduler.AddJobListener(jobListener);
            scheduler.AddGlobalTriggerListener(globalTriggerListener);
            scheduler.AddTriggerListener(triggerListener);
            scheduler.Start();
            scheduler.Shutdown(false);

            SchedulerFactoryObject schedulerFactoryObject = new TestSchedulerFactoryObject(scheduler);

            schedulerFactoryObject.JobFactory = (jobFactory);
            schedulerFactoryObject.SchedulerListeners = (new ISchedulerListener[] {schedulerListener});
            schedulerFactoryObject.GlobalJobListeners = (new IJobListener[] {globalJobListener});
            schedulerFactoryObject.JobListeners = (new IJobListener[] {jobListener});
            schedulerFactoryObject.GlobalTriggerListeners = (new ITriggerListener[] {globalTriggerListener});
            schedulerFactoryObject.TriggerListeners = (new ITriggerListener[] {triggerListener});
            try
            {
                schedulerFactoryObject.AfterPropertiesSet();
                schedulerFactoryObject.Start();
            }
            finally
            {
                schedulerFactoryObject.Dispose();
            }
        }