From f02b3244ecf6f8383092fc34a6e1e920a7b25e73 Mon Sep 17 00:00:00 2001 From: Thomas Trageser Date: Thu, 27 Sep 2012 16:24:42 +0100 Subject: [PATCH 01/13] SPRNET-881 Add XML configuration option for default-autowire-candidates/autowire-candidate and modify IObjectFactory.GetObject() to return requested object with the use of autowire-candidate filter --- .../Objects/Factory/IObjectFactory.cs | 31 ++++++ .../Support/AbstractObjectDefinition.cs | 4 +- .../Factory/Support/AbstractObjectFactory.cs | 32 ++++++ .../Support/DefaultListableObjectFactory.cs | 31 +++++- .../Support/ObjectDefinitionBuilder.cs | 22 ++++ .../Factory/Xml/DocumentDefaultsDefinition.cs | 11 ++ .../Factory/Xml/ObjectDefinitionConstants.cs | 16 +++ .../Xml/ObjectDefinitionParserHelper.cs | 14 +++ .../Factory/Xml/ObjectsNamespaceParser.cs | 20 +++- .../Factory/Xml/spring-objects-2.0.xsd | 100 +++++++++++------- .../DefaultListableObjectFactoryTests.cs | 30 ++++++ .../Xml/XmlObjectDefinitionReaderTests.cs | 32 ++++++ 12 files changed, 295 insertions(+), 48 deletions(-) diff --git a/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs index aff582d0..7ffba218 100644 --- a/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs @@ -260,6 +260,37 @@ namespace Spring.Objects.Factory #endif object this[string name] { get; } + /// + /// Return an instance (possibly shared or independent) of the given object name. + /// + /// + /// + /// This method allows an object factory to be used as a replacement for the + /// Singleton or Prototype design pattern. + /// + /// + /// Note that callers should retain references to returned objects. There is no + /// guarantee that this method will be implemented to be efficient. For example, + /// it may be synchronized, or may need to run an RDBMS query. + /// + /// + /// Will ask the parent factory if the object cannot be found in this factory + /// instance. + /// + /// + /// The type of the object to return. + /// The instance of the object. + /// + /// If there's no such object definition. + /// + /// + /// If there is more than a single object of the requested type defined in the factory. + /// + /// + /// If the object could not be created. + /// + T GetObject(); + /// /// Return an instance (possibly shared or independent) of the given object name. /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs index d0a0cd02..2ce78874 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs @@ -814,7 +814,8 @@ namespace Spring.Objects.Factory.Support AutowireMode = other.AutowireMode; ResourceDescription = other.ResourceDescription; IsPrimary = other.IsPrimary; - + IsAutowireCandidate = other.IsAutowireCandidate; + AbstractObjectDefinition aod = other as AbstractObjectDefinition; if (aod != null) { @@ -846,6 +847,7 @@ namespace Spring.Objects.Factory.Support buffer.Append("; Singleton = ").Append(IsSingleton); buffer.Append("; LazyInit = ").Append(IsLazyInit); buffer.Append("; Autowire = ").Append(AutowireMode); + buffer.Append("; Autowire-Candidate = ").Append(IsAutowireCandidate); buffer.Append("; Primary = ").Append(IsPrimary); buffer.Append("; DependencyCheck = ").Append(DependencyCheck); buffer.Append("; InitMethodName = ").Append(InitMethodName); diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs index ac65c8a0..2958e596 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs @@ -1917,6 +1917,38 @@ namespace Spring.Objects.Factory.Support return GetObjectInternal(name, null, null, false); } + + /// + /// Return an instance (possibly shared or independent) of the given object name. + /// + /// + /// + /// This method allows an object factory to be used as a replacement for the + /// Singleton or Prototype design pattern. + /// + /// + /// Note that callers should retain references to returned objects. There is no + /// guarantee that this method will be implemented to be efficient. For example, + /// it may be synchronized, or may need to run an RDBMS query. + /// + /// + /// Will ask the parent factory if the object cannot be found in this factory + /// instance. + /// + /// + /// The type of the object to return. + /// The instance of the object. + /// + /// If there's no such object definition. + /// + /// + /// If there is more than a single object of the requested type defined in the factory. + /// + /// + /// If the object could not be created. + /// + public abstract T GetObject(); + /// /// Return an instance (possibly shared or independent) of the given object name. /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs index bad5a33d..81419945 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs @@ -949,20 +949,41 @@ namespace Spring.Objects.Factory.Support /// /// If the object could not be created. /// - public T GetObject() + public override T GetObject() { IList objectNamesForType = GetObjectNamesForType(typeof(T)); + + if (objectNamesForType.Count > 1) + { + IList autowireCandidates = new List(); + foreach (var objectName in objectNamesForType) + { + if (GetObjectDefinition(objectName).IsAutowireCandidate) + autowireCandidates.Add(objectName); + + } + if (autowireCandidates.Count > 0) + objectNamesForType = autowireCandidates; + } + if ((objectNamesForType == null) || (objectNamesForType.Count == 0)) { throw new NoSuchObjectDefinitionException(typeof(T).FullName, "Requested Type not Defined in the Context."); } - if (objectNamesForType.Count > 1) + if (objectNamesForType.Count == 1) { - throw new ObjectDefinitionStoreException(string.Format("More than one definition for {0} found in the Context.", typeof(T).FullName)); + return (T)GetObject(objectNamesForType[0]); + } + else if (objectNamesForType.Count == 0 && ParentObjectFactory != null) + { + return ParentObjectFactory.GetObject(); + } + else + { + throw new NoSuchObjectDefinitionException(typeof(T), "expected single bean but found " + + objectNamesForType.Count + ": " + StringUtils.ArrayToCommaDelimitedString(objectNamesForType)); } - - return (T)GetObject(objectNamesForType[0]); } /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs index 49e80bae..96b59a9f 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/ObjectDefinitionBuilder.cs @@ -336,6 +336,28 @@ namespace Spring.Objects.Factory.Support return this; } + /// + /// Sets the autowire candidate value for this definition. + /// + /// The autowire candidate value + /// + public ObjectDefinitionBuilder SetAutowireCandidate(bool autowireCandidate) + { + objectDefinition.IsAutowireCandidate = autowireCandidate; + return this; + } + + /// + /// Sets the primary value for this definition. + /// + /// If object is primary + /// + public ObjectDefinitionBuilder SetPrimary(bool primary) + { + objectDefinition.IsPrimary = primary; + return this; + } + /// /// Sets the dependency check mode for this definition. /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs index eccaa27d..92243287 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs @@ -33,6 +33,7 @@ namespace Spring.Objects.Factory.Xml private string dependencyCheck; private string lazyInit; private string merge; + private string autowireCandidates; /// /// Gets or sets the autowire setting for the document that's currently parsed. @@ -73,5 +74,15 @@ namespace Spring.Objects.Factory.Xml get { return merge; } set { merge = value; } } + + /// + /// Gets or sets autowire candidates for the document that's currently parsed + /// + /// The Autowire Candidates + public string AutowireCandidates + { + get { return autowireCandidates; } + set { autowireCandidates = value; } + } } } diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs index 51c9835e..fe2e7643 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs @@ -48,6 +48,12 @@ namespace Spring.Objects.Factory.Xml /// public const string TrueValue = "true"; + /// + /// Value of a boolean attribute that represents + /// . + /// + public const string FalseValue = "false"; + /// /// Signifies that a default value is to be applied. /// @@ -90,6 +96,11 @@ namespace Spring.Objects.Factory.Xml /// public const string DefaultAutowireAttribute = "default-autowire"; + /// + /// Specifies the default autowire candidates. + /// + public const string DefaultAutowireCandidatesAttribute = "default-autowire-candidates"; + /// /// Specifies the default collection merge mode. /// @@ -586,6 +597,11 @@ namespace Spring.Objects.Factory.Xml /// public const string AutowireAttribute = "autowire"; + /// + /// The autowiring mode for an individual object definition. + /// + public const string AutowireCandidateAttribute = "autowire-candidate"; + /// /// Attribute element to farther deifne the qualifier of an object /// diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs index d4a64c38..7bdf0f1f 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs @@ -175,6 +175,20 @@ namespace Spring.Objects.Factory.Xml #endregion + ddd.AutowireCandidates = GetAttributeValue(root, ObjectDefinitionConstants.DefaultAutowireCandidatesAttribute); + + #region Instrumentation + + if (log.IsDebugEnabled) + { + log.Debug( + string.Format( + "Default autowire candidates '{0}'.", + ddd.AutowireCandidates)); + } + + #endregion + defaults = ddd; } diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs index 2188fdf1..df704dcb 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs @@ -481,10 +481,24 @@ namespace Spring.Objects.Factory.Xml autowire = childParserContext.ParserHelper.Defaults.Autowire; } od.AutowireMode = GetAutowireMode(autowire); - string primary = GetAttributeValue(element, ObjectDefinitionConstants.PrimaryAttribute); - if (primary == null) + + string autowireCandidates = GetAttributeValue(element, ObjectDefinitionConstants.AutowireCandidateAttribute); + if (string.IsNullOrEmpty(autowireCandidates) || ObjectDefinitionConstants.DefaultValue.Equals(autowireCandidates)) { - primary = "false"; + if (!string.IsNullOrEmpty(childParserContext.ParserHelper.Defaults.AutowireCandidates)) + { + string[] patterns = childParserContext.ParserHelper.Defaults.AutowireCandidates.Split(','); + od.IsAutowireCandidate = PatternMatchUtils.SimpleMatch(patterns, id); + } + } + else + { + od.IsAutowireCandidate = ObjectDefinitionConstants.TrueValue.Equals(autowireCandidates); + } + string primary = GetAttributeValue(element, ObjectDefinitionConstants.PrimaryAttribute); + if (string.IsNullOrEmpty(primary)) + { + primary = ObjectDefinitionConstants.FalseValue; } od.IsPrimary = IsTrueStringValue(primary); string initMethodName = GetAttributeValue(element, ObjectDefinitionConstants.InitMethodAttribute); diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd b/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd index c5febc79..8f084e61 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd @@ -500,10 +500,25 @@ + Indicates whether or not this object should be considered when looking + for matching candidates to satisfy another object's autowiring requirements. + Note that this does not affect explicit references by name, which will get + resolved even if the specified bean is not marked as an autowire candidate. + --> + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 From 2c68fdea43b7034a0d15d58ccac2f6fb188468c2 Mon Sep 17 00:00:00 2001 From: Thomas Trageser Date: Thu, 27 Sep 2012 22:56:17 +0100 Subject: [PATCH 02/13] SPRNET-1523 Possibility to define a default init and destroy method in XML configuration document --- .../Factory/Xml/DocumentDefaultsDefinition.cs | 22 ++++++++ .../Factory/Xml/ObjectDefinitionConstants.cs | 9 ++++ .../Xml/ObjectDefinitionParserHelper.cs | 28 ++++++++++ .../Factory/Xml/ObjectsNamespaceParser.cs | 22 ++++++-- .../Factory/Xml/spring-objects-2.0.xsd | 20 +++++++ .../Factory/Xml/default-destroy-methods.xml | 17 ++++++ .../Factory/Xml/default-initializers.xml | 23 ++++++++ .../Factory/Xml/XmlObjectFactoryTests.cs | 54 +++++++++++++++++++ .../Spring.Core.Tests.2010.csproj | 2 + 9 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-destroy-methods.xml create mode 100644 test/Spring/Spring.Core.Tests/Data/Spring/Objects/Factory/Xml/default-initializers.xml diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs index eccaa27d..e277f005 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/DocumentDefaultsDefinition.cs @@ -33,6 +33,8 @@ namespace Spring.Objects.Factory.Xml private string dependencyCheck; private string lazyInit; private string merge; + private string initMethod; + private string destroyMethod; /// /// Gets or sets the autowire setting for the document that's currently parsed. @@ -73,5 +75,25 @@ namespace Spring.Objects.Factory.Xml get { return merge; } set { merge = value; } } + + /// + /// Get or sets the init method for the document that's currently parsed. + /// + /// The init method + public string InitMethod + { + get { return initMethod; } + set { initMethod = value; } + } + + /// + /// Gets or sets the destroy method for the document that's currently parsed. + /// + /// The destroy methood + public string DestroyMethod + { + get { return destroyMethod; } + set { destroyMethod = value; } + } } } diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs index 51c9835e..fefc3d08 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionConstants.cs @@ -95,6 +95,15 @@ namespace Spring.Objects.Factory.Xml /// public const string DefaultMergeAttribute = "default-merge"; + /// + /// Specifies the default init method. + /// + public const string DefaultInitMethodAttribute = "default-init-method"; + + /// + /// Specifies the default destroy method. + /// + public const string DefaultDestroyMethodAttribute = "default-destroy-method"; /// /// Defines a single named object. diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs index d4a64c38..98849570 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectDefinitionParserHelper.cs @@ -175,6 +175,34 @@ namespace Spring.Objects.Factory.Xml #endregion + ddd.InitMethod = GetAttributeValue(root, ObjectDefinitionConstants.DefaultInitMethodAttribute); + + #region Instrumentation + + if (log.IsDebugEnabled) + { + log.Debug( + string.Format( + "Default init method '{0}'.", + ddd.InitMethod)); + } + + #endregion + + ddd.DestroyMethod = GetAttributeValue(root, ObjectDefinitionConstants.DefaultDestroyMethodAttribute); + + #region Instrumentation + + if (log.IsDebugEnabled) + { + log.Debug( + string.Format( + "Default destroy method '{0}'.", + ddd.DestroyMethod)); + } + + #endregion + defaults = ddd; } diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs index 2188fdf1..1ab1f877 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsNamespaceParser.cs @@ -488,14 +488,28 @@ namespace Spring.Objects.Factory.Xml } od.IsPrimary = IsTrueStringValue(primary); string initMethodName = GetAttributeValue(element, ObjectDefinitionConstants.InitMethodAttribute); - if (StringUtils.HasText(initMethodName)) + if (initMethodName != null) { - od.InitMethodName = initMethodName; + if (StringUtils.HasText(initMethodName)) + od.InitMethodName = initMethodName; + } + else + { + if (StringUtils.HasText(childParserContext.ParserHelper.Defaults.InitMethod)) + od.InitMethodName = childParserContext.ParserHelper.Defaults.InitMethod; } string destroyMethodName = GetAttributeValue(element, ObjectDefinitionConstants.DestroyMethodAttribute); - if (StringUtils.HasText(destroyMethodName)) + if (destroyMethodName != null) { - od.DestroyMethodName = destroyMethodName; + if (StringUtils.HasText(destroyMethodName)) + { + od.DestroyMethodName = destroyMethodName; + } + } + else + { + if (StringUtils.HasText(childParserContext.ParserHelper.Defaults.DestroyMethod)) + od.DestroyMethodName = childParserContext.ParserHelper.Defaults.DestroyMethod; } if (element.HasAttribute(ObjectDefinitionConstants.SingletonAttribute)) { diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd b/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd index c5febc79..9896a32b 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd +++ b/src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-2.0.xsd @@ -589,6 +589,26 @@ + + + + + + + + + + + + + + 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/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.2010.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj index 521fedd1..1761db63 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj @@ -839,6 +839,8 @@ + + From c265d4b014c0c7f30ff6e1ad743da6eb8af619a7 Mon Sep 17 00:00:00 2001 From: Andreas Kluth Date: Mon, 8 Oct 2012 23:52:10 +0200 Subject: [PATCH 03/13] SPRNET-1495 - Add unit tests to document existing behavior. --- .../TypeConversionUtilsTests.cs | 31 ++++++++++++++++--- .../Spring.Core.Tests.2008.csproj | 1 + .../Spring.Core.Tests.2010.csproj | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs b/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs index 8fe88761..f6979a34 100644 --- a/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs @@ -31,18 +31,39 @@ 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 ConvertValue_ForDecimalMarkWithComma_FailsWithBritishCulture() + { + TestDelegate testDelegate = () => TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1,2", "foo" ); + Assert.Throws( testDelegate ); + } + + [Test] + [SetCulture( "nl-NL" )] + public void ConvertValue_ForDecimalMarkWithPoint_ReturnsValueWithDutchCulture() + { + object o = TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1.2", "foo" ); + Assert.That( o, Is.EqualTo( 1.2 ) ); + } + + [Test] + [SetCulture( "nl-NL" )] + public void ConvertValue_ForDecimalMarkWithComma_ReturnsValueWithDutchCulture() + { + 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/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..1abe6791 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 @@ + From 1f69127cc56036372bb72c6470e0bf36bf0fe8ad Mon Sep 17 00:00:00 2001 From: Andreas Kluth Date: Tue, 9 Oct 2012 00:14:38 +0200 Subject: [PATCH 04/13] SPRNET-1495 Addition of another test. Housekeeping. --- .../TypeConversion/TypeConversionUtilsTests.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs b/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs index f6979a34..c48153da 100644 --- a/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs +++ b/test/Spring/Spring.Core.Tests/Core/TypeConversion/TypeConversionUtilsTests.cs @@ -44,7 +44,15 @@ namespace Spring.Core.TypeConversion [Test] [SetCulture( "en-US" )] - public void ConvertValue_ForDecimalMarkWithComma_FailsWithBritishCulture() + 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 ); @@ -52,7 +60,7 @@ namespace Spring.Core.TypeConversion [Test] [SetCulture( "nl-NL" )] - public void ConvertValue_ForDecimalMarkWithPoint_ReturnsValueWithDutchCulture() + public void ConvertValueWithDutchCultureForDecimalMarkWithPointReturnsValue() { object o = TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1.2", "foo" ); Assert.That( o, Is.EqualTo( 1.2 ) ); @@ -60,7 +68,7 @@ namespace Spring.Core.TypeConversion [Test] [SetCulture( "nl-NL" )] - public void ConvertValue_ForDecimalMarkWithComma_ReturnsValueWithDutchCulture() + public void ConvertValueWithDutchCultureForDecimalMarkWithCommaReturnsValue() { object o = TypeConversionUtils.ConvertValueIfNecessary( typeof( Double ), "1,2", "foo" ); Assert.That( o, Is.EqualTo( 1.2 ) ); From c8a73c59084043a3dcd9585d5603df1d998bc344 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Thu, 11 Oct 2012 11:44:07 -0400 Subject: [PATCH 05/13] SPRNET-881 fixing merge error --- .../Objects/Factory/IListableObjectFactory.cs | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs index c071a342..c7a832b6 100644 --- a/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs @@ -335,36 +335,5 @@ namespace Spring.Objects.Factory /// If the objects could not be created. /// IDictionary GetObjects(bool includePrototypes, bool includeFactoryObjects); - - /// - /// Return an instance (possibly shared or independent) of the given object name. - /// - /// - /// - /// This method allows an object factory to be used as a replacement for the - /// Singleton or Prototype design pattern. - /// - /// - /// Note that callers should retain references to returned objects. There is no - /// guarantee that this method will be implemented to be efficient. For example, - /// it may be synchronized, or may need to run an RDBMS query. - /// - /// - /// Will ask the parent factory if the object cannot be found in this factory - /// instance. - /// - /// - /// The type of the object to return. - /// The instance of the object. - /// - /// If there's no such object definition. - /// - /// - /// If there is more than a single object of the requested type defined in the factory. - /// - /// - /// If the object could not be created. - /// - T GetObject(); } } \ No newline at end of file From f783f7b58795fd13957571ce06dd4e3805dc485c Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Mon, 22 Oct 2012 13:05:07 -0400 Subject: [PATCH 06/13] fixing data.integration tests --- .../Spring.Data/Data/Common/dbproviders.xml | 6 +- .../Data/AdoDaoTests.cs | 8 +- .../Data/DTC1.1AppContext.xml | 4 +- .../Data/DTCAppContext.xml | 8 +- .../Data/DTCAppContextNoInterfaces.xml | 6 +- .../Data/Generic/GenericAdoTemplateTests.cs | 40 +++- .../Data/Generic/GenericAdoTemplateTests.xml | 2 +- .../Data/ITestObjectManager.cs | 2 + .../Data/MappingAdoQueryTests.cs | 110 +++++---- .../Data/NativeAdoTests.cs | 33 ++- .../Data/NestedTxScopeTests.cs | 8 +- .../Data/Northwind/NativeAdoShipperDao.cs | 4 +- .../Objects/Generic/StoredProcedureTests.cs | 90 ++++++-- .../Data/OracleAdoTemplateTests.cs | 1 + .../Data/SQLiteTests.cs | 212 +++++++++--------- .../SimpleExceptionTranslationTests.cs | 54 ++--- .../Data/TestObjectManager.cs | 16 +- .../Data/TestObjectQuery.cs | 4 +- .../Data/TestTxIsolationLevel.xml | 2 +- .../Data/TestTxIsolationLevelTests.cs | 2 +- .../Data/TransactionTemplateTests.cs | 108 +++++---- .../Data/adoTemplateTests.xml | 20 +- .../Data/autoDeclarativeServices.xml | 4 +- .../Data/declarativeServices.xml | 2 +- .../Data/nativeAdoTests.xml | 2 +- .../Spring.Data.Integration.Tests.2010.csproj | 4 +- 26 files changed, 450 insertions(+), 302 deletions(-) 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/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/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/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/Spring.Data.Integration.Tests.2010.csproj b/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.2010.csproj index a209d791..c03ed953 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 + From ba557544732bb9666dc9dca84a18bccd1bd40c4d Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Mon, 22 Oct 2012 14:50:02 -0400 Subject: [PATCH 07/13] SPRNET-1444 - change default tx isolation mode from ReadCommitted to Unspecified --- .../Support/DefaultTransactionDefinition.cs | 2 +- .../AdoPlatformTransactionManagerTests.cs | 35 ++++++++++--------- .../ServiceDomainTransactionManagerTests.cs | 4 +-- .../Core/TxScopeTransactionManagerTests.cs | 6 ++-- .../DefaultTransactionAttributeTests.cs | 2 +- .../TransactionAttributeEditorTests.cs | 2 +- .../TransactionAttributeSourceEditorTests.cs | 2 +- .../DefaultTransactionDefinitionTests.cs | 10 ++++-- 8 files changed, 35 insertions(+), 28 deletions(-) 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/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() { From 6cf4e2dd0f9d0fddccad1114cae522a7f0738770 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Mon, 22 Oct 2012 19:28:32 -0400 Subject: [PATCH 08/13] SPRNET-1444 - update def. tx isolation assumption in NMS txMgr --- .../Messaging/Nms/Connections/NmsTransactionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"); } From 914e774701aa1d529003acaa4cf85c84e21698d4 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Mon, 22 Oct 2012 19:53:01 -0400 Subject: [PATCH 09/13] enabling data.integration tests in build files --- Spring.build | 20 +++++++++---------- .../Spring.Data.Integration.Tests.build | 9 ++++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Spring.build b/Spring.build index fe09c001..9b00dc03 100644 --- a/Spring.build +++ b/Spring.build @@ -116,10 +116,10 @@ Commandline Examples: - - - - + + + + - + From 65ad9ccb4a3e4597392a4029f14cfba2ef5cfb66 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Wed, 24 Oct 2012 16:00:26 -0400 Subject: [PATCH 10/13] cleaning up DB schema creation scripts for integration tests --- .../Data/CreateTestObject.sql | 7 -- .../Data/CreditsDebitsSchema.sql | 51 -------------- ...ration.Tests_CreditsAndDebits_database.sql | Bin 0 -> 1946 bytes ...ata.Integration.Tests_Credits_database.sql | Bin 0 -> 990 bytes ...Data.Integration.Tests_Debits_database.sql | Bin 0 -> 976 bytes ...Data.Integration.Tests_Spring_database.sql | Bin 0 -> 7862 bytes .../Data/testobjects-sqlserver.sql | 65 ------------------ .../Spring.Data.Integration.Tests.2010.csproj | 7 +- 8 files changed, 4 insertions(+), 126 deletions(-) delete mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/CreateTestObject.sql delete mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/CreditsDebitsSchema.sql create mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_CreditsAndDebits_database.sql create mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Credits_database.sql create mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Debits_database.sql create mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/Spring.Data.Integration.Tests_Spring_database.sql delete mode 100644 test/Spring/Spring.Data.Integration.Tests/Data/testobjects-sqlserver.sql 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/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 0000000000000000000000000000000000000000..b0ade1201751dc568d1079b95d168fc901e6350b GIT binary patch literal 1946 zcmeH{+e^bx4934#1^0#mz9uxTHDyjVH03=3+C!aVeT4TC zc!4@PKzD)8(2qG^tFLL!!>DF!Pmb>`v2H*JusJ}UIIN~-)X=Qv+;>Jz&H>+fZs)YX zx2Z)ment(KrPbEqCR7T3q5-n2O`aTW#xK97(s~D*48NEx26(kNrTk8`${VX);Txfi ziDOT)$%R93IR40Q?n z53hJVozj_W$Fbp8V+72Eag=;ii?u_}5>JPDxoYkauLG5TAuNtvK{H-r3GS(j2K+C)t{aJ+zu) zP;GC$HTDa>eO`-A{OtZGHg)(v!6v16{>HA3R{u7w{!Kai-``gs^>;Sbk5K0Q^_{Ik K``_B1+1h8d3kVtj literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..cdd7dffec82697d2fe6f9ce49a4f376dd6a9ab8a GIT binary patch literal 990 zcmaizK~KU!5QX1W6aPbxV2B_=4<;UJDcA@tQivKt8Wl}6DhBcItKV#eRMKFY?QUn^ zyqS43{r(y&RVYsr1zPAqGd*dk4^6eFU3HbXy{`Sj<6*tiGw6G;CwO}r=@#1yHshLc zp2Kla!fR-IQoI*LdxyhQ8~-KV#&)QN>T0Ux-VMH+&U(acOULfr!cxqs?((!+M%?&{ z;g6KDkJaNzu_k;Kt6HHi!6f*FWRc<3<`nZCsly62Eb$GnhQu*1tKQccQF0}>RbO!# z>}=>_F{kiM(Blmq>|D%aq#ISxp~k9m7rT6I&#SAIvif?Z3!iJoi5}_D+$n7l%2_-n z!IVm=YDirXXVY||fiBReI47&T2OuN$K@Z8)0~fkIKogrVQ_1vdb7vjcu7Zz8;BZx4 z!8_79eih>Tza5HQkFK$LI%Oqvs)IT;ZV2wiS2m@+zXOj;@PPj<*h52Xf7e%I1INfA_1u F_6Grshfn|j literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5c7b2e6f6bec1d01cc019003e7bef04c6337e61d GIT binary patch literal 976 zcmaizTT8=05QWdHg8w0pt%z+!Q3M}inrhG{wP{f)QoK}9yy4~VtKUpWO|>dvGn?Hr zXJ*b!KHi7Q6)Vt4ZB2Bc8@=j9XIj#t_LRA8Xu0wPoL=Y_^d;DBd;<-1&e07PcQ^TKF3a+tEHwITGP6}n`*HScyDmKu1$Y$aZ=5w;aOT818zd4 z@FyB$hdSiRInDU0)>NX8z-0KvWHH98%`W9TQHK?)KgT!XG$xLDS?!^AiBhQed+jxk zzc8bT#XEyzgcc8IVEbwg1D&cy^((A8cd6%Uwy11n4ri!))PI}ujdV?C9$jPOpU)8} za*cB8=~GeSDp+Pc9iYtDbd)*wz$NN}?UQ8yDs~&8g-w;IV>-3DGv)uPKLj5+s;*;L z2inK0M(hxO>r0A_b;4<&9actvI_P4vWF4@M*)D-6_ugk7-Ky%sGvv-X^xZpQ%1sf= z)T$hU9ZzeSjTHJcWn?%8U)V!z1m0$>`!efg(; E0;ivZFaQ7m literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..e8b5113ea3e68f44bcff297f2b71220a3e34766a GIT binary patch literal 7862 zcmeHMZBH994EEPe+JCr@fT{r#NDK*y(jKfDv>k27CNx#Nbif1@!Lez7e%tdnq)G46 zcV0B8PHnD`}c$8rDuX-G|CiDVz`m0Zi2T*`@jlQ;5Owxpu%yv%t|gx*8>AuTzQ zL{>33lDZtA?;L&Pbd2{lc)Z2?XN(--lYny@yl>FY8GLFOp~NeUMp9I&mU3K_1(}z3 zvZUV&vWWKx-^&oK20gIMk zZ`zc0=boI&1uS`vz8P3-MRFKhkXd~D>#ECF9nXP=V`W`GTVt(UN8TnlUSr=9j2(b? z>rUEF{JMs`Q*9}2`A$xj$2Mpt;}Apg6;{=j-_W3iwG6xJtTr{Qg}Nu$DaGMgz3X&WgGv<<&zg(69-5({7_JfS!J9H7l!LJ~h{|r4qvQ z#5TR&Sl+j;iE)F*Z49)LqMx_ZZhmx`ByQG$N_vbRYoAZ-95xd6vVy~Xh@z~g4|klW zS)%c3yx5n=S!kn!c1Ord$;L>YY&_RY%=Ke!?}*WFjpIj*eq5(f<9?#XBoUwp zBsz=st&uZQiwbuWaaj zZFIZ1+bHd`j}5Uvu? z5|dWX{x<|pVlVEaIhANPx7)q2Y0<{E8;7RqvVna&QLI`@V$$wr7>&G>IuzzQ$c&I< zGAdm_vk(r5&|j#r5%a9BT11Tc}M*3b;KUnBF^ zmewS_uB=9(6`C3x*Gg+78pSV1thtQuryHm}TKn&5ws(qX>GW`M<)xkzzL$<-E$--j zdMN$8+b8GHbAO(eMqq^6H~Svrv>0Spb8=MR8;N()O%a*k-r`C}JI&Ig`!)hfp^P}xkVSS3=ZUoaFqat&3 Sw1sk#$H-;UsN-)NUH<|9W=_}u literal 0 HcmV?d00001 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 c03ed953..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 @@ -195,10 +195,11 @@ - - - + + + + From 62f953f566e5ebe3644acc106685e760263c0724 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Wed, 24 Oct 2012 16:20:47 -0400 Subject: [PATCH 11/13] change data type in schema .sql file to datetime --- ...Data.Integration.Tests_Spring_database.sql | Bin 7862 -> 7878 bytes 1 file changed, 0 insertions(+), 0 deletions(-) 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 index e8b5113ea3e68f44bcff297f2b71220a3e34766a..50b2b976481b3ff6c8b36e55f8ef9e504fe769f2 100644 GIT binary patch delta 48 vcmdmHd(3u&7&B)HLncEmLn=e;Vkvu& Date: Wed, 24 Oct 2012 16:32:59 -0400 Subject: [PATCH 12/13] SPRNET-1444 change expectations for default tx isolation in EmsTransactionManager --- .../Messaging/Ems/Connections/EmsTransactionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"); } From a6c3980dbec5f2501a1470bd58640c0e19f5725c Mon Sep 17 00:00:00 2001 From: Bruno Baia Date: Fri, 26 Oct 2012 16:21:43 +0200 Subject: [PATCH 13/13] Add extra documentation for the element --- doc/reference/src/wcf.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/reference/src/wcf.xml b/doc/reference/src/wcf.xml index 55762004..d3250f25 100644 --- a/doc/reference/src/wcf.xml +++ b/doc/reference/src/wcf.xml @@ -243,6 +243,21 @@ The value 'serverAppCalculatorEndpoint' refers to the name of an enpoints in the <client> section of the standard WCF configuration inside of App.config. + + You can also specify the scope of the created channel (default is singleton) + and use classic DI to configure the ChannelFactory<T> instance. + + <objects xmlns="http://www.springframework.net" + xmlns:wcf="http://www.springframework.net/wcf"> + + <wcf:channelFactory id="serverAppCalculator" + channelType="Spring.WcfQuickStart.ICalculator, Spring.WcfQuickStart.Contracts" + endpointConfigurationName="serverAppCalculatorEndpoint"> + <wcf:property name="IsSingleton" value="false" /> + <wcf:property name="Credentials.Windows.ClientCredential" value="Domain\Login:Password" /> + </wcf:channelFactory> + +</objects>