Merge pull request #120 from thorstenbaek/master

Multiple PropertyPlaceholderConfigurers fail in AbstractObjectFactory
This commit is contained in:
Steve Bohlen
2015-11-22 13:14:24 -05:00
5 changed files with 82 additions and 1 deletions

View File

@@ -1685,7 +1685,7 @@ namespace Spring.Objects.Factory.Support
/// <summary>
/// String Resolver applied to Autowired value injections
/// </summary>
private ISet embeddedValueResolvers = new SortedSet();
private ISet embeddedValueResolvers = new SortedSet(new ObjectOrderComparator());
/// <summary>
/// Indicates whether any IInstantiationAwareBeanPostProcessors have been registered

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2004 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<objects xmlns="http://www.springframework.net">
<object id="testObject" type="Spring.Objects.TestObject, Spring.Core.Tests">
<property name="Name" value="${SomeName}" />
</object>
<object name="propertyplaceholder_100"
type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
<property name="Order" value="100"/>
<property name="EnvironmentVariableMode" value="never"/>
<property name="IgnoreUnresolvablePlaceholders" value="false"/>
<property name="Properties">
<name-values>
<add key="SomeName" value="wrong_name" />
</name-values>
</property>
</object>
</objects>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2004 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<objects xmlns="http://www.springframework.net">
<object name="propertyplaceholder_90"
type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
<property name="Order" value="90"/>
<property name="EnvironmentVariableMode" value="never"/>
<property name="IgnoreUnresolvablePlaceholders" value="false"/>
<property name="Properties">
<name-values>
<add key="SomeName" value="correct_name" />
</name-values>
</property>
</object>
</objects>

View File

@@ -635,5 +635,21 @@ namespace Spring.Objects.Factory.Config
Assert.AreEqual(2, to.Computers.Count);
Assert.IsTrue(to.PeriodicTable.Contains("C"));
}
[Test]
public void WithMultipleXml_MultiplePropertyPlaceholderConfigurersAndOrder_CanReplaceValueFromOtherXml()
{
var context =
new XmlApplicationContext(
new[]
{
"file://Spring/Objects/Factory/Config/FirstPropertyPlaceholderConfigurer.xml",
"file://Spring/Objects/Factory/Config/SecondPropertyPlaceholderConfigurer.xml"
});
var testObject = context.GetObject<TestObject>("testObject");
Assert.AreEqual("correct_name", testObject.Name);
}
}
}

View File

@@ -872,6 +872,8 @@
<Content Include="Data\Spring\Context\Support\SPRNET-192.xml" />
<Content Include="Data\Spring\Objects\Factory\concurrent.xml" />
<Content Include="Data\Spring\Objects\Factory\Config\AnotherDaoConfig.xml" />
<Content Include="Data\Spring\Objects\Factory\Config\SecondPropertyPlaceholderConfigurer.xml" />
<Content Include="Data\Spring\Objects\Factory\Config\FirstPropertyPlaceholderConfigurer.xml" />
<Content Include="Data\Spring\Objects\Factory\Config\PPCWithTypesTests.xml" />
<Content Include="Data\Spring\Objects\Factory\Config\TypeAliases.xml" />
<Content Include="Data\Spring\Objects\Factory\Config\DaoConfig.xml" />