From e76b73225e5b488ec7071a1ba22131856c29ca6e Mon Sep 17 00:00:00 2001 From: lahma Date: Fri, 6 Nov 2009 05:52:13 +0000 Subject: [PATCH] Fixing Quartz integration code comments and setting warnaserror = true in build file --- .../Spring.Scheduling.Quartz.2008.csproj | 2 +- .../Spring.Scheduling.Quartz.build | 2 +- .../Quartz/AdaptableJobFactoryTest.cs | 12 ++ .../Quartz/CronTriggerObjectTest.cs | 10 +- .../Scheduling/Quartz/JobDetailObjectTest.cs | 31 ++++- ...ethodInvokingJobDetailFactoryObjectTest.cs | 14 +- .../Quartz/MethodInvokingJobTest.cs | 29 +++- .../Scheduling/Quartz/QuartzSupportTests.cs | 126 +++++++++++++++++- .../Scheduling/Quartz/QuartzTestObject.cs | 14 ++ .../Quartz/SchedulerFactoryObjectTest.cs | 84 +++++++++++- .../Quartz/SimpleTriggerObjectTest.cs | 21 ++- .../Quartz/SpringObjectJobFactoryTest.cs | 24 +++- .../Quartz/TestMethodInvokingTask.cs | 13 ++ .../Scheduling/Quartz/TriggerObjectTest.cs | 28 +++- ...Spring.Scheduling.Quartz.Tests.2008.csproj | 3 + 15 files changed, 394 insertions(+), 19 deletions(-) diff --git a/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2008.csproj b/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2008.csproj index f45eb061..e6f8e2ad 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2008.csproj +++ b/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2008.csproj @@ -19,7 +19,7 @@ TRACE;DEBUG;NET_2_0 prompt 4 - Spring.Scheduling.Quartz.xml + ..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz\Debug\Spring.Scheduling.Quartz.XML true diff --git a/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.build b/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.build index b0980263..6b569a3d 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.build +++ b/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.build @@ -8,7 +8,7 @@ --> + /// Test setup. + /// [SetUp] public void SetUp() { jobFactory = new AdaptableJobFactory(); } + /// + /// Tests job creation. + /// [Test] public void TestNewJob_IncompatibleJob() { @@ -64,12 +70,18 @@ namespace Spring.Scheduling.Quartz } } + /// + /// Tests job creation. + /// [Test] public void TestNewJob_ThreadStartJob() { // TODO ThreadStart is not the way to go } + /// + /// Tests job creation. + /// [Test] public void TestNewJob_NormalIJob() { diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/CronTriggerObjectTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/CronTriggerObjectTest.cs index 366e9dbf..c1bed77c 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/CronTriggerObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/CronTriggerObjectTest.cs @@ -32,6 +32,9 @@ namespace Spring.Scheduling.Quartz { private CronTriggerObject cronTrigger; + /// + /// Test setup. + /// [SetUp] public void SetUp() { @@ -54,7 +57,9 @@ namespace Spring.Scheduling.Quartz } } - + /// + /// Tests that JobDetail defaults values as expected in AfterPropertiesSet. + /// [Test] public override void TestAfterPropertiesSet_JobDetailGiven() { @@ -67,6 +72,9 @@ namespace Spring.Scheduling.Quartz Assert.AreSame(jd, cronTrigger.JobDetail, "job details weren't same"); } + /// + /// Tests that JobDetail maps job data map as expected. + /// [Test] public void TestJobDataAsMap() { diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs index 5a0549b9..3fea2651 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs @@ -35,12 +35,18 @@ namespace Spring.Scheduling.Quartz { private JobDetailObject jobDetail; + /// + /// Test setup. + /// [SetUp] public void SetUp() { jobDetail = new JobDetailObject(); } + /// + /// Tests job detail's property behavior. + /// [Test] [ExpectedException(typeof(ArgumentException))] public void TestJobType_Null() @@ -48,6 +54,9 @@ namespace Spring.Scheduling.Quartz jobDetail.JobType = null; } + /// + /// Tests job detail's property behavior. + /// [Test] public void TestJobType_NonIJob() { @@ -55,6 +64,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(typeof(object), jobDetail.JobType, "JobDetail did not create same type as expected"); } + /// + /// Tests job detail's property behavior. + /// [Test] public void TestJobType_IJob() { @@ -63,7 +75,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(jobDetail.JobType, CORRECT_IJOB, "JobDetail did not register correct job type"); } - + /// + /// Tests job detail's property behavior. + /// [Test] [ExpectedException(typeof(ArgumentException))] public void TestJobDataAsMap_Null() @@ -71,6 +85,9 @@ namespace Spring.Scheduling.Quartz jobDetail.JobDataAsMap = null; } + /// + /// Tests job detail's property behavior. + /// [Test] public void TestJobDataAsMap_ProperValues() { @@ -83,6 +100,9 @@ namespace Spring.Scheduling.Quartz CollectionAssert.AreEqual(values.Keys, jobDetail.JobDataMap.Keys, "JobDataMap values not equal"); } + /// + /// Tests job detail's property behavior. + /// [Test] public void TestAfterPropertiesSet_Defaults() { @@ -94,6 +114,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(objectName, jobDetail.Name, "Names differ"); } + /// + /// Tests job detail's property behavior. + /// [Test] public void TestAfterPropertiesSet_CustomNameAndGroup() { @@ -108,6 +131,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(jobDetailName, jobDetail.Name, "Names differ"); } + /// + /// Tests job detail's property behavior. + /// [Test] public void TestAfterPropertiesSet_ApplicationContextJobDataKeySetWithApplicationContext() { @@ -122,6 +148,9 @@ namespace Spring.Scheduling.Quartz Assert.AreSame(ctx, jobDetail.JobDataMap[key], "ApplicationContext was not set to job data map"); } + /// + /// Tests job detail's property behavior. + /// [Test] [ExpectedException(typeof(ArgumentException))] public void TestAfterPropertiesSet_ApplicationContextJobDataKeySetWithoutApplicationContext() diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobDetailFactoryObjectTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobDetailFactoryObjectTest.cs index 1be2228a..266e550f 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobDetailFactoryObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobDetailFactoryObjectTest.cs @@ -21,7 +21,7 @@ using Quartz; namespace Spring.Scheduling.Quartz { /// - /// + /// Unit tests for MethodInvokingJobDetailFactoryObject. /// /// Marko Lahma (.NET) [TestFixture] @@ -30,6 +30,9 @@ namespace Spring.Scheduling.Quartz private const string FACTORY_NAME = "springObjectFactory"; private MethodInvokingJobDetailFactoryObject factory; + /// + /// Setup for the test. + /// [SetUp] public void SetUp() { @@ -39,6 +42,9 @@ namespace Spring.Scheduling.Quartz factory.TargetObject = new InvocationCountingJob(); } + /// + /// Tests JobDetail retrieval and it's set properties. + /// [Test] public void TestGetObject_MinimalDefaults() { @@ -51,6 +57,9 @@ namespace Spring.Scheduling.Quartz Assert.IsTrue(jd.Volatile, "job was not volatile"); } + /// + /// Tests JobDetail retrieval and it's set properties. + /// [Test] public void TestGetObject_ConcurrentJob() { @@ -61,6 +70,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(jd.JobType, typeof(StatefulMethodInvokingJob), "factory did not create stateful method invoking job"); } + /// + /// Tests JobDetail retrieval and it's set properties. + /// [Test] public void TestGetObject_TriggerListenersSet() { diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs index cc4d813f..94d3cfc2 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs @@ -30,7 +30,7 @@ using Spring.Objects.Support; namespace Spring.Scheduling.Quartz { /// - /// + /// Tests for MethodInvokingJob. /// /// Marko Lahma (.NET) [TestFixture] @@ -38,12 +38,18 @@ namespace Spring.Scheduling.Quartz { private MethodInvokingJob methodInvokingJob; + /// + /// Test setup. + /// [SetUp] public void SetUp() { methodInvokingJob = new MethodInvokingJob(); } + /// + /// Test method invoke via execute. + /// [Test] [ExpectedException(typeof(ArgumentException))] public void TestMethodInvoker_SetWithNull() @@ -51,6 +57,9 @@ namespace Spring.Scheduling.Quartz methodInvokingJob.MethodInvoker = null; } + /// + /// Test method invoke via execute. + /// [Test] [ExpectedException(typeof(JobExecutionException))] public void TestMethodInvocation_NullMethodInvokder() @@ -58,6 +67,9 @@ namespace Spring.Scheduling.Quartz methodInvokingJob.Execute(CreateMinimalJobExecutionContext()); } + /// + /// Test method invoke via execute. + /// [Test] public void TestMethodInvoker_MethodSetCorrectly() { @@ -71,6 +83,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(1, job.CounterValue, "Job was not invoked once"); } + /// + /// Test method invoke via execute. + /// [Test] public void TestMethodInvoker_MethodSetCorrectlyThrowsException() { @@ -92,6 +107,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(1, job.CounterValue, "Job was not invoked once"); } + /// + /// Test method invoke via execute. + /// [Test] public void TestMethodInvoker_PrivateMethod() { @@ -130,11 +148,17 @@ namespace Spring.Scheduling.Quartz { private int counter; + /// + /// Increments method invoke counter. + /// public void Invoke() { Interlocked.Increment(ref counter); } + /// + /// Throws exception after incrementing counter. + /// public void InvokeAndThrowException() { Interlocked.Increment(ref counter); @@ -145,6 +169,9 @@ namespace Spring.Scheduling.Quartz { } + /// + /// Invocation count. + /// public int CounterValue { get { return counter; } diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzSupportTests.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzSupportTests.cs index 17f13b7d..80a77ad9 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzSupportTests.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzSupportTests.cs @@ -43,24 +43,36 @@ namespace Spring.Scheduling.Quartz { private MockRepository mockery; + /// + /// Test setup. + /// [SetUp] public void SetUp() { mockery = new MockRepository(); } + /// + /// Executes parametrized test. + /// [Test] public void TestSchedulerFactoryObject() { DoTestSchedulerFactoryObject(false, false); } + /// + /// Executes parametrized test. + /// [Test] public void TestSchedulerFactoryObjectWithExplicitJobDetail() { DoTestSchedulerFactoryObject(true, false); } + /// + /// Executes parametrized test. + /// [Test] [Ignore("Requires change to MethodInvoker for overriding target object and type")] public void TestSchedulerFactoryObjectWithPrototypeJob() @@ -155,12 +167,18 @@ namespace Spring.Scheduling.Quartz mockery.VerifyAll(); } + /// + /// Executes parametrized test. + /// [Test] public void TestSchedulerFactoryObjectWithExistingJobs() { DoTestSchedulerFactoryObjectWithExistingJobs(false); } + /// + /// Executes parametrized test. + /// [Test] public void TestSchedulerFactoryObjectWithOverwriteExistingJobs() { @@ -245,12 +263,18 @@ namespace Spring.Scheduling.Quartz mockery.VerifyAll(); } + /// + /// Executes parametrized test. + /// [Test] public void TestSchedulerFactoryObjectWithExistingJobsAndRaceCondition() { DoTestSchedulerFactoryObjectWithExistingJobsAndRaceCondition(false); } - + + /// + /// Executes parametrized test. + /// [Test] public void TestSchedulerFactoryObjectWithOverwriteExistingJobsAndRaceCondition() { @@ -344,6 +368,8 @@ namespace Spring.Scheduling.Quartz mockery.VerifyAll(); } + /// + /// [Test] public void TestSchedulerFactoryObjectWithListeners() { @@ -478,6 +504,8 @@ namespace Spring.Scheduling.Quartz schedulerFactoryObject.Dispose(); } + /// + /// [Test] public void TestSchedulerFactoryObjectWithPlainQuartzObjects() { @@ -551,6 +579,8 @@ namespace Spring.Scheduling.Quartz mockery.VerifyAll(); } + /// + /// [Test] public void TestSchedulerFactoryObjectWithApplicationContext() { @@ -587,6 +617,8 @@ namespace Spring.Scheduling.Quartz mockery.VerifyAll(); } + /// + /// [Test] public void TestJobDetailObjectWithApplicationContext() { @@ -607,6 +639,8 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(ac, jobDetail.JobDataMap.Get("appCtx")); } + /// + /// [Test] public void TestMethodInvokingJobDetailFactoryObjectWithListenerNames() { @@ -624,6 +658,8 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(names, result); } + /// + /// [Test] public void TestJobDetailObjectWithListenerNames() { @@ -634,6 +670,8 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(names, result); } + /// + /// [Test] public void TestCronTriggerObjectWithListenerNames() { @@ -644,6 +682,8 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(names, result); } + /// + /// [Test] public void TestSimpleTriggerObjectWithListenerNames() { @@ -654,6 +694,8 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(names, result); } + /// + /// [Test] public void TestSchedulerWithTaskExecutor() { @@ -686,6 +728,8 @@ namespace Spring.Scheduling.Quartz bean.Dispose(); } + /// + /// [Test] public void TestSchedulerWithRunnable() { @@ -714,6 +758,8 @@ namespace Spring.Scheduling.Quartz bean.Dispose(); } + /// + /// [Test] public void TestSchedulerWithQuartzJobObject() { @@ -745,6 +791,8 @@ namespace Spring.Scheduling.Quartz sfo.Dispose(); } + /// + /// [Test] public void TestSchedulerWithSpringObjectJobFactory() { @@ -778,6 +826,8 @@ namespace Spring.Scheduling.Quartz bean.Dispose(); } + /// + /// [Test] public void TestSchedulerWithSpringObjectJobFactoryAndParamMismatchNotIgnored() { @@ -813,6 +863,8 @@ namespace Spring.Scheduling.Quartz bean.Dispose(); } + /// + /// [Test] public void TestSchedulerWithSpringObjectJobFactoryAndRunnable() { @@ -845,6 +897,8 @@ namespace Spring.Scheduling.Quartz bean.Dispose(); } + /// + /// [Test] public void TestSchedulerWithSpringObjectJobFactoryAndQuartzJobObject() { @@ -877,6 +931,9 @@ namespace Spring.Scheduling.Quartz bean.Dispose(); } + /// + /// + /// [Test] public void TestSchedulerWithSpringObjectJobFactoryAndJobSchedulingData() { @@ -934,6 +991,9 @@ namespace Spring.Scheduling.Quartz } } + /// + /// Tests calling of services with method invoke. + /// [Test] public void TestWithTwoAnonymousMethodInvokingJobDetailFactoryObjects() { @@ -955,6 +1015,9 @@ namespace Spring.Scheduling.Quartz } } + /// + /// Tests how quartz triggers and services interact. + /// [Test] public void TestSchedulerAccessorObject() { @@ -976,6 +1039,9 @@ namespace Spring.Scheduling.Quartz } } + /// + /// Tests how scheduler is exposed to application context. + /// [Test] public void TestSchedulerRepositoryExposure() { @@ -1073,10 +1139,17 @@ namespace Spring.Scheduling.Quartz } + /// + /// Simple task executor that tracks invocation count. + /// public class CountingTaskExecutor : ITaskExecutor { internal int count; + /// + /// Executes task instance. + /// + /// public void Execute(ThreadStart task) { count++; @@ -1084,12 +1157,18 @@ namespace Spring.Scheduling.Quartz } } - + /// + /// Simple test job object. + /// public class DummyJobObject : QuartzJobObject { internal static int param; internal static int count; + /// + /// Sets parameter value. + /// + /// public void SetParam(int value) { if (param > 0) @@ -1099,19 +1178,29 @@ namespace Spring.Scheduling.Quartz param = value; } + /// + /// Execute the actual job. The job data map will already have been + /// applied as object property values by execute. The contract is + /// exactly the same as for the standard Quartz execute method. + /// protected override void ExecuteInternal(JobExecutionContext jobExecutionContext) { count++; } } - + /// + /// Simple thread runnable. + /// public class DummyRunnable : IThreadRunnable { internal static int param; - internal static int count; + /// + /// Sets param value. + /// + /// public void SetParam(int value) { if (param > 0) @@ -1121,6 +1210,9 @@ namespace Spring.Scheduling.Quartz param = value; } + /// + /// Runs thread runnable. + /// public void Run() { count++; @@ -1128,12 +1220,18 @@ namespace Spring.Scheduling.Quartz } } + /// + /// A simple job that tracks invocation count and allows setting of a simple parameter. + /// public class DummyJob : IJob { internal static int param; - internal static int count; + /// + /// Sets param value. + /// + /// public void SetParam(int value) { if (param > 0) @@ -1143,21 +1241,39 @@ namespace Spring.Scheduling.Quartz param = value; } + /// + /// Executes this job instance. + /// + /// public void Execute(JobExecutionContext jobExecutionContext) { count++; } } + /// + /// Subclass of SchedulerFactoryObject for testing purposes. + /// public class TestSchedulerFactoryObject : SchedulerFactoryObject { private readonly IScheduler sched; + /// + /// Creates new instance of this class. + /// + /// public TestSchedulerFactoryObject(IScheduler sched) { this.sched = sched; } + /// + /// Creates a scheduler actually returning the scheduler this intance + /// was instantiated with. + /// + /// + /// + /// protected override IScheduler CreateScheduler(ISchedulerFactory schedulerFactory, String schedulerName) { return sched; diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzTestObject.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzTestObject.cs index 5c6161ad..87522ab2 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzTestObject.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/QuartzTestObject.cs @@ -1,6 +1,8 @@ namespace Spring.Scheduling.Quartz { /// + /// A simple test object for Quartz.NET to run + /// that simulates imports and exports. /// /// Rob Harrop public class QuartzTestObject @@ -8,21 +10,33 @@ namespace Spring.Scheduling.Quartz private int exportCount; private int importCount; + /// + /// Executes a fake import and increments counter. + /// public void DoImport() { ++importCount; } + /// + /// Executes a fake export and increments counter. + /// public void DoExport() { ++exportCount; } + /// + /// Tells how many times import has been done. + /// public int ImportCount { get { return importCount; } } + /// + /// Tells how many times export has been done. + /// public int ExportCount { get { return exportCount; } diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs index 28983766..a6a61908 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs @@ -34,7 +34,7 @@ using Spring.Core.IO; namespace Spring.Scheduling.Quartz { /// - /// + /// Tests for SchedulerFactoryObject. /// /// Marko Lahma (.NET) [TestFixture] @@ -45,6 +45,9 @@ namespace Spring.Scheduling.Quartz private MockRepository mockery; private SchedulerFactoryObject factory; + /// + /// Test setup. + /// [SetUp] public void SetUp() { @@ -57,6 +60,9 @@ namespace Spring.Scheduling.Quartz .Repeat.Any(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_Defaults() { @@ -64,6 +70,9 @@ namespace Spring.Scheduling.Quartz TestSchedulerFactory.Mockery.ReplayAll(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_NullJobFactory() { @@ -72,6 +81,9 @@ namespace Spring.Scheduling.Quartz TestSchedulerFactory.Mockery.ReplayAll(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_NoAutoStartup() { @@ -85,6 +97,9 @@ namespace Spring.Scheduling.Quartz factory.AfterPropertiesSet(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_AutoStartup() { @@ -98,6 +113,9 @@ namespace Spring.Scheduling.Quartz factory.AfterPropertiesSet(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_AddListeners() { @@ -129,6 +147,9 @@ namespace Spring.Scheduling.Quartz factory.AfterPropertiesSet(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_Calendars() { @@ -147,6 +168,9 @@ namespace Spring.Scheduling.Quartz factory.AfterPropertiesSet(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_Trigger_TriggerExists() { @@ -165,6 +189,9 @@ namespace Spring.Scheduling.Quartz factory.AfterPropertiesSet(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_Trigger_TriggerDoesntExist() { @@ -197,6 +224,9 @@ namespace Spring.Scheduling.Quartz LastCall.IgnoreArguments(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_AutoStartup_WithDelay() { @@ -212,6 +242,9 @@ namespace Spring.Scheduling.Quartz factory.AfterPropertiesSet(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestStart() { @@ -227,6 +260,9 @@ namespace Spring.Scheduling.Quartz factory.Start(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestStop() { @@ -242,6 +278,9 @@ namespace Spring.Scheduling.Quartz factory.Stop(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestGetObject() { @@ -251,6 +290,9 @@ namespace Spring.Scheduling.Quartz Assert.IsNotNull(sched, "scheduler was null"); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] [ExpectedException(typeof(ArgumentException))] public void TestSchedulerFactoryType_InvalidType() @@ -259,6 +301,9 @@ namespace Spring.Scheduling.Quartz factory.SchedulerFactoryType = typeof(SchedulerFactoryObjectTest); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestSchedulerFactoryType_ValidType() { @@ -266,6 +311,9 @@ namespace Spring.Scheduling.Quartz factory.SchedulerFactoryType = typeof(StdSchedulerFactory); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestInitSchedulerFactory_MinimalDefaults() { @@ -276,6 +324,9 @@ namespace Spring.Scheduling.Quartz m_InitSchedulerFactory.Invoke(factory, new object[] { factoryToPass }); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestInitSchedulerFactory_ConfigLocationReadingShouldPreserverExtraEqualsMarksAndTrimKeysAndValues() { @@ -308,6 +359,9 @@ ConnectionStringKey+ " = " + ConnectionStringValue + Environment.NewLine + } + /// + /// Cleans this test instance. + /// [TearDown] public void TearDown() { @@ -328,6 +382,9 @@ ConnectionStringKey+ " = " + ConnectionStringValue + Environment.NewLine + } } + /// + /// ISchedulerFactory implementation for testing purposes. + /// public class TestSchedulerFactory : ISchedulerFactory { private static readonly MockRepository mockery = new MockRepository(); @@ -338,41 +395,66 @@ ConnectionStringKey+ " = " + ConnectionStringValue + Environment.NewLine + mockScheduler = (IScheduler) mockery.CreateMock(typeof (IScheduler)); } + /// + /// MockRepository intance. + /// public static MockRepository Mockery { get { return mockery; } } + /// + /// The mocked scheduler. + /// public static IScheduler MockScheduler { get { return mockScheduler; } } + /// + /// + /// public IScheduler GetScheduler() { return mockScheduler; } + /// + /// + /// + /// public IScheduler GetScheduler(string schedName) { return mockScheduler; } + /// + /// public ICollection AllSchedulers { get { return new ArrayList(); } } } + /// + /// Scheduler factory that supports property interception. + /// public class InterceptingStdSChedulerFactory : StdSchedulerFactory { private NameValueCollection properties; + /// + /// Initializes the factory. + /// + /// public override void Initialize(NameValueCollection props) { this.properties = props; } + /// + /// Return propeties given to this factory at initialization time. + /// public NameValueCollection Properties { get { return properties; } diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SimpleTriggerObjectTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SimpleTriggerObjectTest.cs index 46553142..fdf11df7 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SimpleTriggerObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SimpleTriggerObjectTest.cs @@ -33,6 +33,9 @@ namespace Spring.Scheduling.Quartz { private SimpleTriggerObject simpleTrigger; + /// + /// Test setup. + /// [SetUp] public void SetUp() { @@ -55,6 +58,9 @@ namespace Spring.Scheduling.Quartz } } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public override void TestAfterPropertiesSet_Defaults() { @@ -62,6 +68,9 @@ namespace Spring.Scheduling.Quartz base.TestAfterPropertiesSet_Defaults(); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public override void TestAfterPropertiesSet_ValuesGiven() { @@ -69,7 +78,10 @@ namespace Spring.Scheduling.Quartz simpleTrigger.AfterPropertiesSet(); base.TestAfterPropertiesSet_ValuesGiven(); } - + + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestAfterPropertiesSet_StartDelayGiven() { @@ -80,7 +92,9 @@ namespace Spring.Scheduling.Quartz AssertDateTimesEqualityWithAllowedDelta(startTime.AddMilliseconds(START_DELAY), simpleTrigger.StartTimeUtc, 1000); } - + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public override void TestAfterPropertiesSet_JobDetailGiven() { @@ -93,6 +107,9 @@ namespace Spring.Scheduling.Quartz Assert.AreSame(jd, simpleTrigger.JobDetail, "job details weren't same"); } + /// + /// Tests AfterPropertiesSet behavior. + /// [Test] public void TestJobDataAsMap() { diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SpringObjectJobFactoryTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SpringObjectJobFactoryTest.cs index 7fe40a1f..5c5920f8 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SpringObjectJobFactoryTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SpringObjectJobFactoryTest.cs @@ -25,7 +25,7 @@ using Quartz.Spi; namespace Spring.Scheduling.Quartz { /// - /// + /// Unit tests for SpringObjectJobFactory. /// /// Marko Lahma (.NET) [TestFixture] @@ -33,12 +33,18 @@ namespace Spring.Scheduling.Quartz { private SpringObjectJobFactory factory; + /// + /// Test setup. + /// [SetUp] public void SetUp() { factory = new SpringObjectJobFactory(); } + /// + /// Tests job instane creation. + /// [Test] public void TestCreateJobInstance_SimpleDefaults() { @@ -49,6 +55,9 @@ namespace Spring.Scheduling.Quartz Assert.IsNotNull(job, "Created job was null"); } + /// + /// Tests job instane creation. + /// [Test] public void TestCreateJobInstance_SchedulerContextGiven() { @@ -65,6 +74,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(123, job.Number, "integer injection failed"); } + /// + /// Tests job instane creation. + /// [Test] public void TestCreateJobInstance_IgnoredProperties() { @@ -82,18 +94,26 @@ namespace Spring.Scheduling.Quartz } + /// + /// Test job object that has injectable properties + /// public class InjectableJob : NoOpJob { private int number; private string foo; - + /// + /// Simple int property. + /// public int Number { get { return number; } set { number = value; } } + /// + /// Simple string property. + /// public string Foo { get { return foo; } diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TestMethodInvokingTask.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TestMethodInvokingTask.cs index c41551c0..8ce4110f 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TestMethodInvokingTask.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TestMethodInvokingTask.cs @@ -20,18 +20,28 @@ namespace Spring.Scheduling.Quartz { /// + /// Simple test task. /// /// Juergen Hoeller public class TestMethodInvokingTask { + /// + /// Counter for DoSomething and DoWait calls. + /// public int counter; private readonly object lockObject = new object(); + /// + /// Simple test method. + /// public void DoSomething() { counter++; } + /// + /// Waits until stop is called. + /// public void DoWait() { counter++; @@ -49,6 +59,9 @@ namespace Spring.Scheduling.Quartz } } + /// + /// Informs test object that stop should be called. + /// public void Stop() { lock (lockObject) diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TriggerObjectTest.cs b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TriggerObjectTest.cs index 873e9e2d..047cd79c 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TriggerObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TriggerObjectTest.cs @@ -31,14 +31,22 @@ namespace Spring.Scheduling.Quartz public abstract class TriggerObjectTest { private Trigger trigger; + /// + /// Constant name for tested triggers. + /// protected const string TRIGGER_NAME = "trigger"; - + /// + /// TriggerObject under test. + /// protected Trigger Trigger { set { trigger = value; } } + /// + /// Tests that TriggerObject defaults values as expected in AfterPropertiesSet. + /// [Test] public virtual void TestAfterPropertiesSet_Defaults() { @@ -51,6 +59,9 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(SchedulerConstants.DefaultGroup, trigger.JobGroup, "trigger job group was not default"); } + /// + /// Tests that TriggerObject defaults values as expected in AfterPropertiesSet. + /// [Test] public virtual void TestAfterPropertiesSet_ValuesGiven() { @@ -67,7 +78,9 @@ namespace Spring.Scheduling.Quartz AssertDateTimesEqualityWithAllowedDelta(START_TIME, trigger.StartTimeUtc, 1000); } - + /// + /// Tests that TriggerObject defaults values as expected in AfterPropertiesSet. + /// [Test] public virtual void TestAfterPropertiesSet_JobDetailGiven() { @@ -79,8 +92,11 @@ namespace Spring.Scheduling.Quartz Assert.AreEqual(jobGroup, trigger.JobGroup, "trigger job group was not from job detail"); } + /// + /// Tests that TriggerObject defaults values as expected in AfterPropertiesSet. + /// [Test] - public virtual void TestTriggerListenerNames_Valis() + public virtual void TestTriggerListenerNames_Valid() { ((IInitializingObject)trigger).AfterPropertiesSet(); @@ -89,6 +105,12 @@ namespace Spring.Scheduling.Quartz CollectionAssert.AreEqual(LISTENER_NAMES, trigger.TriggerListenerNames, "Trigger listeners were not equal"); } + /// + /// Tests whether two datetimes are close enough. + /// + /// + /// + /// protected static void AssertDateTimesEqualityWithAllowedDelta(DateTime d1, DateTime d2, int allowedDeltaInMilliseconds) { int diffInMillis = (int) Math.Abs((d1 - d2).TotalMilliseconds); diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2008.csproj b/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2008.csproj index 0ab438d4..fe0e52b5 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2008.csproj +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2008.csproj @@ -19,6 +19,9 @@ TRACE;DEBUG;NET_2_0 prompt 4 + + + true pdbonly