### Question:
KeycloakLogoutHandler implements LogoutHandler { @Override public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { if (authentication == null) { log.warn("Cannot log out without authentication"); return; } else if (!KeycloakAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { log.warn("Cannot log out a non-Keycloak authentication: {}", authentication); return; } handleSingleSignOut(request, response, (KeycloakAuthenticationToken) authentication); } KeycloakLogoutHandler(AdapterDeploymentContext adapterDeploymentContext); void setAdapterTokenStoreFactory(AdapterTokenStoreFactory adapterTokenStoreFactory); @Override void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication);  }### Answer:
@Test public void testLogout() throws Exception { keycloakLogoutHandler.logout(request, response, keycloakAuthenticationToken); verify(session).logout(eq(keycloakDeployment)); }
@Test public void testLogoutAnonymousAuthentication() throws Exception { Authentication authentication = new AnonymousAuthenticationToken(UUID.randomUUID().toString(), UUID.randomUUID().toString(), authorities); keycloakLogoutHandler.logout(request, response, authentication); verifyZeroInteractions(session); }
@Test public void testLogoutUsernamePasswordAuthentication() throws Exception { Authentication authentication = new UsernamePasswordAuthenticationToken(UUID.randomUUID().toString(), UUID.randomUUID().toString(), authorities); keycloakLogoutHandler.logout(request, response, authentication); verifyZeroInteractions(session); }
@Test public void testLogoutRememberMeAuthentication() throws Exception { Authentication authentication = new RememberMeAuthenticationToken(UUID.randomUUID().toString(), UUID.randomUUID().toString(), authorities); keycloakLogoutHandler.logout(request, response, authentication); verifyZeroInteractions(session); }
@Test public void testLogoutNullAuthentication() throws Exception { keycloakLogoutHandler.logout(request, response, null); verifyZeroInteractions(session); }