### Question:
BasicGlobalExceptionHandler { protected ModelAndView handleException(HttpServletRequest req, Exception e) throws Exception { final String exceptionId = getUniqueId(); final String logExceptionId = exceptionId + ":"; LOG.error(logExceptionId + "Uncaught exception occured, user get's an error page.", e); LOG.error(logExceptionId + "Requested-URL: {}, method: {}", req.getRequestURL(), req.getMethod()); final List<String> headerInfos = getHeaderInfos(req); final Date time = new Date(); for (String header : headerInfos) { LOG.error(logExceptionId + header); } final List<String> parameterInfos = getParameterInfos(req); for (String parameter : parameterInfos) { LOG.error(logExceptionId + parameter); } if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) { throw e; } final StringBuilder stackTrace = new StringBuilder(); for (final StackTraceElement part : e.getStackTrace()) { stackTrace.append(part).append(newLine); } ModelAndView mav = new ModelAndView(); mav.addObject("exception", e); mav.addObject("exceptionId", exceptionId); mav.addObject("stacktrace", stackTrace); mav.addObject("headerInfos", headerInfos); mav.addObject("parameterInfos", parameterInfos); mav.addObject("time", time); mav.addObject("url", req.getRequestURL()); mav.setViewName(defaultErrorView); return mav; } BasicGlobalExceptionHandler(String defaultErrorView);   }### Answer:
@Test public void testHandleExceptionWithResponseCode() throws Exception { final Exception e = new ResourceNotFoundException(); try { testee.handleException(requestMock, e); fail("Exception should happend"); } catch (ResourceNotFoundException ce) { assertThat(ce).isSameAs(e); } }
@Test public void testHandleException() throws Exception { final Exception e = new Exception(); final ModelAndView mav = testee.handleException(requestMock, e); assertThat(mav.getViewName()).isEqualTo(VIEW_NAME); assertThat(mav.getModel()).containsKeys("stacktrace", "exception", "headerInfos", "parameterInfos", "url", "time"); assertThat(mav.getModel().get("exception")).isSameAs(e); assertThat(mav.getModel().get("headerInfos")).isNotNull(); assertThat(mav.getModel().get("parameterInfos")).isNotNull(); assertThat(mav.getModel().get("stacktrace")).isNotNull(); final Date time = (Date) mav.getModel().get("time"); assertThat(time).isNotNull(); assertThat(System.currentTimeMillis() - time.getTime()).isLessThan(100); }