SPRNET-1358 : Allow for ignoring of resources not found in PropertyFileVariableSource

SPRNET-1356 : Introduce IPriorityOrdered interface to ensure correct ordering among IObjectFactoryPostProcessors
SPRNET-1355 : TypeAlias usage with other IObjectFactoryPostProcessor object definitions not working.

work started on SPRNET-1262 

fix 2003/2005 solution builds
This commit is contained in:
markpollack
2010-08-19 14:56:55 +00:00
parent e793a01220
commit 2aee3148ca
29 changed files with 615 additions and 118 deletions

View File

@@ -6,10 +6,26 @@
<dictionary>
<entry key="TestObject" value="Spring.Objects.TestObject, Spring.Core.Tests" />
<entry key="intAlias" value="System.Int32" />
<entry key="TVariablePlaceholderConfigurer" value="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core"/>
</dictionary>
</property>
</object>
<object id="vpc" type="TVariablePlaceholderConfigurer">
<property name="VariableSources">
<list>
<object type="Spring.Objects.Factory.Config.ConfigSectionVariableSource, Spring.Core">
<property name="SectionNames" value="PropertyPlaceholderConfigurerSectionTest" />
</object>
</list>
</property>
</object>
<object lazy-init="true" type="Spring.Objects.Factory.Config.PropertyOverrideConfigurer, Spring.Core">
<property name="Order" value="2000"/>
<property name="ConfigSections" value="${prop.override.section}" />
</object>
<object id="testObject1" type="TestObject"/>
<object id="baseTestObject" type="TestObject" abstract="true"/>
@@ -20,6 +36,18 @@
<constructor-arg name="age" value="26"/>
</object>
<object id="testObject5" type="TestObject">
<constructor-arg name="name" value="Joe"/>
<constructor-arg name="age" value="26"/>
</object>
<object id="testObject6" type="TestObject">
<constructor-arg name="name" value="${test.name.1}"/>
<constructor-arg name="age" value="27"/>
</object>
<!-- SPRNET-1119 -->
<object id="testObject4" type="TestObject">
<constructor-arg name="name" value="Bruno"/>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<objects xmlns="http://www.springframework.net">
<description>
Tests for list and map handling in an XML object definition file.
</description>
<object id="foo" type="Spring.Objects.TestObject, Spring.Core.Tests" abstract="true">
<constructor-arg index="0" value="foo"/>
<constructor-arg index="1" value="2"/>
</object>
<object id="rod" type="Spring.Objects.TestObject, Spring.Core.Tests">
<constructor-arg index="0" value="rod"/>
<constructor-arg index="1" value="1"/>
</object>
</objects>

View File

@@ -18,7 +18,7 @@
#endregion
#region Imports
#region
using NUnit.Framework;
using Spring.Core.IO;
@@ -27,7 +27,7 @@ using Spring.Core.IO;
namespace Spring.Objects.Factory.Config
{
/// <summary>
/// <summary>
/// Unit tests for the PropertyFileVariableSource class.
/// </summary>
/// <author>Aleksandar Seovic</author>
@@ -50,17 +50,39 @@ namespace Spring.Objects.Factory.Config
Assert.IsNull(vs.ResolveVariable("dummy"));
}
[Test]
public void TestMissingResourceLocation()
{
PropertyFileVariableSource vs = new PropertyFileVariableSource();
vs.IgnoreMissingResources = true;
vs.Locations = new IResource[]
{
new AssemblyResource(
"assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/non-existent.properties")
,
new AssemblyResource(
"assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties")
,
};
// existing vars
Assert.AreEqual("Aleks Seovic", vs.ResolveVariable("name"));
Assert.AreEqual("32", vs.ResolveVariable("age"));
}
[Test]
public void TestVariablesResolutionWithTwoLocations()
{
PropertyFileVariableSource vs = new PropertyFileVariableSource();
vs.Locations = new IResource[]
{
new AssemblyResource(
"assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties"),
new AssemblyResource(
"assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/two.properties")
};
{
new AssemblyResource(
"assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties")
,
new AssemblyResource(
"assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/two.properties")
};
// existing vars
Assert.AreEqual("Aleksandar Seovic", vs.ResolveVariable("name")); // should be overriden by the second file
@@ -71,4 +93,4 @@ namespace Spring.Objects.Factory.Config
Assert.IsNull(vs.ResolveVariable("dummy"));
}
}
}
}

