use of org.springframework.aop.interceptor.DebugInterceptor in project spring-framework by spring-projects.
the class AbstractAopProxyTests method testProxyIsBoundBeforeTargetSourceInvoked.
@Test
public void testProxyIsBoundBeforeTargetSourceInvoked() {
final TestBean target = new TestBean();
ProxyFactory pf = new ProxyFactory(target);
pf.addAdvice(new DebugInterceptor());
pf.setExposeProxy(true);
final ITestBean proxy = (ITestBean) createProxy(pf);
Advised config = (Advised) proxy;
// This class just checks proxy is bound before getTarget() call
config.setTargetSource(new TargetSource() {
@Override
public Class<?> getTargetClass() {
return TestBean.class;
}
@Override
public boolean isStatic() {
return false;
}
@Override
public Object getTarget() throws Exception {
assertEquals(proxy, AopContext.currentProxy());
return target;
}
@Override
public void releaseTarget(Object target) throws Exception {
}
});
// Just test anything: it will fail if context wasn't found
assertEquals(0, proxy.getAge());
}
use of org.springframework.aop.interceptor.DebugInterceptor in project spring-framework by spring-projects.
the class ObjenesisProxyTests method appliesAspectToClassWithComplexConstructor.
@Test
public void appliesAspectToClassWithComplexConstructor() {
@SuppressWarnings("resource") ApplicationContext context = new ClassPathXmlApplicationContext("ObjenesisProxyTests-context.xml", getClass());
ClassWithComplexConstructor bean = context.getBean(ClassWithComplexConstructor.class);
bean.method();
DebugInterceptor interceptor = context.getBean(DebugInterceptor.class);
assertThat(interceptor.getCount(), is(1L));
assertThat(bean.getDependency().getValue(), is(1));
}
Aggregations