UnauthorizedEntryController { @RequestMapping(produces = TEXT_HTML_VALUE) public String unauthorizedHtml(HttpServletRequest request, RedirectAttributes redirectAttributes) { String url = (String) request.getAttribute(JudgeHandlerInterceptor.BACK_URL_ATTRIBUTE_NAME); if (StringUtils.hasText(url)) { redirectAttributes.addAttribute("url", url); } return "redirect:/login"; }  @RequestMapping(produces = TEXT_HTML_VALUE) String unauthorizedHtml(HttpServletRequest request, RedirectAttributes redirectAttributes); @RequestMapping(produces = APPLICATION_JSON_VALUE) ResponseEntity<Map<?, ?>> unauthorized();  }
@Test public void testUnauthorizedHtml() throws Exception { log.info("unauthorizedHtml"); MvcResult result = mvc.perform(get("/unauthorized").accept(MediaType.TEXT_HTML)) .andExpect(status().isFound()) .andExpect(redirectedUrl("/login")) .andReturn(); }