Example usage for org.springframework.aop.interceptor SimpleTraceInterceptor SimpleTraceInterceptor

List of usage examples for org.springframework.aop.interceptor SimpleTraceInterceptor SimpleTraceInterceptor

Introduction

In this page you can find the example usage for org.springframework.aop.interceptor SimpleTraceInterceptor SimpleTraceInterceptor.

Prototype

public SimpleTraceInterceptor(boolean useDynamicLogger) 

Source Link

Document

Create a new SimpleTraceInterceptor with dynamic or static logger, according to the given flag.

Usage

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));
}