Brought more tests from Java side and synchronized with Java code base:
use object name as default scheduler name (when "SchedulerName" property not explicitly specified); do not accept a pre-registered Scheduler instance in the Quartz SchedulerRepository anymore; do not expose the Spring-created/managed Scheduler to the Quartz SchedulerRepository anymore; added "ExposeSchedulerInRepository" flag for explicit exposure to the SchedulerRepository; introduced SchedulerAccessorObject for registering jobs/triggers/listeners on an existing Quartz Scheduler instance
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <author>Rob Harrop</author>
|
||||
public class QuartzTestObject
|
||||
{
|
||||
private int exportCount;
|
||||
private int importCount;
|
||||
|
||||
public void DoImport()
|
||||
{
|
||||
++importCount;
|
||||
}
|
||||
|
||||
public void DoExport()
|
||||
{
|
||||
++exportCount;
|
||||
}
|
||||
|
||||
public int ImportCount
|
||||
{
|
||||
get { return importCount; }
|
||||
}
|
||||
|
||||
public int ExportCount
|
||||
{
|
||||
get { return exportCount; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,11 @@ namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
factory = new SchedulerFactoryObject();
|
||||
TestSchedulerFactory.Mockery.BackToRecordAll();
|
||||
|
||||
Expect
|
||||
.Call(TestSchedulerFactory.MockScheduler.SchedulerName)
|
||||
.Return("scheduler")
|
||||
.Repeat.Any();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Threading;
|
||||
|
||||
namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
public class TestMethodInvokingTask
|
||||
{
|
||||
public int counter;
|
||||
private readonly object lockObject = new object();
|
||||
|
||||
public void DoSomething()
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
|
||||
public void DoWait()
|
||||
{
|
||||
counter++;
|
||||
// wait until stop is called
|
||||
lock (lockObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
Monitor.Wait(lockObject);
|
||||
}
|
||||
catch (ThreadInterruptedException)
|
||||
{
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
Monitor.Pulse(lockObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ using NUnit.Framework;
|
||||
|
||||
using Quartz;
|
||||
|
||||
using Spring.Objects.Factory;
|
||||
|
||||
namespace Spring.Scheduling.Quartz
|
||||
{
|
||||
/// <summary>
|
||||
@@ -40,6 +42,8 @@ namespace Spring.Scheduling.Quartz
|
||||
[Test]
|
||||
public virtual void TestAfterPropertiesSet_Defaults()
|
||||
{
|
||||
((IInitializingObject) trigger).AfterPropertiesSet();
|
||||
|
||||
Assert.AreEqual(TRIGGER_NAME, trigger.Name, "trigger name mismatch");
|
||||
Assert.AreEqual(SchedulerConstants.DefaultGroup, trigger.Group, "trigger group name mismatch");
|
||||
AssertDateTimesEqualityWithAllowedDelta(DateTime.UtcNow, trigger.StartTimeUtc, 1000);
|
||||
@@ -50,6 +54,8 @@ namespace Spring.Scheduling.Quartz
|
||||
[Test]
|
||||
public virtual void TestAfterPropertiesSet_ValuesGiven()
|
||||
{
|
||||
((IInitializingObject)trigger).AfterPropertiesSet();
|
||||
|
||||
const string NAME = "newName";
|
||||
const string GROUP = "newGroup";
|
||||
DateTime START_TIME = new DateTime(10000000);
|
||||
@@ -65,6 +71,8 @@ namespace Spring.Scheduling.Quartz
|
||||
[Test]
|
||||
public virtual void TestAfterPropertiesSet_JobDetailGiven()
|
||||
{
|
||||
((IInitializingObject)trigger).AfterPropertiesSet();
|
||||
|
||||
const string jobName = "jobName";
|
||||
const string jobGroup = "jobGroup";
|
||||
Assert.AreEqual(jobName, trigger.JobName, "trigger job name was not from job detail");
|
||||
@@ -74,7 +82,9 @@ namespace Spring.Scheduling.Quartz
|
||||
[Test]
|
||||
public virtual void TestTriggerListenerNames_Valis()
|
||||
{
|
||||
string[] LISTENER_NAMES = new string[] {"Foo", "Bar", "Baz"};
|
||||
((IInitializingObject)trigger).AfterPropertiesSet();
|
||||
|
||||
string[] LISTENER_NAMES = new string[] { "Foo", "Bar", "Baz" };
|
||||
trigger.TriggerListenerNames = LISTENER_NAMES;
|
||||
CollectionAssert.AreEqual(LISTENER_NAMES, trigger.TriggerListenerNames, "Trigger listeners were not equal");
|
||||
}
|
||||
|
||||
@@ -58,11 +58,18 @@
|
||||
<Project>{E823D54C-CE82-4868-929F-5F95A999F61E}</Project>
|
||||
<Name>Spring.Scheduling.Quartz.2005</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Spring.Core.Tests\Spring.Core.Tests.2005.csproj">
|
||||
<Project>{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}</Project>
|
||||
<Name>Spring.Core.Tests.2005</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Scheduling\Quartz\AdaptableJobFactoryTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\QuartzSupportTests.cs" />
|
||||
<Compile Include="Scheduling\Quartz\QuartzTestObject.cs" />
|
||||
<Compile Include="Scheduling\Quartz\SchedulerFactoryObjectTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\SpringObjectJobFactoryTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\TestMethodInvokingTask.cs" />
|
||||
<Compile Include="Scheduling\Quartz\TestUtil.cs" />
|
||||
<Compile Include="Scheduling\Quartz\TriggerObjectTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\SimpleTriggerObjectTest.cs" />
|
||||
@@ -76,6 +83,23 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="job-scheduling-data.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="multipleAnonymousMethodInvokingJobDetailFB.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="multipleSchedulers.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="schedulerAccessorObject.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="schedulerRepositoryExposure.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
@@ -54,11 +54,18 @@
|
||||
<Project>{E823D54C-CE82-4868-929F-5F95A999F61E}</Project>
|
||||
<Name>Spring.Scheduling.Quartz.2008</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Spring.Core.Tests\Spring.Core.Tests.2008.csproj">
|
||||
<Project>{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}</Project>
|
||||
<Name>Spring.Core.Tests.2008</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Scheduling\Quartz\AdaptableJobFactoryTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\QuartzSupportTests.cs" />
|
||||
<Compile Include="Scheduling\Quartz\QuartzTestObject.cs" />
|
||||
<Compile Include="Scheduling\Quartz\SchedulerFactoryObjectTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\SpringObjectJobFactoryTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\TestMethodInvokingTask.cs" />
|
||||
<Compile Include="Scheduling\Quartz\TestUtil.cs" />
|
||||
<Compile Include="Scheduling\Quartz\TriggerObjectTest.cs" />
|
||||
<Compile Include="Scheduling\Quartz\SimpleTriggerObjectTest.cs" />
|
||||
@@ -72,6 +79,23 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="job-scheduling-data.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="multipleAnonymousMethodInvokingJobDetailFB.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="multipleSchedulers.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="schedulerAccessorObject.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="schedulerRepositoryExposure.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="1.0">
|
||||
|
||||
<job>
|
||||
<job-detail>
|
||||
<name>myJob</name>
|
||||
<group>myGroup</group>
|
||||
<job-type>Spring.Scheduling.Quartz.DummyJob, Spring.Scheduling.Quartz.Tests</job-type>
|
||||
<job-data-map>
|
||||
<entry>
|
||||
<key>param</key>
|
||||
<value>10</value>
|
||||
</entry>
|
||||
</job-data-map>
|
||||
</job-detail>
|
||||
<trigger>
|
||||
<simple>
|
||||
<name>myTrigger</name>
|
||||
<group>myGroup</group>
|
||||
<repeat-count>1</repeat-count>
|
||||
<repeat-interval>500</repeat-interval>
|
||||
</simple>
|
||||
</trigger>
|
||||
</job>
|
||||
|
||||
</quartz>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
|
||||
|
||||
<object id="scheduler" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="Triggers">
|
||||
<list>
|
||||
<ref local="exportTrigger"/>
|
||||
<ref local="importTrigger"/>
|
||||
</list>
|
||||
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="exportTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
|
||||
<property name="JobDetail">
|
||||
<object type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="TargetObject" ref="exportService"/>
|
||||
<property name="TargetMethod" value="DoExport"/>
|
||||
</object>
|
||||
|
||||
</property>
|
||||
<property name="RepeatInterval" value="1s"/>
|
||||
<property name="RepeatCount" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="importTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
|
||||
<property name="JobDetail">
|
||||
<object type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="TargetObject" ref="importService"/>
|
||||
|
||||
<property name="TargetMethod" value="DoImport"/>
|
||||
</object>
|
||||
</property>
|
||||
<property name="RepeatInterval" value="1s"/>
|
||||
<property name="RepeatCount" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="exportService" type="Spring.Scheduling.Quartz.QuartzTestObject, Spring.Scheduling.Quartz.Tests"/>
|
||||
|
||||
<object id="importService" type="Spring.Scheduling.Quartz.QuartzTestObject, Spring.Scheduling.Quartz.Tests"/>
|
||||
|
||||
</objects>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
|
||||
|
||||
|
||||
<object id="scheduler1" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="SchedulerName" value="quartz1"/>
|
||||
</object>
|
||||
|
||||
<object id="scheduler2" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="SchedulerName" value="quartz2"/>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
|
||||
|
||||
|
||||
<object id="scheduler" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz"/>
|
||||
|
||||
<object type="Spring.Scheduling.Quartz.SchedulerAccessorObject, Spring.Scheduling.Quartz">
|
||||
<property name="Scheduler" ref="scheduler"/>
|
||||
<property name="Triggers">
|
||||
<list>
|
||||
<ref local="exportTrigger"/>
|
||||
|
||||
<ref local="importTrigger"/>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="exportTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
|
||||
<property name="JobDetail">
|
||||
<object type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="TargetObject" ref="exportService"/>
|
||||
<property name="TargetMethod" value="DoExport"/>
|
||||
</object>
|
||||
</property>
|
||||
<property name="RepeatInterval" value="1s"/>
|
||||
<property name="RepeatCount" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="importTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
|
||||
<property name="jobDetail">
|
||||
|
||||
<object type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="TargetObject" ref="importService"/>
|
||||
<property name="TargetMethod" value="DoImport"/>
|
||||
</object>
|
||||
</property>
|
||||
<property name="RepeatInterval" value="1s"/>
|
||||
<property name="RepeatCount" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="exportService" type="Spring.Scheduling.Quartz.QuartzTestObject, Spring.Scheduling.Quartz.Tests"/>
|
||||
|
||||
<object id="importService" type="Spring.Scheduling.Quartz.QuartzTestObject, Spring.Scheduling.Quartz.Tests"/>
|
||||
|
||||
</objects>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
|
||||
|
||||
|
||||
<object id="scheduler" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="schedulerName" value="myScheduler"/>
|
||||
<property name="exposeSchedulerInRepository" value="true"/>
|
||||
</object>
|
||||
|
||||
<object type="Spring.Scheduling.Quartz.SchedulerAccessorObject, Spring.Scheduling.Quartz">
|
||||
<property name="schedulerName" value="myScheduler"/>
|
||||
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref local="exportTrigger"/>
|
||||
<ref local="importTrigger"/>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="exportTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
|
||||
|
||||
<property name="JobDetail">
|
||||
<object type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="TargetObject" ref="exportService"/>
|
||||
<property name="TargetMethod" value="DoExport"/>
|
||||
</object>
|
||||
</property>
|
||||
<property name="RepeatInterval" value="1s"/>
|
||||
<property name="RepeatCount" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="importTrigger" type="Spring.Scheduling.Quartz.SimpleTriggerObject, Spring.Scheduling.Quartz">
|
||||
<property name="jobDetail">
|
||||
<object type="Spring.Scheduling.Quartz.MethodInvokingJobDetailFactoryObject, Spring.Scheduling.Quartz">
|
||||
<property name="TargetObject" ref="importService"/>
|
||||
<property name="TargetMethod" value="DoImport"/>
|
||||
</object>
|
||||
</property>
|
||||
<property name="RepeatInterval" value="1s"/>
|
||||
|
||||
<property name="RepeatCount" value="1"/>
|
||||
</object>
|
||||
|
||||
<object id="exportService" type="Spring.Scheduling.Quartz.QuartzTestObject, Spring.Scheduling.Quartz.Tests"/>
|
||||
|
||||
<object id="importService" type="Spring.Scheduling.Quartz.QuartzTestObject, Spring.Scheduling.Quartz.Tests"/>
|
||||
|
||||
</objects>
|
||||
Reference in New Issue
Block a user