tests for SPRNET-1077
This commit is contained in:
@@ -1,34 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
|
||||
|
||||
<object id="OverrideConfigurer" type="Spring.Objects.Factory.Config.PropertyOverrideConfigurer">
|
||||
<property name="Properties">
|
||||
<name-values>
|
||||
<add key="Test2.Name" value="Overriden Name"/>
|
||||
</name-values>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="PlaceholderConfigurer" type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer">
|
||||
<property name="Properties">
|
||||
<name-values>
|
||||
<add key="DefaultName" value="DefName"/>
|
||||
</name-values>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="Test1" type="Spring.Objects.TestObject, Spring.Core.Tests">
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<objects xmlns="http://www.springframework.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
|
||||
<object id="OverrideConfigurer" type="Spring.Objects.Factory.Config.PropertyOverrideConfigurer">
|
||||
<property name="Properties">
|
||||
<name-values>
|
||||
<add key="Test2.Name" value="Overriden Name" />
|
||||
</name-values>
|
||||
</property>
|
||||
</object>
|
||||
<object id="PlaceholderConfigurer" type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer">
|
||||
<property name="Properties">
|
||||
<name-values>
|
||||
<add key="DefaultName" value="DefName" />
|
||||
</name-values>
|
||||
</property>
|
||||
</object>
|
||||
<object id="ConfigSectionPlaceholderConfigurer" type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer">
|
||||
<property name="PlaceholderPrefix" value="%{" />
|
||||
<property name="ConfigSections" value="PropertyPlaceholderConfigurerSectionTest,PropertyPlaceholderConfigurerSectionGroupTest/PropertyPlaceholderConfigurerSectionGroupTestSection" />
|
||||
</object>
|
||||
<object id="Test1" type="Spring.Objects.TestObject, Spring.Core.Tests">
|
||||
<property name="Name">
|
||||
<value>A ${DefaultName}</value>
|
||||
</property>
|
||||
</object>
|
||||
<object id="Test2" type="Spring.Objects.TestObject, Spring.Core.Tests">
|
||||
<property name="Name">
|
||||
<value>Start Name</value>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="Test3" type="Spring.Objects.TestObject, Spring.Core.Tests">
|
||||
<property name="Name">
|
||||
<value>A ${DefaultName}</value>
|
||||
<value>%{test.name.1}</value>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id="Test2" type="Spring.Objects.TestObject, Spring.Core.Tests">
|
||||
<property name="Name">
|
||||
<value>Start Name</value>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
|
||||
<object id="Test4" type="Spring.Objects.TestObject, Spring.Core.Tests">
|
||||
<property name="Name">
|
||||
<value>%{test.name.2}</value>
|
||||
</property>
|
||||
</object>
|
||||
</objects>
|
||||
@@ -557,6 +557,19 @@ namespace Spring.Objects.Factory.Config
|
||||
Assert.AreEqual("A DefName", to.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ViaXMLAndConfigSection()
|
||||
{
|
||||
IResource resource = new ReadOnlyXmlTestResource("PropertyResourceConfigurerTests.xml", GetType());
|
||||
XmlObjectFactory xbf = new XmlObjectFactory(resource);
|
||||
PropertyPlaceholderConfigurer ppc = (PropertyPlaceholderConfigurer) xbf.GetObject("ConfigSectionPlaceholderConfigurer");
|
||||
Assert.IsNotNull(ppc);
|
||||
ppc.PostProcessObjectFactory(xbf);
|
||||
|
||||
Assert.AreEqual("name from section", ((TestObject)xbf.GetObject("Test3")).Name);
|
||||
Assert.AreEqual("name from sectiongroup/section", ((TestObject)xbf.GetObject("Test4")).Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WithTypes()
|
||||
{
|
||||
|
||||
@@ -26,6 +26,11 @@ limitations under the License.
|
||||
<sectionGroup name="common">
|
||||
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
|
||||
</sectionGroup>
|
||||
|
||||
<section name="PropertyPlaceholderConfigurerSectionTest" type="System.Configuration.NameValueSectionHandler"/>
|
||||
<sectionGroup name='PropertyPlaceholderConfigurerSectionGroupTest'>
|
||||
<section name="PropertyPlaceholderConfigurerSectionGroupTestSection" type="System.Configuration.NameValueSectionHandler"/>
|
||||
</sectionGroup>
|
||||
|
||||
<sectionGroup name='spring'>
|
||||
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
|
||||
@@ -51,6 +56,16 @@ limitations under the License.
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<PropertyPlaceholderConfigurerSectionTest>
|
||||
<add key="test.name.1" value="name from section"/>
|
||||
</PropertyPlaceholderConfigurerSectionTest>
|
||||
|
||||
<PropertyPlaceholderConfigurerSectionGroupTest>
|
||||
<PropertyPlaceholderConfigurerSectionGroupTestSection>
|
||||
<add key="test.name.2" value="name from sectiongroup/section"/>
|
||||
</PropertyPlaceholderConfigurerSectionGroupTestSection>
|
||||
</PropertyPlaceholderConfigurerSectionGroupTest>
|
||||
|
||||
<common>
|
||||
<logging>
|
||||
<factoryAdapter type="Common.Logging.Simple.NoOpLoggerFactoryAdapter, Common.Logging"/>
|
||||
|
||||
@@ -27,6 +27,11 @@ limitations under the License.
|
||||
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
|
||||
</sectionGroup>
|
||||
|
||||
<section name="PropertyPlaceholderConfigurerSectionTest" type="System.Configuration.NameValueSectionHandler"/>
|
||||
<sectionGroup name='PropertyPlaceholderConfigurerSectionGroupTest'>
|
||||
<section name="PropertyPlaceholderConfigurerSectionGroupTestSection" type="System.Configuration.NameValueSectionHandler"/>
|
||||
</sectionGroup>
|
||||
|
||||
<sectionGroup name='spring'>
|
||||
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
|
||||
<section name='context' type='Spring.HookableContextHandler, Spring.Core.Tests'/>
|
||||
@@ -51,6 +56,16 @@ limitations under the License.
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<PropertyPlaceholderConfigurerSectionTest>
|
||||
<add key="test.name.1" value="name from section"/>
|
||||
</PropertyPlaceholderConfigurerSectionTest>
|
||||
|
||||
<PropertyPlaceholderConfigurerSectionGroupTest>
|
||||
<PropertyPlaceholderConfigurerSectionGroupTestSection>
|
||||
<add key="test.name.2" value="name from sectiongroup/section"/>
|
||||
</PropertyPlaceholderConfigurerSectionGroupTestSection>
|
||||
</PropertyPlaceholderConfigurerSectionGroupTest>
|
||||
|
||||
<common>
|
||||
<logging>
|
||||
<factoryAdapter type="Common.Logging.Simple.NoOpLoggerFactoryAdapter, Common.Logging"/>
|
||||
|
||||
Reference in New Issue
Block a user