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
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:db="http://www.springframework.net/database"
|
||||
xmlns:tx="http://www.springframework.net/tx"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects-1.3.xsd
|
||||
http://www.springframework.net/database http://www.springframework.net/schema/db/spring-database-1.1.xsd
|
||||
http://www.springframework.net/tx http://www.springframework.net/schema/tx/spring-tx-1.1.xsd">
|
||||
|
||||
<object name="GrandParentHttpModule" abstract="true">
|
||||
<property name="GrandParentProperty">
|
||||
<list element-type="string">
|
||||
<value>GrandParentValue1</value>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object name="ParentHttpModule" abstract="true" parent="GrandParentHttpModule">
|
||||
<property name="ParentProperty">
|
||||
<list element-type="string">
|
||||
<value>ParentValue1</value>
|
||||
<value>ParentValue2</value>
|
||||
<value>ParentValue3</value>
|
||||
<value>ParentValue4</value>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object name="HttpApplicationConfigurer" type="Spring.Context.Support.HttpApplicationConfigurer, Spring.Web">
|
||||
<property name="ModuleTemplates">
|
||||
<dictionary>
|
||||
<entry key="DirectoryServicesAuthentication">
|
||||
<object id="theModule" parent="ParentHttpModule">
|
||||
<property name="ParentProperty">
|
||||
<list element-type="string" merge="true">
|
||||
<value>MergedValueToFind</value>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
</entry>
|
||||
</dictionary>
|
||||
</property>
|
||||
</object>
|
||||
</objects>
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Context\Support\HttpApplicationConfigurerTests.xml" />
|
||||
<EmbeddedResource Include="Context\Support\HttpApplicationConfigurerMergablePropertiesTests.xml" />
|
||||
<Content Include="Data\Spring\Context\Support\WebApplicationContextTests\Dummy.aspx" />
|
||||
<Content Include="Data\Spring\Objects\Factory\Support\TestForm.aspx" />
|
||||
<Content Include="Data\Spring\Web\Support\LocalResourceManagerTests\WithoutResources.aspx" />
|
||||
|
||||
Reference in New Issue
Block a user