### Question:
LoginController extends BaseController { @ApiOperation(value = "login", notes = "LOGIN_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, dataType = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, dataType = "String") }) @PostMapping(value = "/login") @ApiException(USER_LOGIN_FAILURE) public Result login(@RequestParam(value = "userName") String userName, @RequestParam(value = "userPassword") String userPassword, HttpServletRequest request, HttpServletResponse response) { logger.info("login user name: {} ", userName); if (StringUtils.isEmpty(userName)) { return error(Status.USER_NAME_NULL.getCode(), Status.USER_NAME_NULL.getMsg()); } String ip = getClientIpAddress(request); if (StringUtils.isEmpty(ip)) { return error(IP_IS_EMPTY.getCode(), IP_IS_EMPTY.getMsg()); } Result<Map<String, String>> result = authenticator.authenticate(userName, userPassword, ip); if (result.getCode() != Status.SUCCESS.getCode()) { return result; } response.setStatus(HttpStatus.SC_OK); Map<String, String> cookieMap = result.getData(); for (Map.Entry<String, String> cookieEntry : cookieMap.entrySet()) { Cookie cookie = new Cookie(cookieEntry.getKey(), cookieEntry.getValue()); cookie.setHttpOnly(true); response.addCookie(cookie); } return result; }  @ApiOperation(value = "login", notes = "LOGIN_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, dataType = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, dataType = "String") }) @PostMapping(value = "/login") @ApiException(USER_LOGIN_FAILURE) Result login(@RequestParam(value = "userName") String userName,
                        @RequestParam(value = "userPassword") String userPassword,
                        HttpServletRequest request,
                        HttpServletResponse response); @ApiOperation(value = "signOut", notes = "SIGNOUT_NOTES") @PostMapping(value = "/signOut") @ApiException(SIGN_OUT_ERROR) Result signOut(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
                          HttpServletRequest request);  }### Answer:
@Test public void testLogin() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userName","cxc"); paramsMap.add("userPassword","123456"); MvcResult mvcResult = mockMvc.perform(post("/login") .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); }