public void testSimpleMixinDefaultConstructor() throws Exception { SimpleMixin.invoked = false; SimpleInterceptor.invoked = null; PlainBean bean = new PlainBean(); AOPProxyFactoryMixin[] mixins = { new AOPProxyFactoryMixin(SimpleMixin.class, new Class[] {Simple.class}) }; Object proxy = assertCreateProxy(bean, mixins, Simple.class); Simple simple = (Simple) proxy; simple.doSomething(); assertTrue(SimpleMixin.invoked); assertNotNull(SimpleInterceptor.invoked); assertEquals("doSomething", SimpleInterceptor.invoked.getName()); }
public void testSimpleMixinConstructorProxyTarget() throws Exception { SimpleMixinWithConstructorAndDelegate.invoked = false; SimpleMixinWithConstructorAndDelegate.proxy = null; SimpleMixinWithConstructorAndDelegate.delegate = null; PlainBean bean = new PlainBean(); AOPProxyFactoryMixin[] mixins = { new AOPProxyFactoryMixin( SimpleMixinWithConstructorAndDelegate.class, new Class[] {Simple.class}, "this") }; Object proxy = assertCreateProxy(bean, mixins, Simple.class); Simple simple = (Simple) proxy; simple.doSomething(); assertTrue(SimpleMixinWithConstructorAndDelegate.invoked); assertNotNull(SimpleMixinWithConstructorAndDelegate.proxy); assertEquals(proxy, SimpleMixinWithConstructorAndDelegate.proxy); assertNotNull(SimpleMixinWithConstructorAndDelegate.delegate); assertEquals(bean, SimpleMixinWithConstructorAndDelegate.delegate); assertNotNull(SimpleInterceptor.invoked); assertEquals("doSomething", SimpleInterceptor.invoked.getName()); }