Skip to content

Commit

Permalink
QRTZNET-250: Adding multiple jobs via the quartz_jobs.xml skips jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Mar 20, 2011
1 parent 5723fd4 commit 57e48b5
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Quartz.Tests.Unit/Quartz.Tests.Unit.2008.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@
<EmbeddedResource Include="Xml\TestData\MinimalConfiguration_20.xml" />
<EmbeddedResource Include="Xml\TestData\RichConfiguration_20.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Xml\TestData\QRTZNET250.xml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
Expand Down
6 changes: 5 additions & 1 deletion src/Quartz.Tests.Unit/Quartz.Tests.Unit.2010.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@
<Name>Quartz.2010</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<EmbeddedResource Include="Xml\TestData\QRTZNET250.xml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
Expand Down
55 changes: 55 additions & 0 deletions src/Quartz.Tests.Unit/Xml/TestData/QRTZNET250.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- This file contains job definitions in schema version 2.0 format -->

<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">

<processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives>

<schedule>

<job>
<name>PerformanceReturnTimelinessJob</name>
<group>PerformanceTimeliness</group>
<job-type>Quartz.Job.NoOpJob, Quartz</job-type>
<durable>true</durable>
<recover>false</recover>
</job>

<trigger>
<cron>
<name>PerformanceReturnTimelinessJobTrigger</name>
<group>PerformanceTimeliness</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>PerformanceReturnTimelinessJob</job-name>
<job-group>PerformanceTimeliness</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 0/1 * * * ?</cron-expression>
</cron>
</trigger>

<job>
<name>ExposureEntryAcceptableVarianceJob</name>
<group>DataValidation</group>
<description>Sample job for Quartz Server</description>
<job-type>Quartz.Job.NoOpJob, Quartz</job-type>
<durable>true</durable>
<recover>false</recover>
</job>

<trigger>
<cron>
<name>ExposureEntryAcceptableVarianceJobTrigger</name>
<group>DataValidation</group>
<description>Simple trigger to simply fire sample job</description>
<job-name>ExposureEntryAcceptableVarianceJob</job-name>
<job-group>DataValidation</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<cron-expression>0 0/1 * * * ?</cron-expression>
</cron>
</trigger>

</schedule>
</job-scheduling-data>
10 changes: 10 additions & 0 deletions src/Quartz.Tests.Unit/Xml/XMLSchedulingDataProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ public void TestScheduling_MinimalConfiguration()
processor.ScheduleJobs(mockScheduler);
}

[Test]
public void TestScheduling_QuartzNet250()
{
Stream s = ReadJobXmlFromEmbeddedResource("QRTZNET250.xml");
processor.ProcessStream(s, null);
processor.ScheduleJobs(mockScheduler);
mockScheduler.AssertWasCalled(x => x.AddJob(Arg<IJobDetail>.Is.NotNull, Arg<bool>.Is.Anything), constraints => constraints.Repeat.Twice());
mockScheduler.AssertWasCalled(x => x.ScheduleJob(Arg<ITrigger>.Is.NotNull), constraints => constraints.Repeat.Twice());
}

private static Stream ReadJobXmlFromEmbeddedResource(string resourceName)
{
string fullName = "Quartz.Tests.Unit.Xml.TestData." + resourceName;
Expand Down
12 changes: 6 additions & 6 deletions src/Quartz/Xml/XMLSchedulingDataProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,10 @@ public virtual void ScheduleJobs(IScheduler sched)
IDictionary<JobKey, List<IMutableTrigger>> triggersByFQJobName = BuildTriggersByFQJobNameMap(triggers);

// add each job, and it's associated triggers
for (int i = 0; i < jobs.Count; i++)
while (jobs.Count > 0)
{
IJobDetail detail = jobs[i];
// remove jobs as we handle them...
IJobDetail detail = jobs[0];
jobs.Remove(detail);

IJobDetail dupeJ = sched.GetJobDetail(detail.Key);
Expand Down Expand Up @@ -724,11 +724,11 @@ public virtual void ScheduleJobs(IScheduler sched)
bool addJobWithFirstSchedule = true;

// Add triggers related to the job...
for (int j = 0; j < triggersOfJob.Count; j++)
while (triggersOfJob.Count > 0)
{
IMutableTrigger trigger = triggersOfJob[j];
IMutableTrigger trigger = triggersOfJob[0];
// remove triggers as we handle them...
triggers.Remove(trigger);
triggersOfJob.Remove(trigger);

bool addedTrigger = false;
while (addedTrigger == false)
Expand Down Expand Up @@ -805,7 +805,7 @@ public virtual void ScheduleJobs(IScheduler sched)
foreach (IMutableTrigger trigger in triggers)
{
bool addedTrigger = false;
while (addedTrigger == false)
while (!addedTrigger)
{
ITrigger dupeT = sched.GetTrigger(trigger.Key);
if (dupeT != null)
Expand Down

0 comments on commit 57e48b5

Please sign in to comment.