Update of /cvsroot/springnet/Spring.Net.Integration/projects/Spring.Scheduling.Quartz/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13005
Modified Files:
SchedulerFactoryObjectTest.cs
Log Message:
Fixes to resource based configuration reading, whitespace is trimmed from keys and values and only first '=' match is used
Index: SchedulerFactoryObjectTest.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net.Integration/projects/Spring.Scheduling.Quartz/test/Spring/Spring.Scheduling.Quartz.Tests/Scheduling/Quartz/SchedulerFactoryObjectTest.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SchedulerFactoryObjectTest.cs 9 Jun 2008 10:03:50 -0000 1.3
--- SchedulerFactoryObjectTest.cs 9 Jun 2008 10:57:18 -0000 1.4
***************
*** 17,21 ****
--- 17,24 ----
using System;
using System.Collections;
+ using System.Collections.Specialized;
+ using System.IO;
using System.Reflection;
+ using System.Text;
using System.Threading;
***************
*** 27,30 ****
--- 30,35 ----
using Rhino.Mocks;
+ using Spring.Core.IO;
+
namespace Spring.Scheduling.Quartz
{
***************
*** 36,40 ****
public class SchedulerFactoryObjectTest
{
! private MockRepository mockery = null;
private SchedulerFactoryObject factory;
--- 41,47 ----
public class SchedulerFactoryObjectTest
{
! private static readonly MethodInfo m_InitSchedulerFactory = typeof(SchedulerFactoryObject).GetMethod("InitSchedulerFactory",
! BindingFlags.Instance | BindingFlags.NonPublic);
! private MockRepository mockery;
private SchedulerFactoryObject factory;
***************
*** 262,271 ****
{
TestSchedulerFactory.Mockery.ReplayAll();
- MethodInfo mi = factory.GetType().GetMethod("InitSchedulerFactory",
- BindingFlags.Instance | BindingFlags.NonPublic);
factory.SchedulerName = "testFactoryObject";
StdSchedulerFactory factoryToPass = new StdSchedulerFactory();
! mi.Invoke(factory, new object[] { factoryToPass });
}
--- 269,308 ----
{
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]);
!
}
***************
*** 283,286 ****
--- 320,330 ----
}
+ internal class TestConfigLocation : InputStreamResource
+ {
+ public TestConfigLocation(Stream inputStream, string description) : base(inputStream, description)
+ {
+ }
+ }
+
public class TestSchedulerFactory : ISchedulerFactory
{
***************
*** 319,322 ****
--- 363,379 ----
}
+ public class InterceptingStdSChedulerFactory : StdSchedulerFactory
+ {
+ private NameValueCollection properties;
+
+ public override void Initialize(NameValueCollection props)
+ {
+ this.properties = props;
+ }
+ public NameValueCollection Properties
+ {
+ get { return properties; }
+ }
+ }
}
|