diff --git a/Spring.build b/Spring.build
index fe09c001..9b00dc03 100644
--- a/Spring.build
+++ b/Spring.build
@@ -116,10 +116,10 @@ Commandline Examples:
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Defines a base type for any required string. Defines a string with a minimum length of 0
-
-
-
-
-
-
-
-
- Element containing informative text describing the purpose of the enclosing
- element. Always optional.
- Used primarily for user documentation of XML object definition documents.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Import an external file containing object definitions into this file.
-
-
-
-
-
- Defines an additional alias name for an object definition.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Defines constructor argument.
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
- Defines property.
-
-
-
-
-
-
-
-
+
+
+ Defines property.
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
- Defines a single named object.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+ The document root. At least one object definition is required.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- The document root. At least one object definition is required.
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Spring/Spring.Data/Data/Common/dbproviders.xml b/src/Spring/Spring.Data/Data/Common/dbproviders.xml
index 38db1e91..36e66dc1 100644
--- a/src/Spring/Spring.Data/Data/Common/dbproviders.xml
+++ b/src/Spring/Spring.Data/Data/Common/dbproviders.xml
@@ -30,7 +30,7 @@
- 156,170,207,208
+ 102,156,170,207,208
229
@@ -71,7 +71,7 @@
- 156,170,207,208
+ 102,156,170,207,208
229
@@ -112,7 +112,7 @@
- 156,170,207,208
+ 102,156,170,207,208
229
diff --git a/src/Spring/Spring.Data/Transaction/Support/DefaultTransactionDefinition.cs b/src/Spring/Spring.Data/Transaction/Support/DefaultTransactionDefinition.cs
index 972c4017..186cba68 100644
--- a/src/Spring/Spring.Data/Transaction/Support/DefaultTransactionDefinition.cs
+++ b/src/Spring/Spring.Data/Transaction/Support/DefaultTransactionDefinition.cs
@@ -68,7 +68,7 @@ namespace Spring.Transaction.Support
//TODO Refactoring to sync with Spring 2.0 for nt/enums for various default values.
private TransactionPropagation _transactionPropagation = TransactionPropagation.Required;
- private IsolationLevel _transactionIsolationLevel = IsolationLevel.ReadCommitted;
+ private IsolationLevel _transactionIsolationLevel = IsolationLevel.Unspecified;
private int _timeout = DefaultTransactionDefinition.TIMEOUT_DEFAULT;
private bool _readOnly = false;
private string _name = null;
diff --git a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs
index efa3ea9f..48452f56 100644
--- a/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs
+++ b/src/Spring/Spring.Messaging.Ems/Messaging/Ems/Connections/EmsTransactionManager.cs
@@ -169,7 +169,7 @@ namespace Spring.Messaging.Ems.Connections
protected override void DoBegin(object transaction, ITransactionDefinition definition)
{
//This is the default value defined in DefaultTransactionDefinition
- if (definition.TransactionIsolationLevel != IsolationLevel.ReadCommitted)
+ if (definition.TransactionIsolationLevel != IsolationLevel.Unspecified)
{
throw new InvalidIsolationLevelException("EMS does not support an isoliation level concept");
}
diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs
index fd6542fe..cb4afc48 100644
--- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs
+++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsTransactionManager.cs
@@ -186,7 +186,7 @@ namespace Spring.Messaging.Nms.Connections
protected override void DoBegin(object transaction, ITransactionDefinition definition)
{
//This is the default value defined in DefaultTransactionDefinition
- if (definition.TransactionIsolationLevel != IsolationLevel.ReadCommitted)
+ if (definition.TransactionIsolationLevel != IsolationLevel.Unspecified)
{
throw new InvalidIsolationLevelException("NMS does not support an isoliation level concept");
}
diff --git a/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs b/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs
index 8fe88761..c48153da 100644
--- a/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs
+++ b/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs
@@ -31,18 +31,47 @@ namespace Spring.Core.TypeConversion
/// This class contains tests for TypeConversionUtils
///
/// Mark Pollack
+ /// Andreas Kluth
[TestFixture]
public class TypeConversionUtilsTests
{
-
-#if NET_2_0
[Test]
public void NullAbleTest()
{
object o = TypeConversionUtils.ConvertValueIfNecessary(typeof(DateTime?), "", "bla");
Assert.IsNull(o);
- }
-#endif
-
+ }
+
+ [Test]
+ [SetCulture( "en-US" )]
+ public void ConvertValueForDecimalMarkWithPointReturnsValue()
+ {
+ object o = TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1.2", "foo" );
+ Assert.That( o, Is.EqualTo( 1.2 ) );
+ }
+
+ [Test]
+ [SetCulture( "en-US" )]
+ public void ConvertValueForDecimalMarkWithCommaFails()
+ {
+ TestDelegate testDelegate = () => TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1,2", "foo" );
+ Assert.Throws( testDelegate );
+ }
+
+ [Test]
+ [SetCulture( "nl-NL" )]
+ public void ConvertValueWithDutchCultureForDecimalMarkWithPointReturnsValue()
+ {
+ object o = TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1.2", "foo" );
+ Assert.That( o, Is.EqualTo( 1.2 ) );
+ }
+
+ [Test]
+ [SetCulture( "nl-NL" )]
+ public void ConvertValueWithDutchCultureForDecimalMarkWithCommaReturnsValue()
+ {
+ object o = TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1,2", "foo" );
+ Assert.That( o, Is.EqualTo( 1.2 ) );
+ }
}
}
\ No newline at end of file
diff --git a/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-destroy-methods.xml b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-destroy-methods.xml
new file mode 100644
index 00000000..39a8407b
--- /dev/null
+++ b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-destroy-methods.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-initializers.xml b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-initializers.xml
new file mode 100644
index 00000000..69be468c
--- /dev/null
+++ b/test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-initializers.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs
index c9b66d4f..94869bd5 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs
@@ -1608,6 +1608,36 @@ namespace Spring.Objects.Factory
Assert.AreEqual(ExpectedAge, child.Age);
}
+ [Test]
+ public void GetObjectByTypeWithAmbiguity()
+ {
+ DefaultListableObjectFactory lbf = new DefaultListableObjectFactory();
+ RootObjectDefinition bd1 = new RootObjectDefinition(typeof(TestObject));
+ RootObjectDefinition bd2 = new RootObjectDefinition(typeof(TestObject));
+ lbf.RegisterObjectDefinition("bd1", bd1);
+ lbf.RegisterObjectDefinition("bd2", bd2);
+
+ Assert.That(delegate { lbf.GetObject(); }, Throws.Exception.TypeOf());
+ }
+
+ [Test]
+ public void GetObjectByTypeFiltersOutNonAutowireCandidates()
+ {
+ DefaultListableObjectFactory lbf = new DefaultListableObjectFactory();
+ RootObjectDefinition bd1 = new RootObjectDefinition(typeof(TestObject));
+ RootObjectDefinition bd2 = new RootObjectDefinition(typeof(TestObject));
+ RootObjectDefinition na1 = new RootObjectDefinition(typeof(TestObject));
+ na1.IsAutowireCandidate = false;
+
+ lbf.RegisterObjectDefinition("bd1", bd1);
+ lbf.RegisterObjectDefinition("na1", na1);
+ TestObject actual = lbf.GetObject(); // na1 was filtered
+ Assert.That(lbf.GetObject("bd1", typeof(TestObject)), Is.SameAs(actual));
+
+ lbf.RegisterObjectDefinition("bd2", bd2);
+ Assert.That(delegate { lbf.GetObject(); }, Throws.Exception.TypeOf());
+ }
+
[Test]
public void GetObjectDefinitionResolvesAliases()
{
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs
index 45aabde2..5fe77be8 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectDefinitionReaderTests.cs
@@ -354,5 +354,37 @@ namespace Spring.Objects.Factory.Xml
Assert.AreEqual("test1", od2.DependsOn[0]);
Assert.AreEqual(DependencyCheckingMode.Simple, od2.DependencyCheck);
}
+
+ [Test]
+ public void ParsesAutowireCandidate()
+ {
+ DefaultListableObjectFactory of = new DefaultListableObjectFactory();
+ XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
+ reader.LoadObjectDefinitions(new StringResource(
+@"
+
+
+
+
+
+
+
+"));
+ var od = (AbstractObjectDefinition)of.GetObjectDefinition("test1");
+ Assert.That(od.IsAutowireCandidate, Is.True, "No attribute set should default to true");
+
+ od = (AbstractObjectDefinition)of.GetObjectDefinition("test2");
+ Assert.That(od.IsAutowireCandidate, Is.False, "Specifically attribute set to false should set to false");
+
+ od = (AbstractObjectDefinition)of.GetObjectDefinition("test3");
+ Assert.That(od.IsAutowireCandidate, Is.True, "Specifically attribute set to true should set to false");
+
+ od = (AbstractObjectDefinition)of.GetObjectDefinition("test4");
+ Assert.That(od.IsAutowireCandidate, Is.True, "Attribute set to default should check pattern and return true");
+
+ od = (AbstractObjectDefinition)of.GetObjectDefinition("test5");
+ Assert.That(od.IsAutowireCandidate, Is.False, "Attribute set to default should check pattern and return false");
+ }
+
}
}
\ No newline at end of file
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs
index a4b772bd..55a4efa0 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlObjectFactoryTests.cs
@@ -884,6 +884,26 @@ namespace Spring.Objects.Factory.Xml
Assert.AreEqual(14, in_Renamed.Num);
}
+ [Test]
+ public void DefaultInitMethodIsInvoked()
+ {
+ IResource resource = new ReadOnlyXmlTestResource("default-initializers.xml", GetType());
+ XmlObjectFactory xof = new XmlObjectFactory(resource);
+ DoubleInitializer in_Renamed = (DoubleInitializer)xof.GetObject("init-method1");
+ // Initializer should have doubled value
+ Assert.AreEqual(14, in_Renamed.Num);
+ }
+
+ [Test]
+ public void DefaultInitMethodDisabled()
+ {
+ IResource resource = new ReadOnlyXmlTestResource("default-initializers.xml", GetType());
+ XmlObjectFactory xof = new XmlObjectFactory(resource);
+ DoubleInitializer in_Renamed = (DoubleInitializer)xof.GetObject("init-method2");
+ // Initializer should have doubled value
+ Assert.AreEqual(7, in_Renamed.Num);
+ }
+
///
/// Test that if a custom initializer throws an exception, it's handled correctly.
///
@@ -935,6 +955,30 @@ namespace Spring.Objects.Factory.Xml
Assert.IsTrue(iib.destroyed && iib.customDestroyed);
}
+ [Test]
+ public void DefaultDestroyMethodInvoked()
+ {
+ IResource resource = new ReadOnlyXmlTestResource("default-destroy-methods.xml", GetType());
+ XmlObjectFactory xof = new XmlObjectFactory(resource);
+ xof.PreInstantiateSingletons();
+ DefaultDestroyer dd = (DefaultDestroyer)xof.GetObject("destroy-method1");
+ Assert.IsTrue(!dd.customDestroyed);
+ xof.Dispose();
+ Assert.IsTrue(dd.customDestroyed);
+ }
+
+ [Test]
+ public void DefaultDestroyMethodDisabled()
+ {
+ IResource resource = new ReadOnlyXmlTestResource("default-destroy-methods.xml", GetType());
+ XmlObjectFactory xof = new XmlObjectFactory(resource);
+ xof.PreInstantiateSingletons();
+ DefaultDestroyer dd = (DefaultDestroyer)xof.GetObject("destroy-method2");
+ Assert.IsTrue(!dd.customDestroyed);
+ xof.Dispose();
+ Assert.IsTrue(!dd.customDestroyed);
+ }
+
[Test]
public void MultiThreadedLazyInit()
{
@@ -1942,6 +1986,16 @@ namespace Spring.Objects.Factory.Xml
}
}
+ public class DefaultDestroyer
+ {
+ public bool customDestroyed;
+
+ public void CustomDestroy()
+ {
+ customDestroyed = true;
+ }
+ }
+
public class InitAndIB : IInitializingObject, IDisposable
{
public static bool constructed;
diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj
index d211800e..58723712 100644
--- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj
+++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2008.csproj
@@ -265,6 +265,7 @@
+
diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj
index 521fedd1..781700f9 100644
--- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj
+++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj
@@ -267,6 +267,7 @@
+
@@ -839,6 +840,8 @@
+
+
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/AdoDaoTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/AdoDaoTests.cs
index c882a6fd..cdf1fce8 100644
--- a/test/Spring/Spring.Data.Integration.Tests/Data/AdoDaoTests.cs
+++ b/test/Spring/Spring.Data.Integration.Tests/Data/AdoDaoTests.cs
@@ -56,7 +56,7 @@ namespace Spring.Data
}
- [Ignore]
+ [Ignore("Sanity-Check tests intended for verification of base-class behavior only")]
[Test]
public void SimpleCreate()
{
@@ -68,7 +68,7 @@ namespace Spring.Data
dao.Create("John", 44);
}
- [Ignore]
+ [Ignore("Sanity-Check tests intended for verification of base-class behavior only")]
[Test]
public void SimpleDao()
{
@@ -87,7 +87,7 @@ namespace Spring.Data
}
- [Ignore]
+ [Ignore("Sanity-Check tests intended for verification of base-class behavior only")]
[Test]
public void SimpleDao2()
{
@@ -99,7 +99,7 @@ namespace Spring.Data
Assert.AreEqual(1, dao.GetCountByDelegate());
}
- [Ignore]
+ [Ignore("Sanity-Check tests intended for verification of base-class behavior only")]
[Test]
public void DaoOperations()
{
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/CreateTestObject.sql b/test/Spring/Spring.Data.Integration.Tests/Data/CreateTestObject.sql
deleted file mode 100644
index f5943fd0..00000000
--- a/test/Spring/Spring.Data.Integration.Tests/Data/CreateTestObject.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE PROCEDURE CreateTestObject
-{
- @Age int,
- @Name varchar(15)
-} AS
-
-INSERT INTO into TestObjects(Age, Name) VALUES (@Age, @Name)
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/CreditsDebitsSchema.sql b/test/Spring/Spring.Data.Integration.Tests/Data/CreditsDebitsSchema.sql
deleted file mode 100644
index 6566603a..00000000
--- a/test/Spring/Spring.Data.Integration.Tests/Data/CreditsDebitsSchema.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-USE [CreditsAndDebits]
-CREATE TABLE [Credits](
- [CreditID] [int] IDENTITY NOT NULL,
- [CreditAmount] [float] NOT NULL,
- CONSTRAINT [PK_CreditID] PRIMARY KEY CLUSTERED
-(
- [CreditID] ASC
-) ON [PRIMARY]
-) ON [PRIMARY]
-GO
-
-
-USE [CreditsAndDebits]
-GO
-CREATE TABLE [Debits](
- [DebitID] [int] IDENTITY NOT NULL,
- [DebitAmount] [float] NOT NULL,
- CONSTRAINT [PK_DebitID] PRIMARY KEY CLUSTERED
-(
- [DebitID] ASC
-) ON [PRIMARY]
-) ON [PRIMARY]
-GO
-
-
-
-USE [Credits]
-GO
-CREATE TABLE [Credits](
- [CreditID] [int] IDENTITY NOT NULL,
- [CreditAmount] [float] NOT NULL,
- CONSTRAINT [PK_CreditID] PRIMARY KEY CLUSTERED
-(
- [CreditID] ASC
-) ON [PRIMARY]
-) ON [PRIMARY]
-GO
-
-
-USE [Debits]
-GO
-CREATE TABLE [Debits](
- [DebitID] [int] IDENTITY NOT NULL,
- [DebitAmount] [float] NOT NULL,
- CONSTRAINT [PK_DebitID] PRIMARY KEY CLUSTERED
-(
- [DebitID] ASC
-) ON [PRIMARY]
-) ON [PRIMARY]
-GO
-
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/DTC1.1AppContext.xml b/test/Spring/Spring.Data.Integration.Tests/Data/DTC1.1AppContext.xml
index ea5eb9aa..0e5c4140 100644
--- a/test/Spring/Spring.Data.Integration.Tests/Data/DTC1.1AppContext.xml
+++ b/test/Spring/Spring.Data.Integration.Tests/Data/DTC1.1AppContext.xml
@@ -9,13 +9,13 @@
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContext.xml b/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContext.xml
index 14554243..a9af1df9 100644
--- a/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContext.xml
+++ b/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContext.xml
@@ -11,16 +11,16 @@
+ connectionString="Data Source=SPRINGQA;Initial Catalog=Debits;Persist Security Info=True;User ID=springqa;Password=springqa"/>
+ connectionString="Data Source=SPRINGQA;Initial Catalog=Credits;Persist Security Info=True;User ID=springqa;Password=springqa"/>
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContextNoInterfaces.xml b/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContextNoInterfaces.xml
index 5fd2c76c..e6bb7419 100644
--- a/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContextNoInterfaces.xml
+++ b/test/Spring/Spring.Data.Integration.Tests/Data/DTCAppContextNoInterfaces.xml
@@ -6,11 +6,11 @@
+ connectionString="Data Source=SPRINGQA;Initial Catalog=Credits;Integrated Security=false;User Id=springqa;Password=springqa;Pooling=False"/>
-
+ connectionString="Data Source=SPRINGQA;Initial Catalog=Debits;Integrated Security=false;User Id=springqa;Password=springqa;Pooling=False"/>
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.cs
index 1c6a8ec7..20481a3e 100644
--- a/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.cs
+++ b/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.cs
@@ -44,41 +44,63 @@ namespace Spring.Data.Generic
"assembly://Spring.Data.Integration.Tests/Spring.Data.Generic/GenericAdoTemplateTests.xml");
adoTemplate = ctx["adoTemplate"] as AdoTemplate;
+
+ RemoveTestData();
+ PopulateTestData();
}
+ private void PopulateTestData()
+ {
+ adoTemplate.ExecuteScalar(CommandType.Text, "insert into TestObjects values (10, 'Jack')");
+ adoTemplate.ExecuteScalar(CommandType.Text, "insert into TestObjects values (20, 'Jill')");
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ RemoveTestData();
+ }
+
+ private void RemoveTestData()
+ {
+ adoTemplate.ExecuteNonQuery(CommandType.Text, "delete TestObjects");
+ }
+
+
[Test]
public void CommandDelegateUsage()
{
- string postalCode = "1010";
+ string name = "Jack";
int count = adoTemplate.Execute(delegate(DbCommand command)
{
command.CommandText =
- "select count(*) from Customers where PostalCode = @PostalCode";
+ "select count(*) from TestObjects where Name = @Name";
DbParameter p = command.CreateParameter();
- p.ParameterName = "@PostalCode";
- p.Value = postalCode;
+ p.ParameterName = "@Name";
+ p.Value = name;
command.Parameters.Add(p);
return (int) command.ExecuteScalar();
});
- Assert.AreEqual(3, count);
+ Assert.AreEqual(1, count);
}
+ [Test]
public void CommandDelegateUsageDownCast()
{
- string postalCode = "1010";
+ string name = "Jack";
int count = adoTemplate.Execute(delegate(DbCommand command)
{
SqlCommand sqlCommand = command as SqlCommand;
command.CommandText =
- "select count(*) from Customers where PostalCode = @PostalCode";
+ "select count(*) from TestObjects where Name = @Name";
- sqlCommand.Parameters.AddWithValue("@PostalCode", postalCode);
+ sqlCommand.Parameters.AddWithValue("@Name", name);
return (int) command.ExecuteScalar();
});
- Assert.AreEqual(3, count);
+ Assert.AreEqual(1, count);
}
[Test]
diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml b/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml
index 852a0163..fce7fffd 100644
--- a/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml
+++ b/test/Spring/Spring.Data.Integration.Tests/Data/Generic/GenericAdoTemplateTests.xml
@@ -4,7 +4,7 @@
+ connectionString="Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/>