UnauthorizedEntryController { @RequestMapping(produces = APPLICATION_JSON_VALUE) public ResponseEntity<Map<?, ?>> unauthorized() { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(Collections.emptyMap()); }  @RequestMapping(produces = TEXT_HTML_VALUE) String unauthorizedHtml(HttpServletRequest request, RedirectAttributes redirectAttributes); @RequestMapping(produces = APPLICATION_JSON_VALUE) ResponseEntity<Map<?, ?>> unauthorized();  }
@Test public void testUnauthorized() throws Exception { log.info("unauthorized"); MvcResult result = mvc.perform(get("/unauthorized").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isUnauthorized()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andReturn(); }