List of usage examples for org.springframework.aop.interceptor SimpleTraceInterceptor SimpleTraceInterceptor
public SimpleTraceInterceptor(boolean useDynamicLogger)
From source file:org.springframework.aop.interceptor.SimpleTraceInterceptorTests.java
@Test public void testSunnyDayPathLogsCorrectly() throws Throwable { MethodInvocation mi = mock(MethodInvocation.class); given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[] {})); given(mi.getThis()).willReturn(this); Log log = mock(Log.class); SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true); interceptor.invokeUnderTrace(mi, log); verify(log, times(2)).trace(anyString()); }
From source file:org.springframework.aop.interceptor.SimpleTraceInterceptorTests.java
@Test public void testExceptionPathStillLogsCorrectly() throws Throwable { MethodInvocation mi = mock(MethodInvocation.class); given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[] {})); given(mi.getThis()).willReturn(this); IllegalArgumentException exception = new IllegalArgumentException(); given(mi.proceed()).willThrow(exception); Log log = mock(Log.class); final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true); try {/*from www.j a v a 2 s. co m*/ interceptor.invokeUnderTrace(mi, log); fail("Must have propagated the IllegalArgumentException."); } catch (IllegalArgumentException expected) { } verify(log).trace(anyString()); verify(log).trace(anyString(), eq(exception)); }