Fixing Quartz integration code comments and setting warnaserror = true in build file

This commit is contained in:
lahma
2009-11-06 05:52:13 +00:00
parent d1bfe35fab
commit e76b73225e
15 changed files with 394 additions and 19 deletions

View File

@@ -19,7 +19,7 @@
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>Spring.Scheduling.Quartz.xml</DocumentationFile>
<DocumentationFile>..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz\Debug\Spring.Scheduling.Quartz.XML</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

View File

@@ -8,7 +8,7 @@
-->
<target name="build">
<csc target="library" define="${current.build.defines.csc}"
warnaserror="false"
warnaserror="true"
debug="${current.build.debug}"
output="${current.bin.dir}/${project::get-name()}.dll"
doc="${current.bin.dir}/${project::get-name()}.xml"

View File

@@ -34,12 +34,18 @@ namespace Spring.Scheduling.Quartz
{
private AdaptableJobFactory jobFactory;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
jobFactory = new AdaptableJobFactory();
}
/// <summary>
/// Tests job creation.
/// </summary>
[Test]
public void TestNewJob_IncompatibleJob()
{
@@ -64,12 +70,18 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Tests job creation.
/// </summary>
[Test]
public void TestNewJob_ThreadStartJob()
{
// TODO ThreadStart is not the way to go
}
/// <summary>
/// Tests job creation.
/// </summary>
[Test]
public void TestNewJob_NormalIJob()
{

View File

@@ -32,6 +32,9 @@ namespace Spring.Scheduling.Quartz
{
private CronTriggerObject cronTrigger;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
@@ -54,7 +57,9 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Tests that JobDetail defaults values as expected in AfterPropertiesSet.
/// </summary>
[Test]
public override void TestAfterPropertiesSet_JobDetailGiven()
{
@@ -67,6 +72,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreSame(jd, cronTrigger.JobDetail, "job details weren't same");
}
/// <summary>
/// Tests that JobDetail maps job data map as expected.
/// </summary>
[Test]
public void TestJobDataAsMap()
{

View File

@@ -35,12 +35,18 @@ namespace Spring.Scheduling.Quartz
{
private JobDetailObject jobDetail;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
jobDetail = new JobDetailObject();
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestJobType_Null()
@@ -48,6 +54,9 @@ namespace Spring.Scheduling.Quartz
jobDetail.JobType = null;
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[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");
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[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");
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestJobDataAsMap_Null()
@@ -71,6 +85,9 @@ namespace Spring.Scheduling.Quartz
jobDetail.JobDataAsMap = null;
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[Test]
public void TestJobDataAsMap_ProperValues()
{
@@ -83,6 +100,9 @@ namespace Spring.Scheduling.Quartz
CollectionAssert.AreEqual(values.Keys, jobDetail.JobDataMap.Keys, "JobDataMap values not equal");
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_Defaults()
{
@@ -94,6 +114,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(objectName, jobDetail.Name, "Names differ");
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_CustomNameAndGroup()
{
@@ -108,6 +131,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(jobDetailName, jobDetail.Name, "Names differ");
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[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");
}
/// <summary>
/// Tests job detail's property behavior.
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestAfterPropertiesSet_ApplicationContextJobDataKeySetWithoutApplicationContext()

View File

@@ -21,7 +21,7 @@ using Quartz;
namespace Spring.Scheduling.Quartz
{
/// <summary>
///
/// Unit tests for MethodInvokingJobDetailFactoryObject.
/// </summary>
/// <author>Marko Lahma (.NET)</author>
[TestFixture]
@@ -30,6 +30,9 @@ namespace Spring.Scheduling.Quartz
private const string FACTORY_NAME = "springObjectFactory";
private MethodInvokingJobDetailFactoryObject factory;
/// <summary>
/// Setup for the test.
/// </summary>
[SetUp]
public void SetUp()
{
@@ -39,6 +42,9 @@ namespace Spring.Scheduling.Quartz
factory.TargetObject = new InvocationCountingJob();
}
/// <summary>
/// Tests JobDetail retrieval and it's set properties.
/// </summary>
[Test]
public void TestGetObject_MinimalDefaults()
{
@@ -51,6 +57,9 @@ namespace Spring.Scheduling.Quartz
Assert.IsTrue(jd.Volatile, "job was not volatile");
}
/// <summary>
/// Tests JobDetail retrieval and it's set properties.
/// </summary>
[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");
}
/// <summary>
/// Tests JobDetail retrieval and it's set properties.
/// </summary>
[Test]
public void TestGetObject_TriggerListenersSet()
{

View File

@@ -30,7 +30,7 @@ using Spring.Objects.Support;
namespace Spring.Scheduling.Quartz
{
/// <summary>
///
/// Tests for MethodInvokingJob.
/// </summary>
/// <author>Marko Lahma (.NET)</author>
[TestFixture]
@@ -38,12 +38,18 @@ namespace Spring.Scheduling.Quartz
{
private MethodInvokingJob methodInvokingJob;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
methodInvokingJob = new MethodInvokingJob();
}
/// <summary>
/// Test method invoke via execute.
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestMethodInvoker_SetWithNull()
@@ -51,6 +57,9 @@ namespace Spring.Scheduling.Quartz
methodInvokingJob.MethodInvoker = null;
}
/// <summary>
/// Test method invoke via execute.
/// </summary>
[Test]
[ExpectedException(typeof(JobExecutionException))]
public void TestMethodInvocation_NullMethodInvokder()
@@ -58,6 +67,9 @@ namespace Spring.Scheduling.Quartz
methodInvokingJob.Execute(CreateMinimalJobExecutionContext());
}
/// <summary>
/// Test method invoke via execute.
/// </summary>
[Test]
public void TestMethodInvoker_MethodSetCorrectly()
{
@@ -71,6 +83,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(1, job.CounterValue, "Job was not invoked once");
}
/// <summary>
/// Test method invoke via execute.
/// </summary>
[Test]
public void TestMethodInvoker_MethodSetCorrectlyThrowsException()
{
@@ -92,6 +107,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(1, job.CounterValue, "Job was not invoked once");
}
/// <summary>
/// Test method invoke via execute.
/// </summary>
[Test]
public void TestMethodInvoker_PrivateMethod()
{
@@ -130,11 +148,17 @@ namespace Spring.Scheduling.Quartz
{
private int counter;
/// <summary>
/// Increments method invoke counter.
/// </summary>
public void Invoke()
{
Interlocked.Increment(ref counter);
}
/// <summary>
/// Throws exception after incrementing counter.
/// </summary>
public void InvokeAndThrowException()
{
Interlocked.Increment(ref counter);
@@ -145,6 +169,9 @@ namespace Spring.Scheduling.Quartz
{
}
/// <summary>
/// Invocation count.
/// </summary>
public int CounterValue
{
get { return counter; }

View File

@@ -43,24 +43,36 @@ namespace Spring.Scheduling.Quartz
{
private MockRepository mockery;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
mockery = new MockRepository();
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[Test]
public void TestSchedulerFactoryObject()
{
DoTestSchedulerFactoryObject(false, false);
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithExplicitJobDetail()
{
DoTestSchedulerFactoryObject(true, false);
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[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();
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithExistingJobs()
{
DoTestSchedulerFactoryObjectWithExistingJobs(false);
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithOverwriteExistingJobs()
{
@@ -245,12 +263,18 @@ namespace Spring.Scheduling.Quartz
mockery.VerifyAll();
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithExistingJobsAndRaceCondition()
{
DoTestSchedulerFactoryObjectWithExistingJobsAndRaceCondition(false);
}
/// <summary>
/// Executes parametrized test.
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithOverwriteExistingJobsAndRaceCondition()
{
@@ -344,6 +368,8 @@ namespace Spring.Scheduling.Quartz
mockery.VerifyAll();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithListeners()
{
@@ -478,6 +504,8 @@ namespace Spring.Scheduling.Quartz
schedulerFactoryObject.Dispose();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithPlainQuartzObjects()
{
@@ -551,6 +579,8 @@ namespace Spring.Scheduling.Quartz
mockery.VerifyAll();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerFactoryObjectWithApplicationContext()
{
@@ -587,6 +617,8 @@ namespace Spring.Scheduling.Quartz
mockery.VerifyAll();
}
/// <summary>
/// </summary>
[Test]
public void TestJobDetailObjectWithApplicationContext()
{
@@ -607,6 +639,8 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(ac, jobDetail.JobDataMap.Get("appCtx"));
}
/// <summary>
/// </summary>
[Test]
public void TestMethodInvokingJobDetailFactoryObjectWithListenerNames()
{
@@ -624,6 +658,8 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(names, result);
}
/// <summary>
/// </summary>
[Test]
public void TestJobDetailObjectWithListenerNames()
{
@@ -634,6 +670,8 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(names, result);
}
/// <summary>
/// </summary>
[Test]
public void TestCronTriggerObjectWithListenerNames()
{
@@ -644,6 +682,8 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(names, result);
}
/// <summary>
/// </summary>
[Test]
public void TestSimpleTriggerObjectWithListenerNames()
{
@@ -654,6 +694,8 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(names, result);
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerWithTaskExecutor()
{
@@ -686,6 +728,8 @@ namespace Spring.Scheduling.Quartz
bean.Dispose();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerWithRunnable()
{
@@ -714,6 +758,8 @@ namespace Spring.Scheduling.Quartz
bean.Dispose();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerWithQuartzJobObject()
{
@@ -745,6 +791,8 @@ namespace Spring.Scheduling.Quartz
sfo.Dispose();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerWithSpringObjectJobFactory()
{
@@ -778,6 +826,8 @@ namespace Spring.Scheduling.Quartz
bean.Dispose();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerWithSpringObjectJobFactoryAndParamMismatchNotIgnored()
{
@@ -813,6 +863,8 @@ namespace Spring.Scheduling.Quartz
bean.Dispose();
}
/// <summary>
/// </summary>
[Test]
public void TestSchedulerWithSpringObjectJobFactoryAndRunnable()
{
@@ -845,6 +897,8 @@ namespace Spring.Scheduling.Quartz
bean.Dispose();
}
///<summary>
///</summary>
[Test]
public void TestSchedulerWithSpringObjectJobFactoryAndQuartzJobObject()
{
@@ -877,6 +931,9 @@ namespace Spring.Scheduling.Quartz
bean.Dispose();
}
/// <summary>
///
/// </summary>
[Test]
public void TestSchedulerWithSpringObjectJobFactoryAndJobSchedulingData()
{
@@ -934,6 +991,9 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Tests calling of services with method invoke.
/// </summary>
[Test]
public void TestWithTwoAnonymousMethodInvokingJobDetailFactoryObjects()
{
@@ -955,6 +1015,9 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Tests how quartz triggers and services interact.
/// </summary>
[Test]
public void TestSchedulerAccessorObject()
{
@@ -976,6 +1039,9 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Tests how scheduler is exposed to application context.
/// </summary>
[Test]
public void TestSchedulerRepositoryExposure()
{
@@ -1073,10 +1139,17 @@ namespace Spring.Scheduling.Quartz
}
/// <summary>
/// Simple task executor that tracks invocation count.
/// </summary>
public class CountingTaskExecutor : ITaskExecutor
{
internal int count;
/// <summary>
/// Executes task instance.
/// </summary>
/// <param name="task"></param>
public void Execute(ThreadStart task)
{
count++;
@@ -1084,12 +1157,18 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Simple test job object.
/// </summary>
public class DummyJobObject : QuartzJobObject
{
internal static int param;
internal static int count;
/// <summary>
/// Sets parameter value.
/// </summary>
/// <param name="value"></param>
public void SetParam(int value)
{
if (param > 0)
@@ -1099,19 +1178,29 @@ namespace Spring.Scheduling.Quartz
param = value;
}
/// <summary>
/// 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.
/// </summary>
protected override void ExecuteInternal(JobExecutionContext jobExecutionContext)
{
count++;
}
}
/// <summary>
/// Simple thread runnable.
/// </summary>
public class DummyRunnable : IThreadRunnable
{
internal static int param;
internal static int count;
/// <summary>
/// Sets param value.
/// </summary>
/// <param name="value"></param>
public void SetParam(int value)
{
if (param > 0)
@@ -1121,6 +1210,9 @@ namespace Spring.Scheduling.Quartz
param = value;
}
/// <summary>
/// Runs thread runnable.
/// </summary>
public void Run()
{
count++;
@@ -1128,12 +1220,18 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// A simple job that tracks invocation count and allows setting of a simple parameter.
/// </summary>
public class DummyJob : IJob
{
internal static int param;
internal static int count;
/// <summary>
/// Sets param value.
/// </summary>
/// <param name="value"></param>
public void SetParam(int value)
{
if (param > 0)
@@ -1143,21 +1241,39 @@ namespace Spring.Scheduling.Quartz
param = value;
}
///<summary>
/// Executes this job instance.
///</summary>
///<param name="jobExecutionContext"></param>
public void Execute(JobExecutionContext jobExecutionContext)
{
count++;
}
}
/// <summary>
/// Subclass of SchedulerFactoryObject for testing purposes.
/// </summary>
public class TestSchedulerFactoryObject : SchedulerFactoryObject
{
private readonly IScheduler sched;
/// <summary>
/// Creates new instance of this class.
/// </summary>
/// <param name="sched"></param>
public TestSchedulerFactoryObject(IScheduler sched)
{
this.sched = sched;
}
/// <summary>
/// Creates a scheduler actually returning the scheduler this intance
/// was instantiated with.
/// </summary>
/// <param name="schedulerFactory"></param>
/// <param name="schedulerName"></param>
/// <returns></returns>
protected override IScheduler CreateScheduler(ISchedulerFactory schedulerFactory, String schedulerName)
{
return sched;

View File

@@ -1,6 +1,8 @@
namespace Spring.Scheduling.Quartz
{
/// <summary>
/// A simple test object for Quartz.NET to run
/// that simulates imports and exports.
/// </summary>
/// <author>Rob Harrop</author>
public class QuartzTestObject
@@ -8,21 +10,33 @@ namespace Spring.Scheduling.Quartz
private int exportCount;
private int importCount;
/// <summary>
/// Executes a fake import and increments counter.
/// </summary>
public void DoImport()
{
++importCount;
}
///<summary>
/// Executes a fake export and increments counter.
///</summary>
public void DoExport()
{
++exportCount;
}
/// <summary>
/// Tells how many times import has been done.
/// </summary>
public int ImportCount
{
get { return importCount; }
}
/// <summary>
/// Tells how many times export has been done.
/// </summary>
public int ExportCount
{
get { return exportCount; }

View File

@@ -34,7 +34,7 @@ using Spring.Core.IO;
namespace Spring.Scheduling.Quartz
{
/// <summary>
///
/// Tests for SchedulerFactoryObject.
/// </summary>
/// <author>Marko Lahma (.NET)</author>
[TestFixture]
@@ -45,6 +45,9 @@ namespace Spring.Scheduling.Quartz
private MockRepository mockery;
private SchedulerFactoryObject factory;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
@@ -57,6 +60,9 @@ namespace Spring.Scheduling.Quartz
.Repeat.Any();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_Defaults()
{
@@ -64,6 +70,9 @@ namespace Spring.Scheduling.Quartz
TestSchedulerFactory.Mockery.ReplayAll();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_NullJobFactory()
{
@@ -72,6 +81,9 @@ namespace Spring.Scheduling.Quartz
TestSchedulerFactory.Mockery.ReplayAll();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_NoAutoStartup()
{
@@ -85,6 +97,9 @@ namespace Spring.Scheduling.Quartz
factory.AfterPropertiesSet();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_AutoStartup()
{
@@ -98,6 +113,9 @@ namespace Spring.Scheduling.Quartz
factory.AfterPropertiesSet();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_AddListeners()
{
@@ -129,6 +147,9 @@ namespace Spring.Scheduling.Quartz
factory.AfterPropertiesSet();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_Calendars()
{
@@ -147,6 +168,9 @@ namespace Spring.Scheduling.Quartz
factory.AfterPropertiesSet();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_Trigger_TriggerExists()
{
@@ -165,6 +189,9 @@ namespace Spring.Scheduling.Quartz
factory.AfterPropertiesSet();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_Trigger_TriggerDoesntExist()
{
@@ -197,6 +224,9 @@ namespace Spring.Scheduling.Quartz
LastCall.IgnoreArguments();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_AutoStartup_WithDelay()
{
@@ -212,6 +242,9 @@ namespace Spring.Scheduling.Quartz
factory.AfterPropertiesSet();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestStart()
{
@@ -227,6 +260,9 @@ namespace Spring.Scheduling.Quartz
factory.Start();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestStop()
{
@@ -242,6 +278,9 @@ namespace Spring.Scheduling.Quartz
factory.Stop();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestGetObject()
{
@@ -251,6 +290,9 @@ namespace Spring.Scheduling.Quartz
Assert.IsNotNull(sched, "scheduler was null");
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentException))]
public void TestSchedulerFactoryType_InvalidType()
@@ -259,6 +301,9 @@ namespace Spring.Scheduling.Quartz
factory.SchedulerFactoryType = typeof(SchedulerFactoryObjectTest);
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestSchedulerFactoryType_ValidType()
{
@@ -266,6 +311,9 @@ namespace Spring.Scheduling.Quartz
factory.SchedulerFactoryType = typeof(StdSchedulerFactory);
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestInitSchedulerFactory_MinimalDefaults()
{
@@ -276,6 +324,9 @@ namespace Spring.Scheduling.Quartz
m_InitSchedulerFactory.Invoke(factory, new object[] { factoryToPass });
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestInitSchedulerFactory_ConfigLocationReadingShouldPreserverExtraEqualsMarksAndTrimKeysAndValues()
{
@@ -308,6 +359,9 @@ ConnectionStringKey+ " = " + ConnectionStringValue + Environment.NewLine +
}
/// <summary>
/// Cleans this test instance.
/// </summary>
[TearDown]
public void TearDown()
{
@@ -328,6 +382,9 @@ ConnectionStringKey+ " = " + ConnectionStringValue + Environment.NewLine +
}
}
/// <summary>
/// ISchedulerFactory implementation for testing purposes.
/// </summary>
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));
}
/// <summary>
/// MockRepository intance.
/// </summary>
public static MockRepository Mockery
{
get { return mockery; }
}
/// <summary>
/// The mocked scheduler.
/// </summary>
public static IScheduler MockScheduler
{
get { return mockScheduler; }
}
///<summary>
///</summary>
///<returns></returns>
public IScheduler GetScheduler()
{
return mockScheduler;
}
///<summary>
///</summary>
///<param name="schedName"></param>
///<returns></returns>
public IScheduler GetScheduler(string schedName)
{
return mockScheduler;
}
///<summary>
///</summary>
public ICollection AllSchedulers
{
get { return new ArrayList(); }
}
}
///<summary>
/// Scheduler factory that supports property interception.
///</summary>
public class InterceptingStdSChedulerFactory : StdSchedulerFactory
{
private NameValueCollection properties;
///<summary>
/// Initializes the factory.
///</summary>
///<param name="props"></param>
public override void Initialize(NameValueCollection props)
{
this.properties = props;
}
/// <summary>
/// Return propeties given to this factory at initialization time.
/// </summary>
public NameValueCollection Properties
{
get { return properties; }

View File

@@ -33,6 +33,9 @@ namespace Spring.Scheduling.Quartz
{
private SimpleTriggerObject simpleTrigger;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
@@ -55,6 +58,9 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public override void TestAfterPropertiesSet_Defaults()
{
@@ -62,6 +68,9 @@ namespace Spring.Scheduling.Quartz
base.TestAfterPropertiesSet_Defaults();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public override void TestAfterPropertiesSet_ValuesGiven()
{
@@ -69,7 +78,10 @@ namespace Spring.Scheduling.Quartz
simpleTrigger.AfterPropertiesSet();
base.TestAfterPropertiesSet_ValuesGiven();
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestAfterPropertiesSet_StartDelayGiven()
{
@@ -80,7 +92,9 @@ namespace Spring.Scheduling.Quartz
AssertDateTimesEqualityWithAllowedDelta(startTime.AddMilliseconds(START_DELAY), simpleTrigger.StartTimeUtc, 1000);
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public override void TestAfterPropertiesSet_JobDetailGiven()
{
@@ -93,6 +107,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreSame(jd, simpleTrigger.JobDetail, "job details weren't same");
}
/// <summary>
/// Tests AfterPropertiesSet behavior.
/// </summary>
[Test]
public void TestJobDataAsMap()
{

View File

@@ -25,7 +25,7 @@ using Quartz.Spi;
namespace Spring.Scheduling.Quartz
{
/// <summary>
///
/// Unit tests for SpringObjectJobFactory.
/// </summary>
/// <author>Marko Lahma (.NET)</author>
[TestFixture]
@@ -33,12 +33,18 @@ namespace Spring.Scheduling.Quartz
{
private SpringObjectJobFactory factory;
/// <summary>
/// Test setup.
/// </summary>
[SetUp]
public void SetUp()
{
factory = new SpringObjectJobFactory();
}
/// <summary>
/// Tests job instane creation.
/// </summary>
[Test]
public void TestCreateJobInstance_SimpleDefaults()
{
@@ -49,6 +55,9 @@ namespace Spring.Scheduling.Quartz
Assert.IsNotNull(job, "Created job was null");
}
/// <summary>
/// Tests job instane creation.
/// </summary>
[Test]
public void TestCreateJobInstance_SchedulerContextGiven()
{
@@ -65,6 +74,9 @@ namespace Spring.Scheduling.Quartz
Assert.AreEqual(123, job.Number, "integer injection failed");
}
/// <summary>
/// Tests job instane creation.
/// </summary>
[Test]
public void TestCreateJobInstance_IgnoredProperties()
{
@@ -82,18 +94,26 @@ namespace Spring.Scheduling.Quartz
}
/// <summary>
/// Test job object that has injectable properties
/// </summary>
public class InjectableJob : NoOpJob
{
private int number;
private string foo;
/// <summary>
/// Simple int property.
/// </summary>
public int Number
{
get { return number; }
set { number = value; }
}
/// <summary>
/// Simple string property.
/// </summary>
public string Foo
{
get { return foo; }

View File

@@ -20,18 +20,28 @@ namespace Spring.Scheduling.Quartz
{
/// <summary>
/// Simple test task.
/// </summary>
/// <author>Juergen Hoeller</author>
public class TestMethodInvokingTask
{
/// <summary>
/// Counter for DoSomething and DoWait calls.
/// </summary>
public int counter;
private readonly object lockObject = new object();
/// <summary>
/// Simple test method.
/// </summary>
public void DoSomething()
{
counter++;
}
/// <summary>
/// Waits until stop is called.
/// </summary>
public void DoWait()
{
counter++;
@@ -49,6 +59,9 @@ namespace Spring.Scheduling.Quartz
}
}
/// <summary>
/// Informs test object that stop should be called.
/// </summary>
public void Stop()
{
lock (lockObject)

View File

@@ -31,14 +31,22 @@ namespace Spring.Scheduling.Quartz
public abstract class TriggerObjectTest
{
private Trigger trigger;
/// <summary>
/// Constant name for tested triggers.
/// </summary>
protected const string TRIGGER_NAME = "trigger";
/// <summary>
/// TriggerObject under test.
/// </summary>
protected Trigger Trigger
{
set { trigger = value; }
}
/// <summary>
/// Tests that TriggerObject defaults values as expected in AfterPropertiesSet.
/// </summary>
[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");
}
/// <summary>
/// Tests that TriggerObject defaults values as expected in AfterPropertiesSet.
/// </summary>
[Test]
public virtual void TestAfterPropertiesSet_ValuesGiven()
{
@@ -67,7 +78,9 @@ namespace Spring.Scheduling.Quartz
AssertDateTimesEqualityWithAllowedDelta(START_TIME, trigger.StartTimeUtc, 1000);
}
/// <summary>
/// Tests that TriggerObject defaults values as expected in AfterPropertiesSet.
/// </summary>
[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");
}
/// <summary>
/// Tests that TriggerObject defaults values as expected in AfterPropertiesSet.
/// </summary>
[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");
}
/// <summary>
/// Tests whether two datetimes are close enough.
/// </summary>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="allowedDeltaInMilliseconds"></param>
protected static void AssertDateTimesEqualityWithAllowedDelta(DateTime d1, DateTime d2, int allowedDeltaInMilliseconds)
{
int diffInMillis = (int) Math.Abs((d1 - d2).TotalMilliseconds);

View File

@@ -19,6 +19,9 @@
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>