SPRNET-1433 - IsAopProxy and IsAopProxyType now check for inheritance based proxies too

This commit is contained in:
Marijn van der Zee
2012-04-24 13:29:56 +02:00
parent 3fc968f8ee
commit 55bdec00e5
2 changed files with 8 additions and 2 deletions

View File

@@ -60,7 +60,7 @@ namespace Spring.Aop.Framework
/// <returns><see langword="true"/> if the supplied <paramref name="objectType"/> is an AOP proxy type.</returns>
public static bool IsAopProxyType(Type objectType)
{
return IsCompositionAopProxyType(objectType) || IsDecoratorAopProxyType(objectType);
return IsCompositionAopProxyType(objectType) || IsDecoratorAopProxyType(objectType) || IsInheritanceAopProxyType(objectType);
}
/// <summary>
@@ -77,7 +77,7 @@ namespace Spring.Aop.Framework
/// </returns>
public static bool IsAopProxy(object instance)
{
return IsCompositionAopProxy(instance) || IsDecoratorAopProxy(instance);
return IsCompositionAopProxy(instance) || IsDecoratorAopProxy(instance) || IsInheritanceAopProxy(instance);
}
/// <summary>

View File

@@ -22,6 +22,8 @@ namespace Spring.Aop.Framework.DynamicProxy
public void TargetIsNotAProxy()
{
Assert.False(AopUtils.IsAopProxy(_target));
Assert.False(AopUtils.IsInheritanceAopProxy(_target));
Assert.False(AopUtils.IsInheritanceAopProxyType(_target.GetType()));
}
[Test]
@@ -69,8 +71,12 @@ namespace Spring.Aop.Framework.DynamicProxy
{
var proxy = (TestObject)ctx["michael"];
Assert.AreEqual("Michael", proxy.Name);
Assert.True(AopUtils.IsInheritanceAopProxyType(proxy.GetType()));
Assert.True(AopUtils.IsAopProxyType(proxy.GetType()));
Assert.True(AopUtils.IsInheritanceAopProxy(proxy));
Assert.True(AopUtils.IsAopProxy(proxy));
}
}
}