类 AopTestUtils

java.lang.Object
cn.taketoday.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 Framework's core AOP utilities, see AopUtils and AopProxyUtils.

从以下版本开始:
4.0
作者:
Sam Brannen, Juergen Hoeller, Harry Yang
另请参阅:
  • 字段详细资料

    • isAopPresent

      static final boolean isAopPresent
  • 构造器详细资料

    • AopTestUtils

      public AopTestUtils()
  • 方法详细资料

    • getTargetObject

      public static <T> T getTargetObject(Object candidate)
      Get the target object of the supplied candidate object.

      If the supplied candidate is a Infra proxy, the target of the proxy will be returned; otherwise, the candidate will be returned as is.

      类型参数:
      T - the type of the target object
      参数:
      candidate - the instance to check (potentially a Infra AOP proxy; never null)
      返回:
      the target object or the candidate (never null)
      抛出:
      IllegalStateException - if an error occurs while unwrapping a proxy
      另请参阅:
    • getUltimateTargetObject

      public static <T> T getUltimateTargetObject(Object candidate)
      Get the ultimate target object of the supplied candidate object, unwrapping not only a top-level proxy but also any number of nested proxies.

      If the supplied candidate is a Infra proxy, the ultimate target of all nested proxies will be returned; otherwise, the candidate will be returned as is.

      NOTE: If the top-level proxy or a nested proxy is not backed by a static TargetSource, invocation of this utility method may result in undesired behavior such as infinite recursion leading to a StackOverflowError.

      类型参数:
      T - the type of the target object
      参数:
      candidate - the instance to check (potentially a Infra AOP proxy; never null)
      返回:
      the target object or the candidate (never null)
      抛出:
      IllegalStateException - if an error occurs while unwrapping a proxy
      另请参阅:
      • Advised.getTargetSource()
      • TargetSource.isStatic()
      • AopProxyUtils.ultimateTargetClass(java.lang.Object)