org.springframework.tests.aop.advice.CountingAfterReturningAdvice Java Examples
The following examples show how to use
org.springframework.tests.aop.advice.CountingAfterReturningAdvice.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractAopProxyTests.java From spring-analysis-note with MIT License | 6 votes |
@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()); }
Example #2
Source File: AbstractAopProxyTests.java From java-technology-stack with MIT License | 6 votes |
@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()); }
Example #3
Source File: AbstractAopProxyTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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()); }