UpdatePasswordController extends BaseFormController { @RequestMapping(value = "/requestRecoveryToken*", method = RequestMethod.GET) public String requestRecoveryToken( @RequestParam(value = "username", required = true) final String username, final HttpServletRequest request) { log.debug("Sending recovery token to user " + username); try { getUserManager().sendPasswordRecoveryEmail(username, RequestUtil.getAppURL(request) + RECOVERY_PASSWORD_TEMPLATE); } catch (final UsernameNotFoundException ignored) { } saveMessage(request, getText("updatePassword.recoveryToken.sent", request.getLocale())); return "redirect:/"; }  @RequestMapping(value = "/requestRecoveryToken*", method = RequestMethod.GET) String requestRecoveryToken(
            @RequestParam(value = "username", required = true) final String username,
            final HttpServletRequest request); @RequestMapping(value = "/updatePassword*", method = RequestMethod.GET) ModelAndView showForm(
            @RequestParam(value = "username", required = false) String username,
            @RequestParam(value = "token", required = false) final String token,
            final HttpServletRequest request); @RequestMapping(value = "/updatePassword*", method = RequestMethod.POST) ModelAndView onSubmit(
            @RequestParam(value = "username", required = true) final String username,
            @RequestParam(value = "token", required = false) final String token,
            @RequestParam(value = "currentPassword", required = false) final String currentPassword,
            @RequestParam(value = "password", required = true) final String password,
            final HttpServletRequest request); static final String RECOVERY_PASSWORD_TEMPLATE; }
@Test public void testRequestRecoveryToken() throws Exception { Wiser wiser = startWiser(getSmtpPort()); ResultActions update = mockMvc.perform(get("/requestRecoveryToken").param("username", "admin")) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("/")); wiser.stop(); assertTrue(wiser.getMessages().size() == 1); MvcResult result = update.andReturn(); MockHttpSession session = (MockHttpSession) result.getRequest().getSession(); assertNotNull(session.getAttribute(BaseFormController.MESSAGES_KEY)); }