Example usage for org.springframework.aop.interceptor DebugInterceptor invoke

List of usage examples for org.springframework.aop.interceptor DebugInterceptor invoke

Introduction

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

Prototype

@Override
    public Object invoke(MethodInvocation invocation) throws Throwable 

Source Link

Usage

From source file:org.springframework.aop.interceptor.DebugInterceptorTests.java

@Test
public void testSunnyDayPathLogsCorrectly() throws Throwable {

    MethodInvocation methodInvocation = mock(MethodInvocation.class);

    Log log = mock(Log.class);
    given(log.isTraceEnabled()).willReturn(true);

    DebugInterceptor interceptor = new StubDebugInterceptor(log);
    interceptor.invoke(methodInvocation);
    checkCallCountTotal(interceptor);//  ww w .j a  v  a  2s .  com

    verify(log, times(2)).trace(anyString());
}

From source file:org.springframework.aop.interceptor.DebugInterceptorTests.java

@Test
public void testExceptionPathStillLogsCorrectly() throws Throwable {

    MethodInvocation methodInvocation = mock(MethodInvocation.class);

    IllegalArgumentException exception = new IllegalArgumentException();
    given(methodInvocation.proceed()).willThrow(exception);

    Log log = mock(Log.class);
    given(log.isTraceEnabled()).willReturn(true);

    DebugInterceptor interceptor = new StubDebugInterceptor(log);
    try {/*  w w w . j a  va2 s. c o  m*/
        interceptor.invoke(methodInvocation);
        fail("Must have propagated the IllegalArgumentException.");
    } catch (IllegalArgumentException expected) {
    }
    checkCallCountTotal(interceptor);

    verify(log).trace(anyString());
    verify(log).trace(anyString(), eq(exception));
}