Quartz.NET 0.9.1, syncing with latest CVS changes
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -86,6 +87,15 @@ namespace Spring.Scheduling.Quartz
|
||||
Assert.AreSame(jd, cronTrigger.JobDetail, "job details weren't same");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestJobDataAsMap()
|
||||
{
|
||||
Hashtable data = new Hashtable();
|
||||
data["foo"] = "bar";
|
||||
data["number"] = 123;
|
||||
cronTrigger.JobDataAsMap = data;
|
||||
CollectionAssert.AreEqual(data, cronTrigger.JobDataMap, "Data differed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Spring.Scheduling.Quartz
|
||||
jobDetail.ObjectName = objectName;
|
||||
jobDetail.Group = null;
|
||||
jobDetail.AfterPropertiesSet();
|
||||
Assert.AreEqual(SchedulerConstants.DEFAULT_GROUP, jobDetail.Group, "Groups differ");
|
||||
Assert.AreEqual(SchedulerConstants.DefaultGroup, jobDetail.Group, "Groups differ");
|
||||
Assert.AreEqual(objectName, jobDetail.Name, "Names differ");
|
||||
}
|
||||
|
||||
@@ -113,9 +113,13 @@ namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
const string objectName = "springJobDetailObject";
|
||||
jobDetail.ObjectName = objectName;
|
||||
jobDetail.ApplicationContext = new XmlApplicationContext();
|
||||
jobDetail.ApplicationContextJobDataKey = "applicationContextJobDataKey";
|
||||
XmlApplicationContext ctx = new XmlApplicationContext();
|
||||
jobDetail.ApplicationContext = ctx;
|
||||
string key = "applicationContextJobDataKey";
|
||||
jobDetail.ApplicationContextJobDataKey = key;
|
||||
jobDetail.AfterPropertiesSet();
|
||||
Assert.AreSame(ctx, jobDetail.ApplicationContext, "ApplicationContext was not set correctly");
|
||||
Assert.AreSame(ctx, jobDetail.JobDataMap[key], "ApplicationContext was not set to job data map");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -92,6 +92,17 @@ namespace Spring.Scheduling.Quartz
|
||||
Assert.AreEqual(1, job.CounterValue, "Job was not invoked once");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMethodInvoker_PrivateMethod()
|
||||
{
|
||||
InvocationCountingJob job = new InvocationCountingJob();
|
||||
MethodInvoker mi = new MethodInvoker();
|
||||
mi.TargetObject = job;
|
||||
mi.TargetMethod = "PrivateMethod";
|
||||
mi.Prepare();
|
||||
methodInvokingJob.MethodInvoker = mi;
|
||||
methodInvokingJob.Execute(CreateMinimalJobExecutionContext());
|
||||
}
|
||||
|
||||
private static JobExecutionContext CreateMinimalJobExecutionContext()
|
||||
{
|
||||
@@ -130,6 +141,9 @@ namespace Spring.Scheduling.Quartz
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
private void PrivateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
public int CounterValue
|
||||
{
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using NUnit.Framework;
|
||||
@@ -25,6 +29,8 @@ using Quartz.Impl;
|
||||
|
||||
using Rhino.Mocks;
|
||||
|
||||
using Spring.Core.IO;
|
||||
|
||||
namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
/// <summary>
|
||||
@@ -34,7 +40,9 @@ namespace Spring.Scheduling.Quartz
|
||||
[TestFixture]
|
||||
public class SchedulerFactoryObjectTest
|
||||
{
|
||||
private MockRepository mockery = null;
|
||||
private static readonly MethodInfo m_InitSchedulerFactory = typeof(SchedulerFactoryObject).GetMethod("InitSchedulerFactory",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
private MockRepository mockery;
|
||||
private SchedulerFactoryObject factory;
|
||||
|
||||
[SetUp]
|
||||
@@ -256,6 +264,48 @@ namespace Spring.Scheduling.Quartz
|
||||
factory.SchedulerFactoryType = typeof(StdSchedulerFactory);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInitSchedulerFactory_MinimalDefaults()
|
||||
{
|
||||
TestSchedulerFactory.Mockery.ReplayAll();
|
||||
|
||||
factory.SchedulerName = "testFactoryObject";
|
||||
StdSchedulerFactory factoryToPass = new StdSchedulerFactory();
|
||||
m_InitSchedulerFactory.Invoke(factory, new object[] { factoryToPass });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInitSchedulerFactory_ConfigLocationReadingShouldPreserverExtraEqualsMarksAndTrimKeysAndValues()
|
||||
{
|
||||
const string ConnectionStringValue = "Server=(local);Database=quartz;Trusted_Connection=True;";
|
||||
const string ConnectionStringKey = "quartz.dataSource.default.connectionString";
|
||||
string configuration =
|
||||
@"quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
|
||||
quartz.jobStore.useProperties = false
|
||||
quartz.jobStore.dataSource = default" + Environment.NewLine +
|
||||
ConnectionStringKey+ " = " + ConnectionStringValue + Environment.NewLine +
|
||||
"quartz.dataSource.default.provider = SqlServer-20";
|
||||
|
||||
// initialize data
|
||||
MemoryStream ms = new MemoryStream();
|
||||
byte[] data = Encoding.UTF8.GetBytes(configuration);
|
||||
ms.Write(data, 0, data.Length);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
ms.Position = 0;
|
||||
|
||||
// intercept call
|
||||
InterceptingStdSChedulerFactory factoryToPass = new InterceptingStdSChedulerFactory();
|
||||
|
||||
TestSchedulerFactory.Mockery.ReplayAll();
|
||||
|
||||
factory.ConfigLocation = new TestConfigLocation(ms, "description");
|
||||
|
||||
m_InitSchedulerFactory.Invoke(factory, new object[] { factoryToPass });
|
||||
|
||||
Assert.AreEqual(ConnectionStringValue, factoryToPass.Properties[ConnectionStringKey]);
|
||||
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
@@ -269,6 +319,13 @@ namespace Spring.Scheduling.Quartz
|
||||
|
||||
}
|
||||
|
||||
internal class TestConfigLocation : InputStreamResource
|
||||
{
|
||||
public TestConfigLocation(Stream inputStream, string description) : base(inputStream, description)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class TestSchedulerFactory : ISchedulerFactory
|
||||
{
|
||||
private static readonly MockRepository mockery = new MockRepository();
|
||||
@@ -305,5 +362,18 @@ namespace Spring.Scheduling.Quartz
|
||||
}
|
||||
}
|
||||
|
||||
public class InterceptingStdSChedulerFactory : StdSchedulerFactory
|
||||
{
|
||||
private NameValueCollection properties;
|
||||
|
||||
public override void Initialize(NameValueCollection props)
|
||||
{
|
||||
this.properties = props;
|
||||
}
|
||||
|
||||
public NameValueCollection Properties
|
||||
{
|
||||
get { return properties; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -92,6 +93,16 @@ namespace Spring.Scheduling.Quartz
|
||||
Assert.AreSame(jd, simpleTrigger.JobDetail, "job details weren't same");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestJobDataAsMap()
|
||||
{
|
||||
Hashtable data = new Hashtable();
|
||||
data["foo"] = "bar";
|
||||
data["number"] = 123;
|
||||
simpleTrigger.JobDataAsMap = data;
|
||||
CollectionAssert.AreEqual(data, simpleTrigger.JobDataMap, "Data differed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace Spring.Scheduling.Quartz
|
||||
public virtual void TestAfterPropertiesSet_Defaults()
|
||||
{
|
||||
Assert.AreEqual(TRIGGER_NAME, trigger.Name, "trigger name mismatch");
|
||||
Assert.AreEqual(SchedulerConstants.DEFAULT_GROUP, trigger.Group, "trigger group name mismatch");
|
||||
Assert.AreEqual(SchedulerConstants.DefaultGroup, trigger.Group, "trigger group name mismatch");
|
||||
AssertDateTimesEqualityWithAllowedDelta(DateTime.UtcNow, trigger.StartTimeUtc, 1000);
|
||||
Assert.IsNull(trigger.JobName, "trigger job name not null");
|
||||
Assert.AreEqual(SchedulerConstants.DEFAULT_GROUP, trigger.JobGroup, "trigger job group was not default");
|
||||
Assert.AreEqual(SchedulerConstants.DefaultGroup, trigger.JobGroup, "trigger job group was not default");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -9,6 +9,11 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Spring</RootNamespace>
|
||||
<AssemblyName>Spring.Scheduling.Quartz.Tests</AssemblyName>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
||||
Reference in New Issue
Block a user