use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class CustomizableTraceInterceptorTests method testExceptionPathLogsCorrectly.
@Test
public void testExceptionPathLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock(MethodInvocation.class);
IllegalArgumentException exception = new IllegalArgumentException();
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
given(methodInvocation.getThis()).willReturn(this);
given(methodInvocation.proceed()).willThrow(exception);
Log log = mock(Log.class);
given(log.isTraceEnabled()).willReturn(true);
CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
assertThatIllegalArgumentException().isThrownBy(() -> interceptor.invoke(methodInvocation));
verify(log).trace(anyString());
verify(log).trace(anyString(), eq(exception));
}
use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class CustomizableTraceInterceptorTests method testSunnyDayPathLogsCorrectly.
@Test
public void testSunnyDayPathLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock(MethodInvocation.class);
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
given(methodInvocation.getThis()).willReturn(this);
Log log = mock(Log.class);
given(log.isTraceEnabled()).willReturn(true);
CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
interceptor.invoke(methodInvocation);
verify(log, times(2)).trace(anyString());
}
use of org.apache.commons.logging.Log in project checkstyle by checkstyle.
the class Checker method process.
@Override
public int process(List<File> files) throws CheckstyleException {
if (cacheFile != null) {
cacheFile.putExternalResources(getExternalResourceLocations());
}
// Prepare to start
fireAuditStarted();
for (final FileSetCheck fsc : fileSetChecks) {
fsc.beginProcessing(charset);
}
final List<File> targetFiles = files.stream().filter(file -> CommonUtil.matchesFileExtension(file, fileExtensions)).collect(Collectors.toList());
processFiles(targetFiles);
// Finish up
// It may also log!!!
fileSetChecks.forEach(FileSetCheck::finishProcessing);
// It may also log!!!
fileSetChecks.forEach(FileSetCheck::destroy);
final int errorCount = counter.getCount();
fireAuditFinished();
return errorCount;
}
use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
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);
Log log = mock(Log.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 org.apache.commons.logging.Log in project spring-framework by spring-projects.
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]));
Log log = mock(Log.class);
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
interceptor.invokeUnderTrace(mi, log);
verify(log).trace(anyString());
}
Aggregations