### Question:
ChainBreakingInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException, ServletException { if (handler instanceof HttpRequestHandler) { HttpRequestHandler resourcehandler = ((HttpRequestHandler) handler); resourcehandler.handleRequest(request, response); return false; } else { LOGGER.warn("handler can not be cast to HttpRequestHandler. It is of class " + handler.getClass().getCanonicalName()); return true; } }  @Override boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response, Object handler);  }### Answer:
@Test public void testPreHandle() throws Exception { boolean result = interceptor.preHandle(request, response, handler); verify(handler).handleRequest(request, response); assertFalse(result); }
@Test public void testPreHandleInvalidHandlerClass() throws Exception { boolean result = interceptor.preHandle(request, response, new String()); verify(handler, never()).handleRequest(request, response); assertTrue(result); }