diff --git a/lib/Net/1.1/Quartz.dll b/lib/Net/1.1/Quartz.dll index 8e0cb265..ccb0389b 100644 Binary files a/lib/Net/1.1/Quartz.dll and b/lib/Net/1.1/Quartz.dll differ diff --git a/lib/Net/2.0/Quartz.dll b/lib/Net/2.0/Quartz.dll index 29196034..bd98ee47 100644 Binary files a/lib/Net/2.0/Quartz.dll and b/lib/Net/2.0/Quartz.dll differ diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/CronTriggerObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/CronTriggerObject.cs index e0466316..c29ffd71 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/CronTriggerObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/CronTriggerObject.cs @@ -54,7 +54,7 @@ namespace Spring.Scheduling.Quartz { private JobDetail jobDetail; private string objectName; - private readonly Constants constants = new Constants(typeof(MisfirePolicy.CronTrigger), typeof(MisfirePolicy)); + private readonly Constants constants = new Constants(typeof(MisfireInstruction.CronTrigger), typeof(MisfireInstruction)); /// @@ -73,11 +73,11 @@ namespace Spring.Scheduling.Quartz /// /// Set the misfire instruction via the name of the corresponding /// constant in the CronTrigger class. - /// Default is MISFIRE_INSTRUCTION_SMART_POLICY. + /// Default is . /// - /// - /// - /// + /// + /// + /// public virtual string MisfireInstructionName { set @@ -154,7 +154,7 @@ namespace Spring.Scheduling.Quartz } if (Group == null) { - Group = SchedulerConstants.DEFAULT_GROUP; + Group = SchedulerConstants.DefaultGroup; } if (StartTimeUtc == DateTime.MinValue) { diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/JobDetailObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/JobDetailObject.cs index 1b53eac2..cfa14013 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/JobDetailObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/JobDetailObject.cs @@ -33,7 +33,7 @@ namespace Spring.Scheduling.Quartz /// Juergen Hoeller /// /// - /// + /// public class JobDetailObject : JobDetail, IObjectNameAware, IApplicationContextAware, IInitializingObject { private Type actualJobType; @@ -200,7 +200,7 @@ namespace Spring.Scheduling.Quartz } if (Group == null) { - Group = SchedulerConstants.DEFAULT_GROUP; + Group = SchedulerConstants.DefaultGroup; } if (applicationContextJobDataKey != null) { diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJobDetailFactoryObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJobDetailFactoryObject.cs index 92bab59b..78ff6f7a 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJobDetailFactoryObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/MethodInvokingJobDetailFactoryObject.cs @@ -65,7 +65,7 @@ namespace Spring.Scheduling.Quartz /// public MethodInvokingJobDetailFactoryObject() { - group = SchedulerConstants.DEFAULT_GROUP; + group = SchedulerConstants.DefaultGroup; } @@ -84,7 +84,7 @@ namespace Spring.Scheduling.Quartz /// Default is the default group of the Scheduler. /// /// - /// + /// public virtual string Group { set { group = value; } diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerFactoryObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerFactoryObject.cs index 6a4aa818..388d3f49 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerFactoryObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SchedulerFactoryObject.cs @@ -679,12 +679,12 @@ namespace Spring.Scheduling.Quartz // its default configuration when explicitly given properties. if (taskExecutor != null) { - mergedProps[StdSchedulerFactory.PROP_THREAD_POOL_CLASS] = + mergedProps[StdSchedulerFactory.PropertyThreadPoolType] = typeof (LocalTaskExecutorThreadPool).FullName; } else { - mergedProps.Set(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, typeof (SimpleThreadPool).Name); + mergedProps.Set(StdSchedulerFactory.PropertyThreadPoolType, typeof(SimpleThreadPool).Name); mergedProps[PROP_THREAD_COUNT] = Convert.ToString(DEFAULT_THREAD_COUNT); } @@ -697,25 +697,29 @@ namespace Spring.Scheduling.Quartz using (StreamReader sr = new StreamReader(configLocation.InputStream)) { string line; - while ((line =sr.ReadLine()) != null) + while ((line = sr.ReadLine()) != null) { - string[] lineItems = line.Split('='); + string[] lineItems = line.Split(new char[] { '=' }, 2); if (lineItems.Length == 2) { - mergedProps[lineItems[0]] = lineItems[1]; + mergedProps[lineItems[0].Trim()] = lineItems[1].Trim(); } } } } - MergePropertiesIntoMap(quartzProperties, mergedProps); + if (quartzProperties != null) + { + // if given quartz properties, merge to them to configuration + MergePropertiesIntoMap(quartzProperties, mergedProps); + } // Make sure to set the scheduler name as configured in the Spring configuration. if (schedulerName != null) { - mergedProps.Add(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, schedulerName); + mergedProps.Add(StdSchedulerFactory.PropertySchedulerInstanceName, schedulerName); } ((StdSchedulerFactory) schedulerFactory).Initialize(mergedProps); diff --git a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SimpleTriggerObject.cs b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SimpleTriggerObject.cs index b4bb4959..de5ce1ef 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SimpleTriggerObject.cs +++ b/src/Spring/Spring.Scheduling.Quartz/Scheduling/Quartz/SimpleTriggerObject.cs @@ -54,14 +54,14 @@ namespace Spring.Scheduling.Quartz private long startDelay = 0; private JobDetail jobDetail; private string objectName; - private readonly Constants constants = new Constants(typeof(MisfirePolicy.SimpleTrigger), typeof(MisfirePolicy)); + private readonly Constants constants = new Constants(typeof(MisfireInstruction.SimpleTrigger), typeof(MisfireInstruction)); /// /// Initializes a new instance of the class. /// public SimpleTriggerObject() { - RepeatCount = REPEAT_INDEFINITELY; + RepeatCount = RepeatIndefinitely; } /// @@ -80,14 +80,14 @@ namespace Spring.Scheduling.Quartz /// /// Set the misfire instruction via the name of the corresponding /// constant in the SimpleTrigger class. - /// Default is . + /// Default is . /// - /// - /// - /// - /// - /// - /// + /// + /// + /// + /// + /// + /// public virtual string MisfireInstructionName { set @@ -179,7 +179,7 @@ namespace Spring.Scheduling.Quartz } if (Group == null) { - Group = SchedulerConstants.DEFAULT_GROUP; + Group = SchedulerConstants.DefaultGroup; } if (StartTimeUtc == DateTime.MinValue) { diff --git a/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2005.csproj b/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2005.csproj index 615b42cc..ac3c6f9d 100644 --- a/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2005.csproj +++ b/src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.2005.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -9,6 +9,11 @@ Properties Spring Spring.Scheduling.Quartz + + + 2.0 + + true 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 52d07ecc..505d1853 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/CronTriggerObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/CronTriggerObjectTest.cs @@ -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"); + } } 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 a3e82eda..7536556a 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/JobDetailObjectTest.cs @@ -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] 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 02f0e319..be92a1ee 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/MethodInvokingJobTest.cs @@ -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 { 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 a6375e05..8b54011e 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs @@ -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 { /// @@ -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; } + } + } } 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 19ae7f61..20fe6fa5 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SimpleTriggerObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SimpleTriggerObjectTest.cs @@ -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"); + } + } } 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 e819f68c..1c47ae28 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TriggerObjectTest.cs +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/TriggerObjectTest.cs @@ -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] diff --git a/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2005.csproj b/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2005.csproj index 0f965b95..c20f1273 100644 --- a/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2005.csproj +++ b/test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.2005.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -9,6 +9,11 @@ Properties Spring Spring.Scheduling.Quartz.Tests + + + 2.0 + + true