### Question:
LoginController extends UIController { @Override protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ApplicationState state = getApplicationState(request); LOG.debug("showForm() state=" + state); String preAction = request.getParameter("prevAction"); if(preAction != null && !preAction.equals("")) { state.setPreviousAction(preAction); } User user = state.getCurrentUser(); if (user == null) { user = checkSingleLogin(request); if (user != null) user = authenticate(user.getToken(), convertRoles(_grantedRoles)); } if (user == null) { user = checkAutoLogin(request); if (user != null) user = authenticate(user.getToken(), convertRoles(_grantedRoles)); } if (user == null) { String username = request.getParameter(LoginValidator.USERNAME_PARAM); String password = request.getParameter(LoginValidator.PASSWORD_PARAM); if (username != null && !"".equals(username) && password != null) { user = authenticate(username, password, errors); } } if (user != null) { LOG.debug("User authenticated: " + user.getName()); state.setCurrentUser(user); String prevAction = state.getPreviousAction(); if (prevAction == null) { LOG.debug("Redirect after succesful login"); return redirectAfterLogin(request, response); } else { LOG.debug("Redirect after succesful login: " + prevAction); state.setPreviousAction(null); return new ModelAndView(new RedirectView(prevAction)); } } LOG.debug("" + errors); Map model = errors.getModel(); model.put("login", new LoginCommand()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); return new ModelAndView(Constants.LOGIN_VIEW, model); } LoginController(TokenService tokenService, String redirectSuccessfulLogin); String getLoginPageURL(); void setLoginPageURL(String url); static ModelAndView redirect(String url); ModelAndView redirectAfterLogin(HttpServletRequest request, HttpServletResponse response); static void clearAutoLogin(HttpServletResponse response); static void clearSingleLogin(HttpServletResponse response); static void clearSecureRandom(HttpServletResponse response); static void clearRootCookie(HttpServletResponse response); static String getSecureRandomCookie(HttpServletRequest request); static String getSecureRandomSession(HttpServletRequest request); static void setSecureRandomSession(HttpServletRequest request, String secureRandom); static void generateSecureRandom(HttpServletRequest request, HttpServletResponse response); static String generateSecureRandom(); static String bytesToHex(byte[] bytes); static void clearCookie(String cookieName, HttpServletResponse response); static void clearOtherCookie(HttpServletResponse response,String cookieName,String path); static String extractUser(Property[] props); static String[] extractRoles(Property[] props); User getCurrentUser(HttpServletRequest request); void setRedirectAfterLoginCookie(HttpServletResponse response); static void setRedirectAfterLoginCookie(HttpServletResponse response, String url); static void setAutoLoginCookie(HttpServletResponse response, String token); static void setSingleLoginCookie(HttpServletResponse response, String token); List<String> getGrantedRoles(); void setGrantedRoles(List<String> roles); String arrayToString(String[] stringArray, String delimiter); void executePost(PostMethod post); @SuppressWarnings("unchecked") ModelAndView logIn(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
            BindException errors); ModelAndView logOut(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
            BindException errors); static final String AUTO_LOGIN_ID; static final String SINGLE_LOGIN_ID; static final String REDIRECT_AFTER_LOGIN; static final String SECURE_RANDOM; static final String JSESSION; static final String UI_FW; static final String MONITORING; static final String BPMS_CONSOLE; }### Answer:
@Test public void testShowFormWithoutUser() throws Exception { LoginCommand loginCom = new LoginCommand(); loginController = (LoginController) context.getBean("loginController"); ModelAndView mav = loginController.showForm(request, response, new BindException(loginCom, "test")); Assert.assertEquals(mav.getViewName(), Constants.LOGIN_VIEW); }