类 AopTestUtils
- java.lang.Object
- org.springframework.test.util.AopTestUtils
public abstract class AopTestUtils extends Object
AopTestUtils
is a collection of AOP-related utility methods for use in unit and integration testing scenarios.For Spring's core AOP utilities, see
AopUtils
andAopProxyUtils
.- 从以下版本开始:
- 4.2
- 作者:
- Sam Brannen, Juergen Hoeller
- 另请参阅:
AopUtils
,AopProxyUtils
,ReflectionTestUtils
构造器概要
构造器 构造器 说明 AopTestUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T> T
getTargetObject(Object candidate)
Get the target object of the suppliedcandidate
object.static <T> T
getUltimateTargetObject(Object candidate)
Get the ultimate target object of the suppliedcandidate
object, unwrapping not only a top-level proxy but also any number of nested proxies.
构造器详细资料
AopTestUtils
public AopTestUtils()
方法详细资料
getTargetObject
public static <T> T getTargetObject(Object candidate)
Get the target object of the suppliedcandidate
object.If the supplied
candidate
is a Spring proxy, the target of the proxy will be returned; otherwise, thecandidate
will be returned as is.- 参数:
candidate
- the instance to check (potentially a Spring AOP proxy; nevernull
)- 返回:
- the target object or the
candidate
(nevernull
) - 抛出:
IllegalStateException
- if an error occurs while unwrapping a proxy- 另请参阅:
Advised.getTargetSource()
,getUltimateTargetObject(java.lang.Object)
getUltimateTargetObject
public static <T> T getUltimateTargetObject(Object candidate)
Get the ultimate target object of the suppliedcandidate
object, unwrapping not only a top-level proxy but also any number of nested proxies.If the supplied
candidate
is a Spring proxy, the ultimate target of all nested proxies will be returned; otherwise, thecandidate
will be returned as is.- 参数:
candidate
- the instance to check (potentially a Spring AOP proxy; nevernull
)- 返回:
- the target object or the
candidate
(nevernull
) - 抛出:
IllegalStateException
- if an error occurs while unwrapping a proxy- 另请参阅:
Advised.getTargetSource()
,AopProxyUtils.ultimateTargetClass(java.lang.Object)