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 @@ + + + + + + + 7 + + + + + + 7 + + + + 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 @@ + value="Data Source=SPRINGQA;Initial Catalog=Credits;Integrated Security=false;User Id=springqa;Password=springqa"/> + value="Data Source=SPRINGQA;Initial Catalog=Debits;Integrated Security=false;User Id=springqa;Password=springqa"/> 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"/> diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/ITestObjectManager.cs b/test/Spring/Spring.Data.Integration.Tests/Data/ITestObjectManager.cs index 1ad32bd3..40a4f4eb 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/ITestObjectManager.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/ITestObjectManager.cs @@ -7,5 +7,7 @@ namespace Spring.Data void SaveTwoTestObjects(TestObject to1, TestObject to2); void DeleteTwoTestObjects(string name1, string name2); + + void DeleteAllTestObjects(); } } \ No newline at end of file diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/MappingAdoQueryTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/MappingAdoQueryTests.cs index 55a5001f..eec9bcb1 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/MappingAdoQueryTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/MappingAdoQueryTests.cs @@ -27,73 +27,97 @@ using NUnit.Framework; using Spring.Context; using Spring.Context.Support; using Spring.Data.Common; +using Spring.Objects; #endregion namespace Spring.Data { - /// - /// Test a MappingAdoQuery implementation - /// - /// Mark Pollack (.NET) - [TestFixture] - public class MappingAdoQueryTests - { - #region Fields - IDbProvider dbProvider; - #endregion + /// + /// Test a MappingAdoQuery implementation + /// + /// Mark Pollack (.NET) + [TestFixture] + public class MappingAdoQueryTests + { + #region Fields + IDbProvider dbProvider; + #endregion - #region Constants + #region Constants - /// - /// The shared ILog instance for this class (and derived classes). - /// - protected static readonly ILog log = - LogManager.GetLogger(typeof (MappingAdoQueryTests)); + /// + /// The shared ILog instance for this class (and derived classes). + /// + protected static readonly ILog log = + LogManager.GetLogger(typeof(MappingAdoQueryTests)); - #endregion + private IApplicationContext ctx; - #region Constructor (s) - /// - /// Initializes a new instance of the class. - /// - public MappingAdoQueryTests() - { + #endregion - } + #region Constructor (s) + /// + /// Initializes a new instance of the class. + /// + public MappingAdoQueryTests() + { - #endregion + } - #region Properties + #endregion - #endregion + #region Properties - #region Methods + #endregion + + #region Methods [SetUp] public void CreateDbProvider() { - IApplicationContext ctx = - new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/adoTemplateTests.xml"); + ctx = new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/adoTemplateTests.xml"); Assert.IsNotNull(ctx); dbProvider = ctx["DbProvider"] as IDbProvider; Assert.IsNotNull(dbProvider); + + DeleteTestData(); + PopulateTestData(); + } + + private void PopulateTestData() + { + ITestObjectManager testObjectManager = ctx["testObjectManager"] as ITestObjectManager; + testObjectManager.SaveTwoTestObjects(new TestObject("Jack", 10), new TestObject("Jill", 20)); + } + + [TearDown] + public void _TestTearDown() + { + DeleteTestData(); + } + + private void DeleteTestData() + { + ITestObjectManager testObjectManager = ctx["testObjectManager"] as ITestObjectManager; + testObjectManager.DeleteAllTestObjects(); + } + + + [Test] + public void MappingAdoQuery() + { + TestObjectQuery testObjectQuery = new TestObjectQuery(dbProvider); + IDictionary inParams = new Hashtable(); + inParams.Add("@Name", "Jack"); + IList testObjectList = testObjectQuery.QueryByNamedParam(inParams); + Assert.AreEqual(1, testObjectList.Count); } - - [Test] - public void MappingAdoQuery() - { - TestObjectQuery testObjectQuery = new TestObjectQuery(dbProvider); - IDictionary inParams = new Hashtable(); - inParams.Add("UName", "George"); - IList testObjectList = testObjectQuery.QueryByNamedParam(inParams); - Assert.AreEqual(2, testObjectList.Count); - } - #endregion + #endregion - - } + + } } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/NativeAdoTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/NativeAdoTests.cs index 1eb815ca..35cfee39 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/NativeAdoTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/NativeAdoTests.cs @@ -31,10 +31,10 @@ using Spring.Context.Support; namespace Spring.Data { - [TestFixture] - public class NativeAdoTests - { - [Test] + [TestFixture] + public class NativeAdoTests + { + [Test] public void SimpleUsage() { IApplicationContext ctx = @@ -45,21 +45,18 @@ namespace Spring.Data dao.Create("John", 45); } - [Test] - public void Helloworld() - { - string connString = - @"Data Source=MARKT60\SQL2005;Initial Catalog=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"; + [Test] + public void Helloworld() + { + string connString = + @"Data Source=SPRINGQA;Initial Catalog=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"; - SqlConnection conn = new SqlConnection(connString); - conn.Open(); + SqlConnection conn = new SqlConnection(connString); conn.Open(); - //conn.BeginTransaction(IsolationLevel.Unspecified); - SqlTransaction trans = conn.BeginTransaction(); - Console.WriteLine(trans.IsolationLevel); + //conn.BeginTransaction(IsolationLevel.Unspecified); + SqlTransaction trans = conn.BeginTransaction(); - - - } - } + Assert.That(trans.IsolationLevel, Is.EqualTo(IsolationLevel.ReadCommitted)); + } + } } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/NestedTxScopeTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/NestedTxScopeTests.cs index b7bfe6a9..6ab2e40c 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/NestedTxScopeTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/NestedTxScopeTests.cs @@ -48,7 +48,7 @@ namespace Spring.Data public void TxTemplate() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); - dbProvider.ConnectionString = @"Data Source=MARKT60\SQL2005;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; + dbProvider.ConnectionString = @"Data Source=SPRINGQA;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; //IPlatformTransactionManager tm = new ServiceDomainPlatformTransactionManager(); //IPlatformTransactionManager tm = new TxScopeTransactionManager(); IPlatformTransactionManager tm = new AdoPlatformTransactionManager(dbProvider); @@ -95,7 +95,7 @@ namespace Spring.Data using (SqlConnection cn2005 = new SqlConnection()) { cn2005.ConnectionString = - @"Data Source=MARKT60\SQL2005;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; + @"Data Source=SPRINGQA;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; SqlCommand cmd = new SqlCommand(updateSql1, cn2005); cn2005.Open(); cmd.ExecuteNonQuery(); @@ -118,7 +118,7 @@ namespace Spring.Data System.Transactions.Transaction.Current.TransactionInformation.LocalIdentifier); using (SqlConnection cn2005 = new SqlConnection()) { - cn2005.ConnectionString = @"Data Source=MARKT60\SQL2005;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; + cn2005.ConnectionString = @"Data Source=SPRINGQA;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; SqlCommand cmd = new SqlCommand(updateSql2, cn2005); cn2005.Open(); cmd.ExecuteNonQuery(); @@ -153,7 +153,7 @@ namespace Spring.Data using (SqlConnection cn2005 = new SqlConnection()) { - cn2005.ConnectionString = @"Data Source=MARKT60\SQL2005;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; + cn2005.ConnectionString = @"Data Source=SPRINGQA;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; SqlCommand cmd = new SqlCommand(updateSql2, cn2005); cn2005.Open(); cmd.ExecuteNonQuery(); diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Northwind/NativeAdoShipperDao.cs b/test/Spring/Spring.Data.Integration.Tests/Data/Northwind/NativeAdoShipperDao.cs index 8959c387..51136d1d 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/Northwind/NativeAdoShipperDao.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/Northwind/NativeAdoShipperDao.cs @@ -35,7 +35,7 @@ namespace Spring.Data.Northwind public Shipper Create(string name, string phone) { - string connectionString = "Data Source=NYCSUMPOLLL;Initial Catalog=Northwind;Persist Security Info=True;User ID=springqa"; + string connectionString = "Data Source=SPRINGQA;Initial Catalog=Northwind;Persist Security Info=True;User ID=springqa;Password=springqa"; int id = 0; using (SqlConnection connection = new SqlConnection(connectionString)) { @@ -66,7 +66,7 @@ namespace Spring.Data.Northwind public Shipper CreateShorter(string name, string phone) { - string connectionString = "Data Source=NYCSUMPOLLL;Initial Catalog=Northwind;Persist Security Info=True;User ID=springqa"; + string connectionString = "Data Source=SPRINGQA;Initial Catalog=Northwind;Persist Security Info=True;User ID=springqa"; int id = 0; using (SqlConnection connection = new SqlConnection(connectionString)) { diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Objects/Generic/StoredProcedureTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/Objects/Generic/StoredProcedureTests.cs index f58027e5..6a46e70b 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/Objects/Generic/StoredProcedureTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/Objects/Generic/StoredProcedureTests.cs @@ -24,6 +24,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Data; using System.Reflection; using NUnit.Framework; using Spring.Data.Common; @@ -41,11 +42,64 @@ namespace Spring.Data.Objects.Generic [TestFixture] public class StoredProcedureTests { + private IDbProvider _dbProvider; + [SetUp] public void Setup() { + _dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); + _dbProvider.ConnectionString = + @"Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"; + + IDbCommand command = _dbProvider.CreateCommand(); + command.Connection = _dbProvider.CreateConnection(); + + ClearTestData(command); + CreateTestData(command); } + [TearDown] + public void TearDown() + { + IDbCommand command = _dbProvider.CreateCommand(); + command.Connection = _dbProvider.CreateConnection(); + + ClearTestData(command); + } + + private void CreateTestData(IDbCommand command) + { + command.Connection.Open(); + + command.CommandText = "insert into TestObjects(Name,Age) values ('Jack', 10)"; + command.ExecuteNonQuery(); + + command.CommandText = "insert into TestObjects(Name,Age) values ('Jill', 20)"; + command.ExecuteNonQuery(); + + command.CommandText = "insert into Vacations(FirstName,LastName,EmployeeId,StartDate,EndDate) values ('Jack', 'Doe', 200, '1/1/2010', '1/15/2010')"; + command.ExecuteNonQuery(); + + command.CommandText = "insert into Vacations(FirstName,LastName,EmployeeId,StartDate,EndDate) values ('Jack', 'Doe', 200, '2/1/2010', '2/15/2010')"; + command.ExecuteNonQuery(); + + command.Connection.Close(); + } + + private void ClearTestData(IDbCommand command) + { + command.Connection.Open(); + + command.CommandText = "truncate table TestObjects"; + command.ExecuteNonQuery(); + + command.CommandText = "truncate table Vacations"; + command.ExecuteNonQuery(); + + command.Connection.Close(); + } + + [Test] public void TestReflection() { @@ -102,36 +156,38 @@ namespace Spring.Data.Objects.Generic MethodInfo methodInfo = rowMapperclosedType.GetMethod("MapRow", BINDING_FLAGS); //MethodInfo genMethodInfo = methodInfo.MakeGenericMethod(genericArgumentType); - object retVal = methodInfo.Invoke(rowmapper, new object[] { null, null}); + object retVal = methodInfo.Invoke(rowmapper, new object[] { null, null }); Console.WriteLine("return val = " + retVal); } [Test] - public void Test() + public void SingleTableStoredProcedure_ReturnsResult() { - IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); - dbProvider.ConnectionString = - @"Data Source=MARKT60\SQL2005;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"; + TestObjectStoredProc sp = new TestObjectStoredProc(_dbProvider); + IList testObjectList = sp.GetByName("Jack"); - TestObjectStoredProc sp = new TestObjectStoredProc(dbProvider); - IList testObjectList = sp.GetByName("George"); - - Assert.IsNotNull(testObjectList); - - TestObjectandVacationStoredProc vsp = new TestObjectandVacationStoredProc(dbProvider); - - System.Collections.IDictionary outParams = vsp.ExecStoreProc("George"); + Assert.That(testObjectList, Is.Not.Null); + Assert.That(testObjectList, Has.Count.EqualTo(1)); + } - testObjectList = outParams["testObjectRowMapper"] as IList; + [Test] + public void MultipleTableStoredProcedure_ReturnsResult() + { + TestObjectandVacationStoredProc vsp = new TestObjectandVacationStoredProc(_dbProvider); + + IDictionary outParams = vsp.ExecStoreProc("Jack"); + + IList testObjectList = testObjectList = outParams["testObjectRowMapper"] as IList; Assert.IsNotNull(testObjectList); Assert.AreEqual(1, testObjectList.Count); IList vacationList = outParams["vacationRowMapper"] as IList; Assert.IsNotNull(vacationList); Assert.AreEqual(2, vacationList.Count); + } } @@ -153,14 +209,14 @@ namespace Spring.Data.Objects.Generic } } - + public class TestObjectStoredProc : StoredProcedure { public TestObjectStoredProc(IDbProvider dbProvider) : base(dbProvider, "SelectByName") - { + { DeriveParameters(); - AddRowMapper("testObjectRowMapper", new TestObjectRowMapper() ); + AddRowMapper("testObjectRowMapper", new TestObjectRowMapper()); Compile(); } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/OracleAdoTemplateTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/OracleAdoTemplateTests.cs index 42593adb..92dff1cf 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/OracleAdoTemplateTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/OracleAdoTemplateTests.cs @@ -42,6 +42,7 @@ namespace Spring.Data /// /// Mark Pollack (.NET) [TestFixture] + [Ignore("ORACLE-dependent tests disabled for integration runs")] public class OracleAdoTemplateTests { #region Setup/Teardown diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/SQLiteTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/SQLiteTests.cs index fbaa45b8..1a9f261b 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/SQLiteTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/SQLiteTests.cs @@ -53,43 +53,45 @@ namespace Spring.Data public void SqlServerTest() { string errorCode = "544"; - string[] errorCodes = new string[4] {"544", "2627", "8114", "8115"}; + string[] errorCodes = new string[4] { "544", "2627", "8114", "8115" }; //Array.IndexOf() //Array.Sort(errorCodes); foreach (string code in errorCodes) { Console.WriteLine(code); } - //if (Array.BinarySearch(errorCodes, errorCode) >= 0) + //if (Array.BinarySearch(errorCodes, errorCode) >= 0) if (Array.IndexOf(errorCodes, errorCode) >= 0) - { - Console.WriteLine("yes"); - } - else - { - Assert.Fail("did not find error code"); - } + { + Console.WriteLine("yes"); + } + else + { + Assert.Fail("did not find error code"); + } IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient"); dbProvider.ConnectionString = - @"Data Source=MARKT60\SQL2005;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa"; + @"Data Source=SPRINGQA;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa"; AdoTemplate adoTemplate = new AdoTemplate(dbProvider); try { - adoTemplate.ExecuteNonQuery(CommandType.Text, "insert into Vacation (id) values (1)"); - } catch (Exception e) + adoTemplate.ExecuteNonQuery(CommandType.Text, "insert into Vacations (FirstName,LastName) values ('Jack','Doe')"); + } + catch (Exception e) { Console.Write(e); throw; } } [Test] + [Ignore("ORACLE-dependent tests disabled for integration runs")] public void OracleTest() { //Data Source=XE;User ID=hr;Unicode=True IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.OracleClient"); dbProvider.ConnectionString = "Data Source=XE;User ID=hr;Password=hr;Unicode=True"; AdoTemplate adoTemplate = new AdoTemplate(dbProvider); - decimal count = (decimal) adoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from emp"); + decimal count = (decimal)adoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from emp"); Assert.AreEqual(14, count); EmpProc empProc = new EmpProc(dbProvider); @@ -107,6 +109,7 @@ namespace Spring.Data } [Test] + [Ignore("ODBC-dependent tests disabled for integration runs")] public void Test() { //IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse1.15"); @@ -127,52 +130,53 @@ namespace Spring.Data } Assert.IsTrue(authorList.Count > 0); } -/* - [Test] - public void StoredProc() - { - //IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse1.15"); - //dbProvider.ConnectionString = "Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';"; - - - //IDbProvider dbProvider = DbProviderFactory.GetDbProvider("Odbc-2.0"); - //dbProvider.ConnectionString = - // "Driver={Adaptive Server Enterprise};server=MARKT60;port=5000;Database=pubs2;uid=sa;pwd=;"; - - IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse-15"); - dbProvider.ConnectionString = "Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';"; - HelloProc proc = new HelloProc(dbProvider); - IDictionary dict = proc.GetResults(); - - Assert.AreEqual("Go Sybase", dict["@inoutParam"]); - Assert.AreEqual("Hello mango", dict["@outParam"]); - Assert.AreEqual(101, (int) dict["RETURN_VALUE"]); - foreach (DictionaryEntry entry in dict) - { - Console.WriteLine("Key = " + entry.Key + ", Value = " + entry.Value); - } - } - - [Test] - public void StordProcAdoTemplate() - { - IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse-15"); - dbProvider.ConnectionString = "Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';"; - AdoTemplate adoTemplate = new AdoTemplate(dbProvider); - IDbParameters parameters = new DbParameters(dbProvider); - parameters.Add("inParam", AseDbType.VarChar, 32).Value = "mango"; - parameters.AddInOut("inoutParam", AseDbType.VarChar, 64).Value = "Sybase"; - parameters.AddOut("outParam", AseDbType.VarChar, 64); - parameters.AddReturn("retValue", AseDbType.Integer); - adoTemplate.ExecuteNonQuery(CommandType.StoredProcedure, "sp_hello", parameters); - - - Assert.AreEqual("Go Sybase", parameters["@inoutParam"].Value); - Assert.AreEqual("Hello mango", parameters[2].Value); - Assert.AreEqual(101, (int) parameters[3].Value); - } -*/ + /* + [Test] + public void StoredProc() + { + //IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse1.15"); + //dbProvider.ConnectionString = "Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';"; + + + //IDbProvider dbProvider = DbProviderFactory.GetDbProvider("Odbc-2.0"); + //dbProvider.ConnectionString = + // "Driver={Adaptive Server Enterprise};server=MARKT60;port=5000;Database=pubs2;uid=sa;pwd=;"; + + IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse-15"); + dbProvider.ConnectionString = "Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';"; + HelloProc proc = new HelloProc(dbProvider); + IDictionary dict = proc.GetResults(); + + Assert.AreEqual("Go Sybase", dict["@inoutParam"]); + Assert.AreEqual("Hello mango", dict["@outParam"]); + Assert.AreEqual(101, (int) dict["RETURN_VALUE"]); + foreach (DictionaryEntry entry in dict) + { + Console.WriteLine("Key = " + entry.Key + ", Value = " + entry.Value); + } + } + + [Test] + public void StordProcAdoTemplate() + { + IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse-15"); + dbProvider.ConnectionString = "Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';"; + AdoTemplate adoTemplate = new AdoTemplate(dbProvider); + IDbParameters parameters = new DbParameters(dbProvider); + parameters.Add("inParam", AseDbType.VarChar, 32).Value = "mango"; + parameters.AddInOut("inoutParam", AseDbType.VarChar, 64).Value = "Sybase"; + parameters.AddOut("outParam", AseDbType.VarChar, 64); + parameters.AddReturn("retValue", AseDbType.Integer); + adoTemplate.ExecuteNonQuery(CommandType.StoredProcedure, "sp_hello", parameters); + + + Assert.AreEqual("Go Sybase", parameters["@inoutParam"].Value); + Assert.AreEqual("Hello mango", parameters[2].Value); + Assert.AreEqual(101, (int) parameters[3].Value); + } + */ [Test] + [Ignore("SYBASE-ASE-dependent tests disabled for integration runs")] public void DeriveParams() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse-15"); @@ -190,25 +194,26 @@ namespace Spring.Data } } -/* - [Test] - public void RawDeriveParams() - { - using ( - AseConnection conn = - new AseConnection("Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';")) - { - using (AseCommand cmd = new AseCommand("@sp_hello", conn)) + /* + [Test] + public void RawDeriveParams() { - conn.Open(); - cmd.CommandType = CommandType.StoredProcedure; - AseCommandBuilder.DeriveParameters(cmd); - Console.WriteLine("Number of parameters = " + cmd.Parameters.Count); + using ( + AseConnection conn = + new AseConnection("Data Source='MARKT60';Port='5000';UID='sa';PWD='';Database='pubs2';")) + { + using (AseCommand cmd = new AseCommand("@sp_hello", conn)) + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + AseCommandBuilder.DeriveParameters(cmd); + Console.WriteLine("Number of parameters = " + cmd.Parameters.Count); + } + } } - } - } -*/ + */ [Test] + [Ignore("SYBASE-ASE-dependent tests disabled for integration runs")] public void QueryWithMapper() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("SybaseAse-15"); @@ -219,6 +224,7 @@ namespace Spring.Data } [Test] + [Ignore("ODBC-dependent tests disabled for integration runs")] public void QueryWithMapperODBC() { IDbProvider dbProvider = DbProviderFactory.GetDbProvider("Odbc-2.0"); @@ -230,6 +236,7 @@ namespace Spring.Data } [Test] + [Ignore("SYBASE-ASE-dependent tests disabled for integration runs")] public void QueryRawODBC() { using ( @@ -267,17 +274,17 @@ namespace Spring.Data { return AdoTemplate.QueryWithRowMapperDelegate(CommandType.StoredProcedure, "history_proc", delegate(IDataReader dataReader, int rowNum) - { - Sale sale = new Sale(); - sale.Date = dataReader.GetDateTime(0); - sale.OrderNumber = dataReader.GetString(1); - sale.Quantity = dataReader.GetInt32(2); - sale.Title = dataReader.GetString(3); - sale.Discount = dataReader.GetFloat(4); - sale.Price = dataReader.GetFloat(5); - sale.Total = dataReader.GetFloat(6); - return sale; - }, "stor_id", + { + Sale sale = new Sale(); + sale.Date = dataReader.GetDateTime(0); + sale.OrderNumber = dataReader.GetString(1); + sale.Quantity = dataReader.GetInt32(2); + sale.Title = dataReader.GetString(3); + sale.Discount = dataReader.GetFloat(4); + sale.Price = dataReader.GetFloat(5); + sale.Total = dataReader.GetFloat(6); + return sale; + }, "stor_id", DbType.String, 0, storeId); } } @@ -335,27 +342,28 @@ namespace Spring.Data set { total = value; } } } -/* - public class HelloProc : StoredProcedure - { - public HelloProc(IDbProvider provider) : base(provider, "sp_hello") + /* + public class HelloProc : StoredProcedure { - DeclaredParameters.Add("inParam", AseDbType.VarChar, 32).Value = "mango"; - DeclaredParameters.AddInOut("inoutParam", AseDbType.VarChar, 64).Value = "Sybase"; - DeclaredParameters.AddOut("outParam", AseDbType.VarChar, 64); - DeclaredParameters.AddReturn("retValue", AseDbType.Integer); - Compile(); - } + public HelloProc(IDbProvider provider) : base(provider, "sp_hello") + { + DeclaredParameters.Add("inParam", AseDbType.VarChar, 32).Value = "mango"; + DeclaredParameters.AddInOut("inoutParam", AseDbType.VarChar, 64).Value = "Sybase"; + DeclaredParameters.AddOut("outParam", AseDbType.VarChar, 64); + DeclaredParameters.AddReturn("retValue", AseDbType.Integer); + Compile(); + } - public IDictionary GetResults() - { - return Query("mango", "Sybase"); + public IDictionary GetResults() + { + return Query("mango", "Sybase"); + } } - } -*/ + */ public class EmpProc : StoredProcedure { - public EmpProc(IDbProvider provider) : base(provider, "TEST.Get1CurOut") + public EmpProc(IDbProvider provider) + : base(provider, "TEST.Get1CurOut") { //DeriveParameters(); DeclaredParameters.AddOut("P_CURSOR1", OracleType.Cursor); @@ -365,7 +373,7 @@ namespace Spring.Data public IDictionary GetEmployees() { - for (int i=0; i< DeclaredParameters.Count; i++) + for (int i = 0; i < DeclaredParameters.Count; i++) { Console.WriteLine("decarled parameter name = " + DeclaredParameters[i].ParameterName + ", type = " + DeclaredParameters[i].DbType); } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_CreditsAndDebits_database.sql b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_CreditsAndDebits_database.sql new file mode 100644 index 00000000..b0ade120 Binary files /dev/null and b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_CreditsAndDebits_database.sql differ diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Credits_database.sql b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Credits_database.sql new file mode 100644 index 00000000..cdd7dffe Binary files /dev/null and b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Credits_database.sql differ diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Debits_database.sql b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Debits_database.sql new file mode 100644 index 00000000..5c7b2e6f Binary files /dev/null and b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Debits_database.sql differ diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Spring_database.sql b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Spring_database.sql new file mode 100644 index 00000000..50b2b976 Binary files /dev/null and b/test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Spring_database.sql differ diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/Support/SimpleExceptionTranslationTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/Support/SimpleExceptionTranslationTests.cs index e0e19c8a..7058602e 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/Support/SimpleExceptionTranslationTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/Support/SimpleExceptionTranslationTests.cs @@ -33,58 +33,60 @@ using Spring.Data.Core; namespace Spring.Data.Support { - [TestFixture] - public class SimpleExceptionTranslationTests - { - #region Fields - private IDbProvider dbProvider; - private IAdoOperations adoOperations; - #endregion + [TestFixture] + public class SimpleExceptionTranslationTests + { + #region Fields + private IDbProvider dbProvider; + private IAdoOperations adoOperations; + #endregion - #region Constants + #region Constants - /// - /// The shared ILog instance for this class (and derived classes). - /// - protected static readonly ILog log = - LogManager.GetLogger(typeof (SimpleExceptionTranslationTests)); + /// + /// The shared ILog instance for this class (and derived classes). + /// + protected static readonly ILog log = + LogManager.GetLogger(typeof(SimpleExceptionTranslationTests)); - #endregion + #endregion - #region Methods + #region Methods - [SetUp] + [SetUp] public void CreateAdoTemplate() { - IApplicationContext ctx = + IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/adoTemplateTests.xml"); Assert.IsNotNull(ctx); dbProvider = ctx["DbProvider"] as IDbProvider; Assert.IsNotNull(dbProvider); adoOperations = new AdoTemplate(dbProvider); } - + [Test] public void ExecuteNonQueryText() { - + string badSql = "insert into TestObjects(Age, Name) VALS (33, 'foo')"; try { adoOperations.ExecuteNonQuery(CommandType.Text, badSql); - } catch (BadSqlGrammarException e) + } + catch (BadSqlGrammarException e) { - + log.Error("caught correct exception", e); - } catch (Exception e) + } + catch (Exception e) { log.Error("caught incorrect exception ", e); Assert.Fail("did not throw exception of type BadSqlGrammerException"); } - - } - #endregion - } + } + #endregion + + } } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectManager.cs b/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectManager.cs index 12c4e741..7c7a7554 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectManager.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectManager.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Collections; using Common.Logging; using Spring.Objects; using Spring.Transaction.Interceptor; @@ -82,7 +83,20 @@ namespace Spring.Data testObjectDao.Delete(name2); } - #endregion + public void DeleteAllTestObjects() + { + IList objects = testObjectDao.FindAll(); + + foreach (object testObject in objects) + { + if (testObject is ITestObject) + { + testObjectDao.Delete(((ITestObject)testObject).Name); + } + } + } + + #endregion } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectQuery.cs b/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectQuery.cs index 9d78429e..cb3b5505 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectQuery.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/TestObjectQuery.cs @@ -36,7 +36,7 @@ namespace Spring.Data /// Mark Pollack (.NET) public class TestObjectQuery : MappingAdoQuery { - private static string sql = "select TestObjectNo, Age, Name from TestObjects where Name = @UName"; + private static string sql = "select TestObjectNo, Age, Name from TestObjects where Name = @Name"; public TestObjectQuery(IDbProvider dbProvider) : base(dbProvider, sql) @@ -44,7 +44,7 @@ namespace Spring.Data //DeclaredParameters = new DbParameters(dbProvider); try { - DeclaredParameters.Add("UName", SqlDbType.VarChar, 50); + DeclaredParameters.Add("Name", SqlDbType.VarChar, 50); } catch (Exception e) { Console.WriteLine(e); diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevel.xml b/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevel.xml index 49bc9d6f..90f24381 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevel.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevel.xml @@ -7,7 +7,7 @@ + connectionString="Data Source=SPRINGQA;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa"/> diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevelTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevelTests.cs index b879d6a4..b572c225 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevelTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/TestTxIsolationLevelTests.cs @@ -80,7 +80,7 @@ namespace Spring.Data using (SqlConnection cn2005 = new SqlConnection()) { cn2005.ConnectionString = - @"Data Source=MARKT60\SQL2005;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; + @"Data Source=SPRINGQA;Initial Catalog=CreditsAndDebits;User ID=springqa; Password=springqa"; SqlCommand cmd = new SqlCommand(updateSql2, cn2005); cn2005.Open(); Console.WriteLine("Isolation level = " + System.Transactions.Transaction.Current.IsolationLevel); diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/TransactionTemplateTests.cs b/test/Spring/Spring.Data.Integration.Tests/Data/TransactionTemplateTests.cs index 4a1686f1..0f166319 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/TransactionTemplateTests.cs +++ b/test/Spring/Spring.Data.Integration.Tests/Data/TransactionTemplateTests.cs @@ -35,21 +35,21 @@ using Spring.Transaction.Support; namespace Spring.Data { - /// - /// Integration tests for transaction template functionality - /// - /// Mark Pollack - [TestFixture] - public class TransactionTemplateTests - { + /// + /// Integration tests for transaction template functionality + /// + /// Mark Pollack + [TestFixture] + public class TransactionTemplateTests + { private IDbProvider dbProvider; private IPlatformTransactionManager transactionManager; private IApplicationContext ctx; - - private IAdoOperations adoOperations; + + private IAdoOperations adoOperations; [SetUp] public void SetUp() @@ -57,9 +57,20 @@ namespace Spring.Data ctx = new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/templateTests.xml"); dbProvider = ctx["DbProvider"] as IDbProvider; - transactionManager = ctx["adoTransactionManager"] as IPlatformTransactionManager; + transactionManager = ctx["transactionManager"] as IPlatformTransactionManager; adoOperations = ctx["adoTemplate"] as IAdoOperations; - + + ITestObjectManager testObjectManager = ctx["testObjectManager"] as ITestObjectManager; + testObjectManager.DeleteAllTestObjects(); + testObjectManager.SaveTwoTestObjects(new TestObject("Jack", 10), new TestObject("Jill", 20)); + } + + [TearDown] + public void TearDown() + { + ITestObjectManager testObjectManager = ctx["testObjectManager"] as ITestObjectManager; + testObjectManager.DeleteTwoTestObjects("Jack", "Jill"); + testObjectManager.DeleteAllTestObjects(); } @@ -73,7 +84,7 @@ namespace Spring.Data [Test] public void DeclarativeViaAutoProxyCreator() { - ITestObjectManager mgr = ctx["testObjectManager"] as ITestObjectManager; + ITestObjectManager mgr = ctx["testObjectManager"] as ITestObjectManager; TestObjectDao dao = (TestObjectDao)ctx["testObjectDao"]; PerformOperations(mgr, dao); } @@ -88,7 +99,7 @@ namespace Spring.Data [Test] public void DeclarativeViaTransactionProxyFactoryObject() { - ITestObjectManager mgr = ctx["testObjectManagerTP"] as ITestObjectManager; + ITestObjectManager mgr = ctx["testObjectManagerTP"] as ITestObjectManager; ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDao"]; PerformOperations(mgr, dao); } @@ -102,7 +113,7 @@ namespace Spring.Data public void DeclarativeViaProxyFactoryObject() { ITestObjectManager mgr = ctx["testObjectManagerPF"] as ITestObjectManager; - TestObjectDao dao = (TestObjectDao)ctx["testObjectDao"]; + TestObjectDao dao = (TestObjectDao)ctx["testObjectDao"]; PerformOperations(mgr, dao); } @@ -121,35 +132,35 @@ namespace Spring.Data coordinator.TestObjectManager.DeleteTwoTestObjects("Jack", "Jill"); } - public static void PerformOperations(ITestObjectManager mgr, + public static void PerformOperations(ITestObjectManager mgr, ITestObjectDao dao) - { - Assert.IsNotNull(mgr); - TestObject to1 = new TestObject(); - to1.Name = "Jack"; - to1.Age = 7; - TestObject to2 = new TestObject(); - to2.Name = "Jill"; - to2.Age = 8; - mgr.SaveTwoTestObjects(to1, to2); - - TestObject to = dao.FindByName("Jack"); - Assert.IsNotNull(to); - - to = dao.FindByName("Jill"); - Assert.IsNotNull(to); - Assert.AreEqual("Jill", to.Name); - - mgr.DeleteTwoTestObjects("Jack", "Jill"); - - to = dao.FindByName("Jack"); - Assert.IsNull(to); - - to = dao.FindByName("Jill"); - Assert.IsNull(to); - } + { + Assert.IsNotNull(mgr); + TestObject to1 = new TestObject(); + to1.Name = "Jack"; + to1.Age = 7; + TestObject to2 = new TestObject(); + to2.Name = "Jill"; + to2.Age = 8; + mgr.SaveTwoTestObjects(to1, to2); - [Test] + TestObject to = dao.FindByName("Jack"); + Assert.IsNotNull(to); + + to = dao.FindByName("Jill"); + Assert.IsNotNull(to); + Assert.AreEqual("Jill", to.Name); + + mgr.DeleteTwoTestObjects("Jack", "Jill"); + + to = dao.FindByName("Jack"); + Assert.IsNull(to); + + to = dao.FindByName("Jill"); + Assert.IsNull(to); + } + + [Test] public void ExecuteTemplate() { TransactionTemplate tt = new TransactionTemplate(transactionManager); @@ -164,7 +175,7 @@ namespace Spring.Data def.PropagationBehavior = TransactionPropagation.Required; ITransactionStatus status = transactionManager.GetTransaction(def); - + int iCount = 0; try { @@ -176,7 +187,8 @@ namespace Spring.Data */ //other AdoCommands can be executed within same tx. - } catch (Exception e) + } + catch (Exception e) { transactionManager.Rollback(status); throw e; @@ -186,12 +198,12 @@ namespace Spring.Data } - + private class SimpleTransactionCallback : ITransactionCallback { private IDbProvider dbProvider; - public SimpleTransactionCallback(IDbProvider dbp) + public SimpleTransactionCallback(IDbProvider dbp) { dbProvider = dbp; } @@ -207,10 +219,10 @@ namespace Spring.Data return adoTemplate.Execute(new TestCommandCallback()); } } - + private class TestCommandCallback : ICommandCallback { - + public Object DoInCommand(IDbCommand cmd) { cmd.CommandText = "SELECT COUNT(*) FROM TestObjects"; @@ -223,5 +235,5 @@ namespace Spring.Data } } - } + } } diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/adoTemplateTests.xml b/test/Spring/Spring.Data.Integration.Tests/Data/adoTemplateTests.xml index 24bfe7ad..29d0c9e6 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/adoTemplateTests.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/adoTemplateTests.xml @@ -3,17 +3,25 @@ xmlns:db="http://www.springframework.net/database"> - - - - - + + + + + + + + + \ No newline at end of file diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml b/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml index aba45ad8..c875f727 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/autoDeclarativeServices.xml @@ -7,12 +7,12 @@ + connectionString="Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/> diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/declarativeServices.xml b/test/Spring/Spring.Data.Integration.Tests/Data/declarativeServices.xml index 2e4f16ba..5239d276 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/declarativeServices.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/declarativeServices.xml @@ -4,7 +4,7 @@ + connectionString="Data Source=SPRINGQA;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/> diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/nativeAdoTests.xml b/test/Spring/Spring.Data.Integration.Tests/Data/nativeAdoTests.xml index 1a68fb54..493416cc 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Data/nativeAdoTests.xml +++ b/test/Spring/Spring.Data.Integration.Tests/Data/nativeAdoTests.xml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/test/Spring/Spring.Data.Integration.Tests/Data/testobjects-sqlserver.sql b/test/Spring/Spring.Data.Integration.Tests/Data/testobjects-sqlserver.sql deleted file mode 100644 index 2ca45e5a..00000000 --- a/test/Spring/Spring.Data.Integration.Tests/Data/testobjects-sqlserver.sql +++ /dev/null @@ -1,65 +0,0 @@ - - -USE Spring -CREATE TABLE TestObjects -( - TestObjectNo int IDENTITY NOT NULL, - Age int, - Name varchar(50) -) - - -CREATE PROCEDURE SelectByName -( - @Name varchar(50) - -) - -as - select TestObjectNo, Age,Name from TestObjects where Name = @Name - -return - -CREATE PROCEDURE SelectByNameWithReturnValue -( - @Name varchar(50) - -) - -as - select * from TestObjects where Name = @Name - -return 5 - - -CREATE PROCEDURE SelectByNameWithReturnAndOutValue -( - @Name varchar(50), - @Count int output - -) - -as - select * from TestObjects where Name = @Name - set @Count = 10 -return 5 - - -CREATE PROCEDURE CreateTestObject -( - @Name varchar(50), - @Age int -) - -as - insert into TestObjects(Name, Age) Values (@Name, @Age) - - - - - -INSERT INTO TestObjects - (Age, Name) -VALUES - (1, 'Gabriel') - \ No newline at end of file diff --git a/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.2010.csproj b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.2010.csproj index a209d791..19e012c5 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.2010.csproj +++ b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.2010.csproj @@ -177,7 +177,9 @@ - + + Designer + @@ -193,10 +195,11 @@ - - - + + + + diff --git a/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.build b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.build index b1ac0b74..122e2e4b 100644 --- a/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.build +++ b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.build @@ -24,9 +24,9 @@ - - - + + + @@ -43,7 +43,6 @@ - - + diff --git a/test/Spring/Spring.Data.Tests/Data/AdoPlatformTransactionManagerTests.cs b/test/Spring/Spring.Data.Tests/Data/AdoPlatformTransactionManagerTests.cs index f4c6755f..5dc59bbf 100644 --- a/test/Spring/Spring.Data.Tests/Data/AdoPlatformTransactionManagerTests.cs +++ b/test/Spring/Spring.Data.Tests/Data/AdoPlatformTransactionManagerTests.cs @@ -45,6 +45,7 @@ namespace Spring.Data public class AdoPlatformTransactionManagerTests { private MockRepository mocks; + private IsolationLevel _defaultIsolationLevel = IsolationLevel.Unspecified; [SetUp] public void Setup() @@ -74,7 +75,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Commit(); LastCall.On(transaction).Repeat.Once(); @@ -115,7 +116,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); @@ -165,7 +166,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); @@ -237,7 +238,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection).Repeat.Twice(); connection.Open(); LastCall.On(connection).Repeat.Twice(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction).Repeat.Twice(); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction).Repeat.Twice(); //standard tx timeout. transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); @@ -279,7 +280,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); transaction.Commit(); LastCall.On(transaction).Repeat.Once(); connection.Dispose(); @@ -291,7 +292,7 @@ namespace Spring.Data Expect.Call(dbProvider2.CreateConnection()).Return(connection2); connection2.Open(); LastCall.On(connection2).Repeat.Once(); - Expect.Call(connection2.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction2); + Expect.Call(connection2.BeginTransaction(_defaultIsolationLevel)).Return(transaction2); transaction2.Rollback(); LastCall.On(transaction2).Repeat.Once(); connection2.Dispose(); @@ -334,7 +335,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); connection.Dispose(); @@ -394,7 +395,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Commit(); LastCall.On(transaction).Repeat.Once(); @@ -430,7 +431,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); @@ -481,7 +482,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection2); connection2.Open(); LastCall.On(connection2).Repeat.Once(); - Expect.Call(connection2.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction2); + Expect.Call(connection2.BeginTransaction(_defaultIsolationLevel)).Return(transaction2); transaction2.Commit(); LastCall.On(transaction2).Repeat.Once(); connection2.Dispose(); @@ -572,7 +573,7 @@ namespace Spring.Data connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); Expect.Call(connection.CreateCommand()).Return(command); command.CommandText = "some SQL statement"; LastCall.On(command).Repeat.Once(); @@ -673,7 +674,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Commit(); LastCall.On(transaction).Throw(new TestSqlException("Cannot commit", "314")); @@ -716,7 +717,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); transaction.Commit(); LastCall.On(transaction).Throw(new TestSqlException("Cannot commit", "314")); @@ -762,7 +763,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Rollback(); LastCall.On(transaction).Throw(new TestSqlException("Cannot commit", "314")); @@ -876,7 +877,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); @@ -922,7 +923,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); //standard tx timeout. transaction.Commit(); LastCall.On(transaction).Repeat.Once(); @@ -970,7 +971,7 @@ namespace Spring.Data Expect.Call(dbProvider.CreateConnection()).Return(connection); connection.Open(); LastCall.On(connection).Repeat.Once(); - Expect.Call(connection.BeginTransaction(IsolationLevel.ReadCommitted)).Return(transaction); + Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction); transaction.Rollback(); LastCall.On(transaction).Repeat.Once(); connection.Dispose(); diff --git a/test/Spring/Spring.Data.Tests/Data/Core/ServiceDomainTransactionManagerTests.cs b/test/Spring/Spring.Data.Tests/Data/Core/ServiceDomainTransactionManagerTests.cs index 6b436ecf..18e7b12f 100644 --- a/test/Spring/Spring.Data.Tests/Data/Core/ServiceDomainTransactionManagerTests.cs +++ b/test/Spring/Spring.Data.Tests/Data/Core/ServiceDomainTransactionManagerTests.cs @@ -159,7 +159,7 @@ namespace Spring.Data.Core // inner tx ConfigureServiceConfig(serviceConfig, false); serviceConfig.TransactionOption = TransactionOption.RequiresNew; - serviceConfig.IsolationLevel = TransactionIsolationLevel.ReadCommitted; + serviceConfig.IsolationLevel = TransactionIsolationLevel.Any; txAdapter.Enter(serviceConfig); Expect.Call(txAdapter.IsInTransaction).Return(true); txAdapter.SetAbort(); @@ -204,7 +204,7 @@ namespace Spring.Data.Core if (standardIsolationAndProp) { serviceConfig.TransactionOption = TransactionOption.Required; - serviceConfig.IsolationLevel = TransactionIsolationLevel.ReadCommitted; + serviceConfig.IsolationLevel = TransactionIsolationLevel.Any; } return serviceConfig; diff --git a/test/Spring/Spring.Data.Tests/Data/Core/TxScopeTransactionManagerTests.cs b/test/Spring/Spring.Data.Tests/Data/Core/TxScopeTransactionManagerTests.cs index 34004da9..18f57b1a 100644 --- a/test/Spring/Spring.Data.Tests/Data/Core/TxScopeTransactionManagerTests.cs +++ b/test/Spring/Spring.Data.Tests/Data/Core/TxScopeTransactionManagerTests.cs @@ -57,7 +57,7 @@ namespace Spring.Data.Core { Expect.Call(txAdapter.IsExistingTransaction).Return(false); TransactionOptions txOptions = new TransactionOptions(); - txOptions.IsolationLevel = IsolationLevel.ReadCommitted; + txOptions.IsolationLevel = IsolationLevel.Unspecified; txAdapter.CreateTransactionScope(TransactionScopeOption.Required, txOptions, EnterpriseServicesInteropOption.None); Expect.Call(txAdapter.RollbackOnly).Return(false); @@ -94,7 +94,7 @@ namespace Spring.Data.Core { Expect.Call(txAdapter.IsExistingTransaction).Return(false); TransactionOptions txOptions = new TransactionOptions(); - txOptions.IsolationLevel = IsolationLevel.ReadCommitted; + txOptions.IsolationLevel = IsolationLevel.Unspecified; txAdapter.CreateTransactionScope(TransactionScopeOption.Required, txOptions, EnterpriseServicesInteropOption.None); txAdapter.Dispose(); } @@ -141,7 +141,7 @@ namespace Spring.Data.Core { Expect.Call(txAdapter.IsExistingTransaction).Return(false); TransactionOptions txOptions = new TransactionOptions(); - txOptions.IsolationLevel = IsolationLevel.ReadCommitted; + txOptions.IsolationLevel = IsolationLevel.Unspecified; txAdapter.CreateTransactionScope(TransactionScopeOption.RequiresNew, txOptions, EnterpriseServicesInteropOption.None); //inner tx actions diff --git a/test/Spring/Spring.Data.Tests/Transaction/Interceptor/DefaultTransactionAttributeTests.cs b/test/Spring/Spring.Data.Tests/Transaction/Interceptor/DefaultTransactionAttributeTests.cs index e43e933d..6a154af5 100644 --- a/test/Spring/Spring.Data.Tests/Transaction/Interceptor/DefaultTransactionAttributeTests.cs +++ b/test/Spring/Spring.Data.Tests/Transaction/Interceptor/DefaultTransactionAttributeTests.cs @@ -18,7 +18,7 @@ namespace Spring.Transaction.Interceptor public void ToStringTests() { DefaultTransactionAttribute dta = new DefaultTransactionAttribute(); - Assert.AreEqual( "PROPAGATION_Required,ISOLATION_ReadCommitted,-System.Exception", dta.ToString()); + Assert.AreEqual( "PROPAGATION_Required,ISOLATION_Unspecified,-System.Exception", dta.ToString()); } } } diff --git a/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeEditorTests.cs b/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeEditorTests.cs index c5e87b5a..441c0132 100644 --- a/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeEditorTests.cs +++ b/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeEditorTests.cs @@ -34,7 +34,7 @@ namespace Spring.Transaction.Interceptor ITransactionAttribute ta = editor.Value; Assert.IsTrue( ta != null ); Assert.IsTrue( ta.PropagationBehavior == TransactionPropagation.Required ); - Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.ReadCommitted ); + Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.Unspecified ); Assert.IsFalse( ta.ReadOnly ); } diff --git a/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeSourceEditorTests.cs b/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeSourceEditorTests.cs index 8da00917..9717d75b 100644 --- a/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeSourceEditorTests.cs +++ b/test/Spring/Spring.Data.Tests/Transaction/Interceptor/TransactionAttributeSourceEditorTests.cs @@ -59,7 +59,7 @@ namespace Spring.Transaction.Interceptor { ITransactionAttribute ta = tas.ReturnTransactionAttribute( method, null ); Assert.IsTrue( ta != null ); - Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.ReadCommitted ); + Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.Unspecified ); Assert.IsTrue( ta.PropagationBehavior == transactionPropagation); } } diff --git a/test/Spring/Spring.Data.Tests/Transaction/Support/DefaultTransactionDefinitionTests.cs b/test/Spring/Spring.Data.Tests/Transaction/Support/DefaultTransactionDefinitionTests.cs index 277f3253..92624b4e 100644 --- a/test/Spring/Spring.Data.Tests/Transaction/Support/DefaultTransactionDefinitionTests.cs +++ b/test/Spring/Spring.Data.Tests/Transaction/Support/DefaultTransactionDefinitionTests.cs @@ -23,12 +23,18 @@ namespace Spring.Transaction.Support Assert.IsTrue( true == def.ReadOnly ); } [Test] - public void IsolationLeveNonDefaultl() + public void PropogationBehaviorDefault() { DefaultTransactionDefinition def = new DefaultTransactionDefinition(); Assert.IsTrue( def.PropagationBehavior == TransactionPropagation.Required ); } - [Test] + [Test] + public void IsolationLevelDefault() + { + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); + Assert.IsTrue(def.TransactionIsolationLevel == IsolationLevel.Unspecified); + } + [Test] [ExpectedException(typeof(ArgumentException))] public void InvalidTimeout() {