jp.toLongString();
assertSame(target, AbstractAspectJAdvice.currentJoinPoint().getTarget());
assertFalse(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getTarget()));
ITestBean thisProxy = (ITestBean) AbstractAspectJAdvice.currentJoinPoint().getThis();
assertTrue(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getThis()));
assertNotSame(target, thisProxy);
// Check getting again doesn't cause a problem
assertSame(thisProxy, AbstractAspectJAdvice.currentJoinPoint().getThis());
// Try reentrant call--will go through this advice.
// Be sure to increment depth to avoid infinite recursion
if (depth++ == 0) {
// Check that toString doesn't cause a problem
thisProxy.toString();
// Change age, so this will be returned by invocation
thisProxy.setAge(newAge);
assertEquals(newAge, thisProxy.getAge());
}
assertSame(AopContext.currentProxy(), thisProxy);
assertSame(target, raw);
assertSame(method.getName(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getName());
assertEquals(method.getModifiers(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getModifiers());
MethodSignature msig = (MethodSignature) AbstractAspectJAdvice.currentJoinPoint().getSignature();
assertSame("Return same MethodSignature repeatedly", msig, AbstractAspectJAdvice.currentJoinPoint().getSignature());
assertSame("Return same JoinPoint repeatedly", AbstractAspectJAdvice.currentJoinPoint(), AbstractAspectJAdvice.currentJoinPoint());
assertEquals(method.getDeclaringClass(), msig.getDeclaringType());
assertTrue(Arrays.equals(method.getParameterTypes(), msig.getParameterTypes()));
assertEquals(method.getReturnType(), msig.getReturnType());
assertTrue(Arrays.equals(method.getExceptionTypes(), msig.getExceptionTypes()));
try {
msig.getParameterNames();
fail("Can't determine parameter names");
}
catch (UnsupportedOperationException ex) {
// Expected
}
msig.toLongString();
msig.toShortString();
}
});
ITestBean itb = (ITestBean) pf.getProxy();
// Any call will do
assertEquals("Advice reentrantly set age", newAge, itb.getAge());
}