@Test
public void testOneAdvisedObjectCallsAnother() {
int age1 = 33;
int age2 = 37;
TestBean target1 = new TestBean();
ProxyFactory pf1 = new ProxyFactory(target1);
// Permit proxy and invocation checkers to get context from AopContext
pf1.setExposeProxy(true);
NopInterceptor di1 = new NopInterceptor();
pf1.addAdvice(0, di1);
pf1.addAdvice(1, new ProxyMatcherInterceptor());
pf1.addAdvice(2, new CheckMethodInvocationIsSameInAndOutInterceptor());
pf1.addAdvice(1, new CheckMethodInvocationViaThreadLocalIsSameInAndOutInterceptor());
// Must be first
pf1.addAdvice(0, ExposeInvocationInterceptor.INSTANCE);
ITestBean advised1 = (ITestBean) pf1.getProxy();
advised1.setAge(age1); // = 1 invocation
TestBean target2 = new TestBean();
ProxyFactory pf2 = new ProxyFactory(target2);
pf2.setExposeProxy(true);
NopInterceptor di2 = new NopInterceptor();
pf2.addAdvice(0, di2);
pf2.addAdvice(1, new ProxyMatcherInterceptor());