ProxyContainerWithPool<ProxiedBean> container = new ProxyContainerWithPool<ProxiedBean>("ProxyInstanceAdvisorTestCase", "InterceptorContainer", ProxiedBean.class);
Class<?> interfaces[] = { MyInterface.class };
MyInterface proxy = container.constructProxy(interfaces);
reset(true);
String result = proxy.sayHi("Me");
assertEquals("Hi Me", result);
ProxiedBean bean1hi = Interceptions.getProxiedBean();
PerInstanceInterceptor pi1hi = Interceptions.getPerInstanceInterceptor();
PerJoinpointInterceptor pj1hi = Interceptions.getPerJoinpointInterceptor();
assertEquals(1, Interceptions.getProxiedBeanCalls());
assertEquals(1, Interceptions.getPerInstanceCalls());
assertEquals(1, Interceptions.getPerJoinpointCalls());
reset(false);
result = proxy.sayBye("Me");
assertEquals("Bye Me", result);
ProxiedBean bean1bye = Interceptions.getProxiedBean();
PerInstanceInterceptor pi1bye = Interceptions.getPerInstanceInterceptor();
PerJoinpointInterceptor pj1bye = Interceptions.getPerJoinpointInterceptor();
assertEquals(1, Interceptions.getProxiedBeanCalls());
assertEquals(1, Interceptions.getPerInstanceCalls());
assertEquals(1, Interceptions.getPerJoinpointCalls());
assertSame(bean1hi, bean1bye);
assertSame(pi1hi, pi1bye);
assertNotSame(pj1hi, pj1bye);
reset(true);
result = proxy.sayHi("Me");
assertEquals("Hi Me", result);
ProxiedBean bean2hi = Interceptions.getProxiedBean();
PerInstanceInterceptor pi2hi = Interceptions.getPerInstanceInterceptor();
PerJoinpointInterceptor pj2hi = Interceptions.getPerJoinpointInterceptor();
assertNotSame(bean1hi, bean2hi);