LogInterceptor extends HandlerInterceptorAdapter { @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { if (ex == null) { logAccess("->", request, response); } else { LOG.error("{} ** \"{} {} {}\":", request.getRemoteHost(), request.getMethod(), getRequestURIwithParams(request), request.getProtocol(), ex); } }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); @Override void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex);  }
@Test public void testAfterCompletion() { interceptor.afterCompletion(request, response, "testAfterCompletion", null); }
@Test public void testAfterCompletionWithException() { LOG.info("Simulating an exception for testing..."); interceptor.afterCompletion(request, response, "testAfterCompletion", new IllegalStateException("bumm")); }