Skip to content

Commit

Permalink
fixes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Apr 22, 2012
1 parent 0b6268f commit e20e849
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 8 deletions.
78 changes: 78 additions & 0 deletions src/Quartz.Tests.Integration/FailFastLoggerFactoryAdapter.cs
@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;

using Common.Logging;
using Common.Logging.Factory;

namespace Quartz.Tests.Integration
{
internal class FailFastLoggerFactoryAdapter : ILoggerFactoryAdapter
{
private static readonly List<string> errors = new List<string>();

public ILog GetLogger(Type type)
{
return new FailFastLogger(this);
}

public ILog GetLogger(string name)
{
return new FailFastLogger(this);
}

private void ReportError(string error)
{
errors.Add(error);
}

public static List<string> Errors
{
get { return errors; }
}

private class FailFastLogger : AbstractLogger
{
private readonly FailFastLoggerFactoryAdapter parent;

public FailFastLogger(FailFastLoggerFactoryAdapter parent)
{
this.parent = parent;
}

protected override void WriteInternal(LogLevel level, object message, Exception exception)
{
parent.ReportError("" + message);
}

public override bool IsTraceEnabled
{
get { return false; }
}

public override bool IsDebugEnabled
{
get { return false; }
}

public override bool IsErrorEnabled
{
get { return true; }
}

public override bool IsFatalEnabled
{
get { return true; }
}

public override bool IsInfoEnabled
{
get { return false; }
}

public override bool IsWarnEnabled
{
get { return true; }
}
}
}
}
Expand Up @@ -4,6 +4,8 @@
using System.Diagnostics;
using System.Threading;

using Common.Logging;

using NUnit.Framework;

using Quartz.Impl;
Expand All @@ -22,11 +24,11 @@ public class AdoJobStoreSmokeTest
private bool clearJobs = true;
private bool scheduleJobs = true;
private bool clustered = true;
private ILoggerFactoryAdapter oldAdapter;

static AdoJobStoreSmokeTest()
{
dbConnectionStrings["Oracle"] =
"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xe)));User Id=quartznet;Password=quartznet;";
dbConnectionStrings["Oracle"] = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xe)));User Id=quartznet;Password=quartznet;";
dbConnectionStrings["SQLServer"] = "Server=(local);Database=quartz;Trusted_Connection=True;";
dbConnectionStrings["SQLServerCe"] = @"Data Source=C:\quartznet.sdf;Persist Security Info=False;";
dbConnectionStrings["MySQL"] = "Server = localhost; Database = quartz; Uid = quartznet; Pwd = quartznet";
Expand All @@ -35,6 +37,21 @@ static AdoJobStoreSmokeTest()
dbConnectionStrings["Firebird"] = "User=SYSDBA;Password=masterkey;Database=c:\\quartznet;DataSource=localhost;Port=3050;Dialect=3; Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0;";
}

[TestFixtureSetUp]
public void FixtureSetUp()
{
// set Adapter to report problems
oldAdapter = LogManager.Adapter;
LogManager.Adapter = new FailFastLoggerFactoryAdapter();
}

[TestFixtureTearDown]
public void FixtureTearDown()
{
// default back to old
LogManager.Adapter = oldAdapter;
}

[Test]
public void TestFirebird()
{
Expand Down Expand Up @@ -259,6 +276,8 @@ private void RunAdoJobStoreTest(string dbProvider, string connectionStringId)
IScheduler sched = sf.GetScheduler();
SmokeTestPerformer performer = new SmokeTestPerformer();
performer.Test(sched, clearJobs, scheduleJobs);

Assert.IsEmpty(FailFastLoggerFactoryAdapter.Errors, "Found error from logging output");
}


Expand Down
Expand Up @@ -119,6 +119,7 @@
</Compile>
<Compile Include="ExceptionPolicy\ExceptionJob.cs" />
<Compile Include="ExceptionPolicy\ExceptionJobTest.cs" />
<Compile Include="FailFastLoggerFactoryAdapter.cs" />
<Compile Include="Impl\AdoJobStore\AdoJobStoreSmokeTest.cs" />
<Compile Include="Impl\Calendar\AnnualCalendarTest.cs">
<SubType>Code</SubType>
Expand Down
Expand Up @@ -101,6 +101,7 @@
<Compile Include="ExceptionPolicy\ExceptionJob.cs" />
<Compile Include="ExceptionPolicy\ExceptionJobTest.cs" />
<Compile Include="Impl\AdoJobStore\AdoJobStoreSmokeTest.cs" />
<Compile Include="FailFastLoggerFactoryAdapter.cs" />
<Compile Include="Impl\Calendar\AnnualCalendarTest.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
6 changes: 4 additions & 2 deletions src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs
Expand Up @@ -2562,11 +2562,13 @@ public virtual IList<TriggerFiredResult> TriggersFired(IList<IOperableTrigger> t
}
catch (JobPersistenceException jpe)
{
log.ErrorFormat("Caught job persistence exception: " + jpe.Message, jpe);
result = new TriggerFiredResult(jpe);
}
catch (Exception re)
catch (Exception ex)
{
result = new TriggerFiredResult(re);
log.ErrorFormat("Caught exception: " + ex.Message, ex);
result = new TriggerFiredResult(ex);
}
results.Add(result);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
Expand Up @@ -2197,15 +2197,15 @@ public int UpdateFiredTrigger(ConnectionAndTransactionHolder conn, IOperableTrig
{
AddCommandParameter(ps, "jobName", trigger.JobKey.Name);
AddCommandParameter(ps, "jobGroup", trigger.JobKey.Group);
AddCommandParameter(ps, "isNonConcurrent", job.ConcurrentExectionDisallowed);
AddCommandParameter(ps, "requestsRecover", job.RequestsRecovery);
AddCommandParameter(ps, "isNonConcurrent", GetDbBooleanValue(job.ConcurrentExectionDisallowed));
AddCommandParameter(ps, "requestsRecover", GetDbBooleanValue(job.RequestsRecovery));
}
else
{
AddCommandParameter(ps, "jobName", null);
AddCommandParameter(ps, "JobGroup", null);
AddCommandParameter(ps, "isNonConcurrent", false);
AddCommandParameter(ps, "requestsRecover", false);
AddCommandParameter(ps, "isNonConcurrent", GetDbBooleanValue(false));
AddCommandParameter(ps, "requestsRecover", GetDbBooleanValue(false));
}

AddCommandParameter(ps, "entryId", trigger.FireInstanceId);
Expand Down

0 comments on commit e20e849

Please sign in to comment.