LoginHandlerInterceptor extends HandlerInterceptorAdapter implements ServletContextAware { @Override public void afterCompletion(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final Exception ex) throws Exception { afterConcurrentHandlingStarted(request, response, handler); this.securityService.logout(); } LoginHandlerInterceptor(); @VisibleForTesting  LoginHandlerInterceptor(SecurityService securityService); static Map<String, String> getEnvironment(); @Override boolean preHandle(final HttpServletRequest request, final HttpServletResponse response,
      final Object handler); @Override void afterCompletion(final HttpServletRequest request, final HttpServletResponse response,
      final Object handler, final Exception ex); @Override void afterConcurrentHandlingStarted(HttpServletRequest request,
      HttpServletResponse response, Object handler); @Override void setServletContext(ServletContext servletContext);  }
@Test public void afterCompletion_logsOut() throws Exception { HttpServletRequest request = request().build(); interceptor.afterCompletion(request, null, null, null); verify(securityService, times(1)).logout(); }