LogoutAction { @RequestMapping("/logout") public void logout(HttpServletRequest request, HttpServletResponse response) { Credential credential = credentialResolver.resolveCredential(request); this.ki4soService.logout(credential); Cookie[] cookies = request.getCookies(); if(cookies!=null && cookies.length>0){ for(Cookie cookie:cookies){ if(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY.equals(cookie.getName())){ cookie.setMaxAge(0); response.addCookie(cookie); } } } String json = "{result:true}"; StringBuffer sb = new StringBuffer(); sb.append(getCallbackName("logoutKi4soServer", request)) .append("(") .append(json) .append(");"); try { response.setContentType("application/x-javascript"); response.setCharacterEncoding("UTF-8"); response.getWriter().println(sb.toString()); } catch (IOException e) { } }  void setKi4soService(Ki4soService ki4soService); void setCredentialResolver(CredentialResolver credentialResolver); @RequestMapping("/getAppList") void getAppList(HttpServletRequest request,
			HttpServletResponse response); @RequestMapping("/logout") void logout(HttpServletRequest request,
			HttpServletResponse response);  }
@Test public void testLogout() { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); CredentialResolver credentialResolver = Mockito.mock(CredentialResolver.class); logoutAction.setCredentialResolver(credentialResolver); Ki4soService ki4soService = Mockito.mock(Ki4soService.class); logoutAction.setKi4soService(ki4soService); logoutAction.logout(request, response); Assert.assertEquals(0, response.getCookies().length); request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); request.setCookies(new Cookie(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY, "dddsd")); logoutAction.logout(request, response); Assert.assertEquals(1, response.getCookies().length); Assert.assertEquals(0, response.getCookies()[0].getMaxAge()); }