public 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
and
AopProxyUtils
.
AopUtils
,
AopProxyUtils
Constructor and Description |
---|
AopTestUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
getTargetObject(Object candidate)
Get the target object of the supplied
candidate object. |
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. |
public static <T> T getTargetObject(Object candidate)
candidate
object.
If the supplied candidate
is a Spring
proxy, the target of the proxy will
be returned; otherwise, the candidate
will be returned
as is.
candidate
- the instance to check (potentially a Spring AOP proxy);
never null
candidate
; never null
IllegalStateException
- if an error occurs while unwrapping a proxyAdvised.getTargetSource()
,
getUltimateTargetObject(java.lang.Object)
public static <T> T getUltimateTargetObject(Object candidate)
candidate
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, the candidate
will be returned as is.
candidate
- the instance to check (potentially a Spring AOP proxy);
never null
candidate
; never
null
IllegalStateException
- if an error occurs while unwrapping a proxyAdvised.getTargetSource()
,
AopProxyUtils.ultimateTargetClass(java.lang.Object)