Ejemplo n.º 1
0
  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());
  }
Ejemplo n.º 2
0
  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());
  }