Examples of CountingAfterReturningAdvice


Examples of org.springframework.tests.aop.advice.CountingAfterReturningAdvice

    CountingThrowsAdvice cta = new CountingThrowsAdvice();

    pf.addAdvice(new SerializableNopInterceptor());
    // Try various advice types
    pf.addAdvice(new CountingBeforeAdvice());
    pf.addAdvice(new CountingAfterReturningAdvice());
    pf.addAdvice(cta);
    Person p = (Person) createAopProxy(pf).getProxy();

    p.echo(null);
    assertEquals(0, cta.getCalls());
View Full Code Here

Examples of org.springframework.tests.aop.advice.CountingAfterReturningAdvice

    assertEquals(i2, proxied.getAge());
  }

  @Test
  public void testAfterReturningAdvisorIsNotInvokedOnException() {
    CountingAfterReturningAdvice car = new CountingAfterReturningAdvice();
    TestBean target = new TestBean();
    ProxyFactory pf = new ProxyFactory(target);
    pf.addAdvice(new NopInterceptor());
    pf.addAdvice(car);
    assertEquals("Advice was wrapped in Advisor and added", car, pf.getAdvisors()[1].getAdvice());
    ITestBean proxied = (ITestBean) createProxy(pf);
    assertEquals(0, car.getCalls());
    int age = 10;
    proxied.setAge(age);
    assertEquals(age, proxied.getAge());
    assertEquals(2, car.getCalls());
    Exception exc = new Exception();
    // On exception it won't be invoked
    try {
      proxied.exceptional(exc);
      fail();
    }
    catch (Throwable t) {
      assertSame(exc, t);
    }
    assertEquals(2, car.getCalls());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.