use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class PerformanceMonitorInterceptorTests method testSunnyDayPathLogsPerformanceMetricsCorrectly.
@Test
public void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
Logger log = mock(Logger.class);
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
interceptor.invokeUnderTrace(mi, log);
verify(log).trace(anyString());
}
use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class DebugInterceptorTests method testExceptionPathStillLogsCorrectly.
@Test
public void testExceptionPathStillLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock(MethodInvocation.class);
IllegalArgumentException exception = new IllegalArgumentException();
given(methodInvocation.proceed()).willThrow(exception);
Logger log = mock(Logger.class);
given(log.isTraceEnabled()).willReturn(true);
DebugInterceptor interceptor = new StubDebugInterceptor(log);
assertThatIllegalArgumentException().isThrownBy(() -> interceptor.invoke(methodInvocation));
checkCallCountTotal(interceptor);
verify(log).trace(anyString());
verify(log).trace(anyString(), eq(exception));
}
use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class DebugInterceptorTests method testSunnyDayPathLogsCorrectly.
@Test
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock(MethodInvocation.class);
Logger log = mock(Logger.class);
given(log.isTraceEnabled()).willReturn(true);
DebugInterceptor interceptor = new StubDebugInterceptor(log);
interceptor.invoke(methodInvocation);
checkCallCountTotal(interceptor);
verify(log, times(2)).trace(anyString());
}
use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class SimpleTraceInterceptorTests method testExceptionPathStillLogsCorrectly.
@Test
public void testExceptionPathStillLogsCorrectly() throws Throwable {
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
given(mi.getThis()).willReturn(this);
IllegalArgumentException exception = new IllegalArgumentException();
given(mi.proceed()).willThrow(exception);
Logger log = mock(Logger.class);
final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
assertThatIllegalArgumentException().isThrownBy(() -> interceptor.invokeUnderTrace(mi, log));
verify(log).trace(anyString());
verify(log).trace(anyString(), eq(exception));
}
use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class SimpleTraceInterceptorTests method testSunnyDayPathLogsCorrectly.
@Test
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
given(mi.getThis()).willReturn(this);
Logger log = mock(Logger.class);
SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true);
interceptor.invokeUnderTrace(mi, log);
verify(log, times(2)).trace(anyString());
}
Aggregations