From d119d8f535123d4c854107c0fc0c1d5275dc4257 Mon Sep 17 00:00:00 2001 From: sbohlen Date: Mon, 9 Aug 2010 21:17:57 +0000 Subject: [PATCH] SPRNET-1364 Verified as resolved in SPRNET-1214 (which is a superset of this issue) but added new tests specifically for this reported use-case --- ...ationConfigurerMergablePropertiesTests.xml | 44 ++++++++++++ .../Support/HttpApplicationConfigurerTests.cs | 71 ++++++++++++++++++- .../Spring.Web.Tests.2008.csproj | 1 + 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerMergablePropertiesTests.xml diff --git a/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerMergablePropertiesTests.xml b/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerMergablePropertiesTests.xml new file mode 100644 index 00000000..d70df103 --- /dev/null +++ b/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerMergablePropertiesTests.xml @@ -0,0 +1,44 @@ + + + + + + + GrandParentValue1 + + + + + + + + ParentValue1 + ParentValue2 + ParentValue3 + ParentValue4 + + + + + + + + + + + + MergedValueToFind + + + + + + + + diff --git a/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs b/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs index 152f6a66..0073d607 100644 --- a/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs +++ b/test/Spring/Spring.Web.Tests/Context/Support/HttpApplicationConfigurerTests.cs @@ -160,6 +160,73 @@ namespace Spring.Context.Support HttpApplicationConfigurer.Configure(appContext, appObject); } + //////////////////////////////////////////////////// + + public class GrandParentHttpModule : IHttpModule + { + + private string[] _grandParentProperty; + public string[] GrandParentProperty + { + get { return _grandParentProperty; } + set + { + _grandParentProperty = value; + } + } + + + public void Dispose() + { + + } + + public void Init(HttpApplication context) + { + + } + } + + public class ParentHttpModule : GrandParentHttpModule + { + private string[] _parentProperty; + public string[] ParentProperty + { + get { return _parentProperty; } + set + { + _parentProperty = value; + } + } + + } + + [Test] + public void ConfigureUsingXmlApplicationContext_CanMergePropertyValues() + { + XmlApplicationContext appContext = new XmlApplicationContext(false, ReadOnlyXmlTestResource.GetFilePath("HttpApplicationConfigurerMergablePropertiesTests.xml", typeof(HttpApplicationConfigurerTests))); + + ParentHttpModule module = new ParentHttpModule(); + + TestApplication appObject = new TestApplication(new ModuleEntry[] + { + new ModuleEntry("DirectoryServicesAuthentication", module) + }); + HttpApplicationConfigurer.Configure(appContext, appObject); + + //base class property has carried through successfully + Assert.Contains("GrandParentValue1", module.GrandParentProperty); + + //parent property values remain in the final instance + Assert.Contains("ParentValue1", module.ParentProperty); + Assert.Contains("ParentValue2", module.ParentProperty); + Assert.Contains("ParentValue3", module.ParentProperty); + Assert.Contains("ParentValue4", module.ParentProperty); + + //the new additional value has been merged into the property + Assert.Contains("MergedValueToFind", module.ParentProperty); + } + [Test] public void ConfigureUsingXmlApplicationContext() { @@ -173,7 +240,7 @@ namespace Spring.Context.Support new ModuleEntry("TestModule1", m1) , new ModuleEntry("TestModule2", m2), }); - HttpApplicationConfigurer.Configure( appContext, appObject ); + HttpApplicationConfigurer.Configure(appContext, appObject); // app configured Assert.AreEqual(appContext.GetObject("testObject"), appObject.TestObject); // modules configured @@ -225,7 +292,7 @@ namespace Spring.Context.Support for (int i = 0; i < testModule.Length; i++) { moduleEntry = testModule[i]; - miAddModule.Invoke(modules, new object[] {moduleEntry.Name, moduleEntry.Module}); + miAddModule.Invoke(modules, new object[] { moduleEntry.Name, moduleEntry.Module }); } } } diff --git a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj index d879143b..c51c6ed2 100644 --- a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj +++ b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj @@ -157,6 +157,7 @@ +