fixed SPRNET-1231
This commit is contained in:
@@ -185,20 +185,23 @@ namespace Spring.Context.Support
|
||||
typeBuilder.TargetType = typeof(TestObject);
|
||||
Type proxyType = typeBuilder.BuildProxyType();
|
||||
|
||||
XmlApplicationContext ctx1 = new XmlApplicationContext();
|
||||
DefaultListableObjectFactory of = new DefaultListableObjectFactory();
|
||||
RootObjectDefinition od1 = new RootObjectDefinition(proxyType, false);
|
||||
od1.PropertyValues.Add("Name", "Bruno");
|
||||
((DefaultListableObjectFactory)ctx1.ObjectFactory).RegisterObjectDefinition("testObject", od1);
|
||||
of.RegisterObjectDefinition("testObject", od1);
|
||||
|
||||
GenericApplicationContext ctx1 = new GenericApplicationContext(of);
|
||||
ContextRegistry.RegisterContext(ctx1);
|
||||
|
||||
ITestObject to1 = ContextRegistry.GetContext().GetObject("testObject") as ITestObject;
|
||||
Assert.IsNotNull(to1);
|
||||
Assert.AreEqual("Bruno", to1.Name);
|
||||
|
||||
XmlApplicationContext ctx2 = new XmlApplicationContext();
|
||||
DefaultListableObjectFactory of2 = new DefaultListableObjectFactory();
|
||||
RootObjectDefinition od2 = new RootObjectDefinition(proxyType, false);
|
||||
od2.PropertyValues.Add("Name", "Baia");
|
||||
((DefaultListableObjectFactory)ctx2.ObjectFactory).RegisterObjectDefinition("testObject", od2);
|
||||
of2.RegisterObjectDefinition("testObject", od2);
|
||||
GenericApplicationContext ctx2 = new GenericApplicationContext(of2);
|
||||
|
||||
ContextRegistry.Clear();
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<objects xmlns='http://www.springframework.net'>
|
||||
|
||||
<object id='testOFPP' type='Spring.Context.Support.XmlApplicationContextTests+SPRNET1231ObjectFactoryPostProcessor' />
|
||||
|
||||
<object id='testFactory' type='Spring.Context.Support.XmlApplicationContextTests+SPRNET1231FactoryObject' />
|
||||
|
||||
<object id='testFactoryProduct' factory-object='testFactory' factory-method='GetProduct' />
|
||||
|
||||
</objects>
|
||||
@@ -35,6 +35,35 @@ namespace Spring.Context.Support
|
||||
[TestFixture]
|
||||
public sealed class XmlApplicationContextTests
|
||||
{
|
||||
[Test(Description = "http://jira.springframework.org/browse/SPRNET-1231")]
|
||||
public void SPRNET1231_DoesNotInvokeFactoryMethodDuringObjectFactoryPostProcessing()
|
||||
{
|
||||
string configLocation = TestResourceLoader.GetAssemblyResourceUri(this.GetType(), "XmlApplicationContextTests-SPRNET1231.xml");
|
||||
XmlApplicationContext ctx = new XmlApplicationContext(configLocation);
|
||||
|
||||
}
|
||||
|
||||
private class SPRNET1231ObjectFactoryPostProcessor : IObjectFactoryPostProcessor
|
||||
{
|
||||
public void PostProcessObjectFactory(IConfigurableListableObjectFactory factory)
|
||||
{
|
||||
SPRNET1231FactoryObject testFactory = (SPRNET1231FactoryObject)factory.GetObject("testFactory");
|
||||
Assert.AreEqual(0, testFactory.count);
|
||||
}
|
||||
}
|
||||
|
||||
private class SPRNET1231FactoryObject
|
||||
{
|
||||
public int count;
|
||||
|
||||
public ITestObject GetProduct()
|
||||
{
|
||||
count++;
|
||||
return new TestObject("test" + count, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void InnerObjectWithPostProcessing()
|
||||
{
|
||||
|
||||
@@ -770,6 +770,7 @@
|
||||
<EmbeddedResource Include="Core\IO\TestResource.txt" />
|
||||
<EmbeddedResource Include="Context\Support\innerObjectsWithPostProcessor.xml" />
|
||||
<EmbeddedResource Include="Core\IO\ConfigSectionResourceTests_config1.xml" />
|
||||
<EmbeddedResource Include="Context\Support\XmlApplicationContextTests-SPRNET1231.xml" />
|
||||
<Content Include="Data\PathMatcher\EmptyPattern.test" />
|
||||
<Content Include="Data\PathMatcher\Examples.test" />
|
||||
<Content Include="Data\PathMatcher\InBetween.test" />
|
||||
|
||||
Reference in New Issue
Block a user