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

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

Introduction

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

Prototype

public PerformanceMonitorInterceptor(boolean useDynamicLogger) 

Source Link

Document

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

Usage

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

@Test
public void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));

    Log log = mock(Log.class);

    PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
    interceptor.invokeUnderTrace(mi, log);

    verify(log).trace(anyString());//  w w w  . ja  v  a2 s. c  om
}

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

@Test
public void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
    MethodInvocation mi = mock(MethodInvocation.class);

    given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
    given(mi.proceed()).willThrow(new IllegalArgumentException());
    Log log = mock(Log.class);

    PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
    try {//from www.  jav  a 2  s.  co m
        interceptor.invokeUnderTrace(mi, log);
        fail("Must have propagated the IllegalArgumentException.");
    } catch (IllegalArgumentException expected) {
    }

    verify(log).trace(anyString());
}