@Test public void wrongPasswordShouldRedirectToErrorPage() throws Exception { request.addParameter("j_username", "nosuchusername"); request.addParameter("j_password", "nosuchpassword"); ModelAndView v = controller.handleRequest(request, response); assertEquals("wrongpassword", v.getViewName()); }
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"); } return new ModelAndView("wrongpassword"); }
LoginController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"); } return new ModelAndView("wrongpassword"); } }
LoginController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"); } return new ModelAndView("wrongpassword"); }  }
LoginController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"); } return new ModelAndView("wrongpassword"); }  void setAuthenticator(Authenticator authenticator); ModelAndView handleRequest(HttpServletRequest request,
            HttpServletResponse response); }
LoginController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String user = request.getParameter("j_username"); String pass = request.getParameter("j_password"); if (authenticator.isValidLogin(user, pass)) { return new ModelAndView("frontpage"); } return new ModelAndView("wrongpassword"); }  void setAuthenticator(Authenticator authenticator); ModelAndView handleRequest(HttpServletRequest request,
            HttpServletResponse response);  }