SessionManager { public void terminateSession() { @Nullable final HttpSession httpSession = getCurrentSession(); if (httpSession == null) { return; } clearSessionData(httpSession); try { httpSession.invalidate(); } catch (final IllegalStateException e) { LOG.info("terminateSession: session has already been terminated", e); } } SessionManager();   SessionManager(@Nonnull final HttpServletRequest httpServletRequest); @Nonnull String startWebSession(@Nonnull final Principal principal); @Nonnull String startAppSession(@Nonnull final Principal principal); void terminateSession(); @Nullable String getCurrentSessionId(); @Nullable static SecurityContext createSecurityContextForSession(@Nonnull final HttpServletRequest httpServletRequest); static final String AUTHENTICATION_SCHEME_USERNAME; static final String AUTHENTICATION_SCHEME_APPTOKEN; }
@Test public void testTerminateSession() { LOG.info("testTerminateSession"); Mockito.when(httpServletRequest.getSession(false)).thenReturn(httpSession); Mockito.doNothing().when(httpSession).invalidate(); impl.terminateSession(); verify(httpServletRequest).getSession(false); verify(httpSession).removeAttribute(SESSION_DATA_KEY); verify(httpSession).invalidate(); }
@Test public void testTerminateSessionNoCurrentSessionDoesNotThrow() { LOG.info("testTerminateSessionNoCurrentSessionDoesNotThrow"); Mockito.when(httpServletRequest.getSession(false)).thenReturn(null); impl.terminateSession(); verify(httpServletRequest).getSession(false); }