Update of /cvsroot/springnet/Spring.Net.Integration/projects/Spring.Scheduling.Quartz/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv23397/Scheduling/Quartz
Modified Files:
AdaptableJobFactoryTest.cs JobDetailObjectTest.cs
SchedulerFactoryObjectTest.cs
Log Message:
Some fixes to tests, added small Quartz Integration example
Index: SchedulerFactoryObjectTest.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net.Integration/projects/Spring.Scheduling.Quartz/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SchedulerFactoryObjectTest.cs 12 Sep 2007 18:39:33 -0000 1.1
--- SchedulerFactoryObjectTest.cs 14 Sep 2007 12:56:10 -0000 1.2
***************
*** 35,38 ****
--- 35,39 ----
public class SchedulerFactoryObjectTest
{
+ private MockRepository mockery = null;
private SchedulerFactoryObject factory;
***************
*** 41,44 ****
--- 42,46 ----
{
factory = new SchedulerFactoryObject();
+ TestSchedulerFactory.Mockery.BackToRecordAll();
}
***************
*** 47,50 ****
--- 49,53 ----
{
factory.AfterPropertiesSet();
+ TestSchedulerFactory.Mockery.ReplayAll();
}
***************
*** 54,57 ****
--- 57,61 ----
factory.JobFactory = null;
factory.AfterPropertiesSet();
+ TestSchedulerFactory.Mockery.ReplayAll();
}
***************
*** 60,64 ****
{
// set expectations
- TestSchedulerFactory.Mockery.BackToRecordAll();
TestSchedulerFactory.MockScheduler.JobFactory = null;
LastCall.IgnoreArguments();
--- 64,67 ----
***************
*** 68,73 ****
factory.AutoStartup = false;
factory.AfterPropertiesSet();
-
- TestSchedulerFactory.Mockery.VerifyAll();
}
--- 71,74 ----
***************
*** 75,82 ****
public void TestAfterPropertiesSet_AutoStartup()
{
! TestSchedulerFactory.Mockery.BackToRecordAll();
! // set expectations
! TestSchedulerFactory.MockScheduler.JobFactory = null;
! LastCall.IgnoreArguments();
TestSchedulerFactory.MockScheduler.Start();
TestSchedulerFactory.Mockery.ReplayAll();
--- 76,81 ----
public void TestAfterPropertiesSet_AutoStartup()
{
! InitForAfterPropertiesSetTest();
!
TestSchedulerFactory.MockScheduler.Start();
TestSchedulerFactory.Mockery.ReplayAll();
***************
*** 85,90 ****
factory.AutoStartup = true;
factory.AfterPropertiesSet();
! TestSchedulerFactory.Mockery.VerifyAll();
}
--- 84,186 ----
factory.AutoStartup = true;
factory.AfterPropertiesSet();
+ }
! [Test]
! public void TestAfterPropertiesSet_AddListeners()
! {
! mockery = new MockRepository();
! InitForAfterPropertiesSetTest();
!
! factory.SchedulerListeners = new ISchedulerListener[] { (ISchedulerListener)mockery.CreateMock(typeof(ISchedulerListener)) };
! TestSchedulerFactory.MockScheduler.AddSchedulerListener(null);
! LastCall.IgnoreArguments();
!
! factory.GlobalJobListeners = new IJobListener[] { (IJobListener)mockery.CreateMock(typeof(IJobListener)) };
! TestSchedulerFactory.MockScheduler.AddGlobalJobListener(null);
! LastCall.IgnoreArguments();
!
! factory.JobListeners = new IJobListener[] { (IJobListener)mockery.CreateMock(typeof(IJobListener)) };
! TestSchedulerFactory.MockScheduler.AddJobListener(null);
! LastCall.IgnoreArguments();
!
! factory.GlobalTriggerListeners = new ITriggerListener[] { (ITriggerListener)mockery.CreateMock(typeof(ITriggerListener)) };
! TestSchedulerFactory.MockScheduler.AddGlobalTriggerListener(null);
! LastCall.IgnoreArguments();
!
! factory.TriggerListeners = new ITriggerListener[] { (ITriggerListener)mockery.CreateMock(typeof(ITriggerListener)) };
! TestSchedulerFactory.MockScheduler.AddTriggerListener(null);
! LastCall.IgnoreArguments();
!
! TestSchedulerFactory.Mockery.ReplayAll();
! mockery.ReplayAll();
! factory.AfterPropertiesSet();
! }
!
! [Test]
! public void TestAfterPropertiesSet_Calendars()
! {
! mockery = new MockRepository();
! InitForAfterPropertiesSetTest();
!
! const string calendarName = "calendar";
! ICalendar cal = (ICalendar) mockery.CreateMock(typeof (ICalendar));
! Hashtable calTable = new Hashtable();
! calTable[calendarName] = cal;
! factory.Calendars = calTable;
! TestSchedulerFactory.MockScheduler.AddCalendar(calendarName, cal, true, true);
!
! TestSchedulerFactory.Mockery.ReplayAll();
! mockery.ReplayAll();
! factory.AfterPropertiesSet();
! }
!
! [Test]
! public void TestAfterPropertiesSet_Trigger_TriggerExists()
! {
! mockery = new MockRepository();
! InitForAfterPropertiesSetTest();
!
! const string TRIGGER_NAME = "trigName";
! const string TRIGGER_GROUP = "trigGroup";
! SimpleTrigger trigger = new SimpleTrigger(TRIGGER_NAME, TRIGGER_GROUP);
! factory.Triggers = new Trigger[] { trigger };
!
! Expect.Call(TestSchedulerFactory.MockScheduler.GetTrigger(TRIGGER_NAME, TRIGGER_GROUP)).Return(trigger);
!
! TestSchedulerFactory.Mockery.ReplayAll();
! mockery.ReplayAll();
! factory.AfterPropertiesSet();
! }
!
! [Test]
! public void TestAfterPropertiesSet_Trigger_TriggerDoesntExist()
! {
! mockery = new MockRepository();
! InitForAfterPropertiesSetTest();
!
! const string TRIGGER_NAME = "trigName";
! const string TRIGGER_GROUP = "trigGroup";
! SimpleTrigger trigger = new SimpleTrigger(TRIGGER_NAME, TRIGGER_GROUP);
! factory.Triggers = new Trigger[] { trigger };
!
! Expect.Call(TestSchedulerFactory.MockScheduler.GetTrigger(TRIGGER_NAME, TRIGGER_GROUP)).Return(null);
! TestSchedulerFactory.MockScheduler.ScheduleJob(trigger);
! LastCall.IgnoreArguments().Return(DateTime.UtcNow);
!
!
! TestSchedulerFactory.Mockery.ReplayAll();
! mockery.ReplayAll();
! factory.AfterPropertiesSet();
!
! }
!
!
! private void InitForAfterPropertiesSetTest()
! {
! factory.AutoStartup = false;
! // set expectations
! factory.SchedulerFactoryType = typeof(TestSchedulerFactory);
! TestSchedulerFactory.MockScheduler.JobFactory = null;
! LastCall.IgnoreArguments();
}
***************
*** 93,97 ****
{
// set expectations
- TestSchedulerFactory.Mockery.BackToRecordAll();
TestSchedulerFactory.MockScheduler.JobFactory = null;
LastCall.IgnoreArguments();
--- 189,192 ----
***************
*** 102,111 ****
factory.SchedulerFactoryType = typeof(TestSchedulerFactory);
factory.AutoStartup = true;
! factory.StartupDelay = 5;
factory.AfterPropertiesSet();
- Thread.Sleep(TimeSpan.FromSeconds(6));
-
- TestSchedulerFactory.Mockery.VerifyAll();
}
--- 197,204 ----
factory.SchedulerFactoryType = typeof(TestSchedulerFactory);
factory.AutoStartup = true;
! factory.StartupDelay = 2;
factory.AfterPropertiesSet();
+ Thread.Sleep(TimeSpan.FromSeconds(3));
}
***************
*** 114,118 ****
{
// set expectations
- TestSchedulerFactory.Mockery.BackToRecordAll();
TestSchedulerFactory.MockScheduler.JobFactory = null;
LastCall.IgnoreArguments();
--- 207,210 ----
***************
*** 124,128 ****
factory.AfterPropertiesSet();
factory.Start();
- TestSchedulerFactory.Mockery.VerifyAll();
}
--- 216,219 ----
***************
*** 131,135 ****
{
// set expectations
- TestSchedulerFactory.Mockery.BackToRecordAll();
TestSchedulerFactory.MockScheduler.JobFactory = null;
LastCall.IgnoreArguments();
--- 222,225 ----
***************
*** 141,145 ****
factory.AfterPropertiesSet();
factory.Stop();
- TestSchedulerFactory.Mockery.VerifyAll();
}
--- 231,234 ----
***************
*** 148,152 ****
{
factory.AfterPropertiesSet();
! IScheduler sched = (IScheduler) factory.GetObject();
Assert.IsNotNull(sched, "scheduler was null");
}
--- 237,242 ----
{
factory.AfterPropertiesSet();
! TestSchedulerFactory.Mockery.ReplayAll();
! IScheduler sched = (IScheduler)factory.GetObject();
Assert.IsNotNull(sched, "scheduler was null");
}
***************
*** 156,160 ****
public void TestSchedulerFactoryType_InvalidType()
{
! factory.SchedulerFactoryType = typeof (SchedulerFactoryObjectTest);
}
--- 246,251 ----
public void TestSchedulerFactoryType_InvalidType()
{
! TestSchedulerFactory.Mockery.ReplayAll();
! factory.SchedulerFactoryType = typeof(SchedulerFactoryObjectTest);
}
***************
*** 162,168 ****
--- 253,270 ----
public void TestSchedulerFactoryType_ValidType()
{
+ TestSchedulerFactory.Mockery.ReplayAll();
factory.SchedulerFactoryType = typeof(StdSchedulerFactory);
}
+ [TearDown]
+ public void TearDown()
+ {
+ TestSchedulerFactory.Mockery.VerifyAll();
+ if (mockery != null)
+ {
+ mockery.VerifyAll();
+ }
+ }
+
}
Index: AdaptableJobFactoryTest.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net.Integration/projects/Spring.Scheduling.Quartz/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/AdaptableJobFactoryTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AdaptableJobFactoryTest.cs 12 Sep 2007 18:39:33 -0000 1.2
--- AdaptableJobFactoryTest.cs 14 Sep 2007 12:56:10 -0000 1.3
***************
*** 24,94 ****
using Spring.Scheduling.Quartz;
! namespace Spring
{
! /// <summary>
! /// Tests for <see cref="AdaptableJobFactory" />.
! /// </summary>
/// <author>Marko Lahma (.NET)</author>
[TestFixture]
! public class AdaptableJobFactoryTest
! {
! private AdaptableJobFactory jobFactory;
! [SetUp]
! public void SetUp()
! {
! jobFactory = new AdaptableJobFactory();
! }
! [Test]
! public void TestNewJob_IncompatibleJob()
! {
! try
! {
! // this actually fails already in Quartz level
TriggerFiredBundle bundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(object));
! jobFactory.NewJob(bundle);
! Assert.Fail("Created job which was not an IJob");
! }
! catch (ArgumentException)
! {
! // ok
! }
! catch (SchedulerException)
! {
! // ok
! }
! catch (Exception)
! {
! Assert.Fail("Got exception that was not instance of SchedulerException or ArgumentException");
! }
! }
! [Test]
! public void TestNewJob_ThreadStartJob()
! {
// TODO ThreadStart is not the way to go
! }
!
! [Test]
! public void TestNewJob_NormalIJob()
! {
! TriggerFiredBundle bundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob));
! IJob job = jobFactory.NewJob(bundle);
! Assert.IsNotNull(job, "Returned job was null");
! }
- }
! internal class NoOpThreadStartJob : NoOpJob
! {
! public void Execute()
! {
! Execute(null);
! }
! }
! }
--- 24,93 ----
using Spring.Scheduling.Quartz;
! namespace Spring.Scheduling.Quartz
{
! /// <summary>
! /// Tests for <see cref="AdaptableJobFactory" />.
! /// </summary>
/// <author>Marko Lahma (.NET)</author>
[TestFixture]
! public class AdaptableJobFactoryTest
! {
! private AdaptableJobFactory jobFactory;
! [SetUp]
! public void SetUp()
! {
! jobFactory = new AdaptableJobFactory();
! }
! [Test]
! public void TestNewJob_IncompatibleJob()
! {
! try
! {
! // this actually fails already in Quartz level
TriggerFiredBundle bundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(object));
! jobFactory.NewJob(bundle);
! Assert.Fail("Created job which was not an IJob");
! }
! catch (ArgumentException)
! {
! // ok
! }
! catch (SchedulerException)
! {
! // ok
! }
! catch (Exception)
! {
! Assert.Fail("Got exception that was not instance of SchedulerException or ArgumentException");
! }
! }
! [Test]
! public void TestNewJob_ThreadStartJob()
! {
// TODO ThreadStart is not the way to go
! }
+ [Test]
+ public void TestNewJob_NormalIJob()
+ {
+ TriggerFiredBundle bundle = TestUtil.CreateMinimalFiredBundleWithTypedJobDetail(typeof(NoOpJob));
+ IJob job = jobFactory.NewJob(bundle);
+ Assert.IsNotNull(job, "Returned job was null");
+ }
! }
! internal class NoOpThreadStartJob : NoOpJob
! {
! public void Execute()
! {
! Execute(null);
! }
! }
! }
\ No newline at end of file
Index: JobDetailObjectTest.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net.Integration/projects/Spring.Scheduling.Quartz/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** JobDetailObjectTest.cs 12 Sep 2007 18:39:33 -0000 1.1
--- JobDetailObjectTest.cs 14 Sep 2007 12:56:10 -0000 1.2
***************
*** 89,92 ****
--- 89,93 ----
const string objectName = "springJobDetailObject";
jobDetail.ObjectName = objectName;
+ jobDetail.Group = null;
jobDetail.AfterPropertiesSet();
Assert.AreEqual(SchedulerConstants.DEFAULT_GROUP, jobDetail.Group, "Groups differ");
|