View File

@@ -108,8 +108,7 @@ namespace Spring.Objects.Factory.Config
[Test]
public void WithinApplicationContext()
{
IApplicationContext ctx = new XmlApplicationContext(
"file://Spring/Objects/Factory/Config/typeAliases.xml");
IApplicationContext ctx = new XmlApplicationContext("file://Spring/Objects/Factory/Config/typeAliases.xml");
object obj1 = ctx.GetObject("testObject1");
Assert.IsNotNull(obj1);
@@ -131,6 +130,26 @@ namespace Spring.Objects.Factory.Config
Assert.AreEqual(typeof(TestObject), obj4.GetType());
Assert.AreEqual("Bruno", ((TestObject)obj4).Name);
Assert.AreEqual(30, ((TestObject)obj4).Age);
object obj6 = ctx.GetObject("testObject6");
Assert.IsNotNull(obj6);
Assert.AreEqual(typeof(TestObject), obj6.GetType());
Assert.AreEqual("name from section", ((TestObject)obj6).Name);
Assert.AreEqual(27, ((TestObject)obj6).Age);
object obj5 = ctx.GetObject("testObject5");
Assert.IsNotNull(obj5);
Assert.AreEqual(typeof(TestObject), obj5.GetType());
Assert.AreEqual("overide-name", ((TestObject)obj5).Name);
Assert.AreEqual(26, ((TestObject)obj5).Age);
object vpc = ctx.GetObject("vpc");
Assert.IsNotNull(vpc);
Assert.AreEqual(typeof(VariablePlaceholderConfigurer), vpc.GetType());
}
private void CreateConfigurerAndTestLinkedList(IDictionary typeAliases)

View File

