@Test public void testMyinfo() throws Exception { MvcResult mvcResult = mockMvc.perform(post("/user/myinfo").principal(new TestingAuthenticationToken("admin", null))) .andExpect(request().asyncStarted()).andExpect(request().asyncResult(is(not(isEmptyOrNullString())))).andReturn(); mvcResult = mockMvc.perform(asyncDispatch(mvcResult)).andReturn(); Member member = (Member) mvcResult.getRequest().getAttribute("member"); logger.debug("My account is \"{}\" and my name is {}", member.getId(), member.getName()); assertThat("Test UserInfo error ", "admin", is(equalTo(member.getId()))); }
@RequestMapping("/user/myinfo") public Callable<String> myinfo(final HttpServletRequest request, final Principal principal) { return new Callable<String>() { @Override public String call() throws Exception { request.setAttribute("member", memberManager.findByPrimaryKey(getPrincipalId(principal))); return "index"; } }; }
DefaultController { @RequestMapping("/user/myinfo") public Callable<String> myinfo(final HttpServletRequest request, final Principal principal) { return new Callable<String>() { @Override public String call() throws Exception { request.setAttribute("member", memberManager.findByPrimaryKey(getPrincipalId(principal))); return "index"; } }; } }
DefaultController { @RequestMapping("/user/myinfo") public Callable<String> myinfo(final HttpServletRequest request, final Principal principal) { return new Callable<String>() { @Override public String call() throws Exception { request.setAttribute("member", memberManager.findByPrimaryKey(getPrincipalId(principal))); return "index"; } }; }  }
DefaultController { @RequestMapping("/user/myinfo") public Callable<String> myinfo(final HttpServletRequest request, final Principal principal) { return new Callable<String>() { @Override public String call() throws Exception { request.setAttribute("member", memberManager.findByPrimaryKey(getPrincipalId(principal))); return "index"; } }; }  @InitBinder void initBinder(WebDataBinder binder); @RequestMapping("/") Callable<String> root(final Device device, final Model model); @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody Callable<String> listuser(); @RequestMapping("/user/myinfo") Callable<String> myinfo(final HttpServletRequest request, final Principal principal); @RequestMapping("/admin/user/{account}") Callable<String> userinfo(final @PathVariable Member account, final HttpServletRequest request); }
DefaultController { @RequestMapping("/user/myinfo") public Callable<String> myinfo(final HttpServletRequest request, final Principal principal) { return new Callable<String>() { @Override public String call() throws Exception { request.setAttribute("member", memberManager.findByPrimaryKey(getPrincipalId(principal))); return "index"; } }; }  @InitBinder void initBinder(WebDataBinder binder); @RequestMapping("/") Callable<String> root(final Device device, final Model model); @RequestMapping(value = "/admin/users", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody Callable<String> listuser(); @RequestMapping("/user/myinfo") Callable<String> myinfo(final HttpServletRequest request, final Principal principal); @RequestMapping("/admin/user/{account}") Callable<String> userinfo(final @PathVariable Member account, final HttpServletRequest request);  }