@@ -55,6 +55,29 @@ namespace Spring.Objects.Factory.Xml
//XmlConfigurator.Configure();
}
[Test]
public void WalkThrough()
{
IResource resource = new ReadOnlyXmlTestResource("ctor-args.xml", GetType());
XmlObjectFactory xof = new XmlObjectFactory(resource);
TestObject rod = (TestObject)xof.GetObject("rod");
Assert.AreEqual(1, rod.Age);
RootObjectDefinition def = (RootObjectDefinition) xof.GetObjectDefinition("rod");
ConstructorResolver resolver = new ConstructorResolver(xof, xof, new SimpleInstantiationStrategy(),
new ObjectDefinitionValueResolver(xof));
ConstructorInstantiationInfo ci = resolver.GetConstructorInstantiationInfo("rod", def, null, null);
AbstractObjectDefinition objDef = (AbstractObjectDefinition)xof.GetObjectDefinition("foo");
objDef.IsAbstract = false;
TestObject foo = (TestObject) xof.GetObject("foo");
Assert.AreEqual(2, foo.Age);
}
[Test]
public void RefSubelementsBuildCollection()
{

View File

@@ -821,6 +821,7 @@
<Content Include="Data\Spring\Objects\Factory\Xml\array-autowire.xml" />
<Content Include="Data\Spring\Objects\Factory\Xml\collectionMergingGeneric.xml" />
<Content Include="Data\Spring\Objects\Factory\Xml\collectionMerging.xml" />
<Content Include="Data\Spring\Objects\Factory\Xml\ctor-args.xml" />
<Content Include="Data\Spring\Objects\Factory\Xml\objectNameGeneration.xml" />
<Content Include="Data\Spring\Objects\Factory\Xml\simple-constructor-arg.xml" />
<Content Include="Data\Spring\Objects\Factory\Xml\expressions.xml" />
@@ -860,7 +861,9 @@
<EmbeddedResource Include="Objects\Factory\Attributes\RequiredWithThreeRequiredPropertiesOmitted.xml" />
<EmbeddedResource Include="Objects\Factory\Attributes\RequiredWithAllRequiredPropertiesProvided.xml" />
<EmbeddedResource Include="Objects\Factory\Attributes\RequiredWithCustomAttribute.xml" />
<Content Include="Spring.Core.Tests.dll.config" />
<Content Include="Spring.Core.Tests.dll.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="Resources\Spring.Context.Tests.de-AT.resx" />
<EmbeddedResource Include="Resources\Spring.Context.Tests.de.resx" />
<EmbeddedResource Include="Validation\ValidationNamespaceParserTests_WhenConfigFileIsNotValid.xml" />

View File

@@ -28,6 +28,9 @@ limitations under the License.
</sectionGroup>
<section name="PropertyPlaceholderConfigurerSectionTest" type="System.Configuration.NameValueSectionHandler"/>
<section name="PropertyOverideSectionTest" type="System.Configuration.NameValueSectionHandler"/>
<sectionGroup name='PropertyPlaceholderConfigurerSectionGroupTest'>
<section name="PropertyPlaceholderConfigurerSectionGroupTestSection" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
@@ -58,8 +61,13 @@ limitations under the License.
<PropertyPlaceholderConfigurerSectionTest>
<add key="test.name.1" value="name from section"/>
<add key="prop.override.section" value="PropertyOverideSectionTest"/>
</PropertyPlaceholderConfigurerSectionTest>
<PropertyOverideSectionTest>
<add key="testObject5.name" value="overide-name"/>
</PropertyOverideSectionTest>
<PropertyPlaceholderConfigurerSectionGroupTest>
<PropertyPlaceholderConfigurerSectionGroupTestSection>
<add key="test.name.2" value="name from sectiongroup/section"/>

View File

@@ -19,7 +19,7 @@ limitations under the License.
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
<section name="objects" type="Spring.Objects.Factory.Xml.ObjectFactorySectionHandler, Spring.Core" />
<section name="DaoConfiguration" type="System.Configuration.NameValueSectionHandler"/>
<section name="DatabaseConfiguration" type="System.Configuration.NameValueSectionHandler"/>
@@ -32,6 +32,9 @@ limitations under the License.
</sectionGroup>
<section name="PropertyPlaceholderConfigurerSectionTest" type="System.Configuration.NameValueSectionHandler"/>
<section name="PropertyOverideSectionTest" type="System.Configuration.NameValueSectionHandler"/>
<sectionGroup name='PropertyPlaceholderConfigurerSectionGroupTest'>
<section name="PropertyPlaceholderConfigurerSectionGroupTestSection" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
@@ -62,8 +65,13 @@ limitations under the License.
<PropertyPlaceholderConfigurerSectionTest>
<add key="test.name.1" value="name from section"/>
<add key="prop.override.section" value="PropertyOverideSectionTest"/>
</PropertyPlaceholderConfigurerSectionTest>
<PropertyOverideSectionTest>
<add key="testObject5.name" value="overide-name"/>
</PropertyOverideSectionTest>
<PropertyPlaceholderConfigurerSectionGroupTest>
<PropertyPlaceholderConfigurerSectionGroupTestSection>
<add key="test.name.2" value="name from sectiongroup/section"/>
@@ -185,7 +193,7 @@ limitations under the License.
<add name="mySqlDataSource" connectionString="mySqlServerConnectionString"/>
<add name="myOracleDataSource" connectionString="myOracleConnectionString" providerName="System.Data.OracleClient"/>
</connectionStrings>
<objects xmlns='http://www.springframework.net'>
<object name="foo" type="Spring.Objects.TestObject, Spring.Core.Tests" />
<object id="rod" type="Spring.Objects.TestObject, Spring.Core.Tests">

View File

@@ -18,7 +18,9 @@
#endregion
using System;
using Apache.NMS;
using Apache.NMS.ActiveMQ;
using NUnit.Framework;
using Spring.Testing.NUnit;
@@ -41,6 +43,14 @@ namespace Spring.Messaging.Nms.Core
this.PopulateProtectedVariables = true;
}
[Test]
public void ConnectionThrowException()
{
ConnectionFactory cf = new ConnectionFactory();
cf.BrokerUri = new Uri("tcp://localaaahost:61616");
IConnection c = cf.CreateConnection();
}
[Test]
public void ConvertAndSend()

View File

@@ -86,6 +86,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Messaging\Core\MessageQueueMetadataCacheTests.cs" />
<Compile Include="Messaging\Core\MessageQueueUtils.cs" />
<Compile Include="Messaging\Core\ThreadingTests.cs" />
<Compile Include="Messaging\Listener\Adapter\MessageListenerAdapterTests.cs" />
<Compile Include="Messaging\Listener\DistributedTxMessageListenerContainerTests.cs" />