SessionImpl implements Session { public boolean isInvalidated() { if (invalidated) return true; invalidated = request.getSession(false) != session; return invalidated; } SessionImpl(HttpServletRequest request, HttpSession session, SessionLock lock); Object getAttribute(String name); List<String> getAttributeNames(); void setAttribute(String name, Object value); List<String> getAttributeNames(String prefix); int getMaxInactiveInterval(); void invalidate(); boolean isInvalidated(); void setMaxInactiveInterval(int seconds); void restoreDirtyObjects();  }
@Test public void http_session_invalidate() { HttpSession hs = mockHttpSession(); HttpServletRequest hsr = mockHttpServletRequest(); SessionLock lock = mockLock(); train_getSession(hsr, false, hs); replay(); Session session = new SessionImpl(hsr, hs, lock); assertFalse(session.isInvalidated()); verify(); train_getSession(hsr, false, null); replay(); assertTrue(session.isInvalidated()); verify(); train_getSession(hsr, false, mockHttpSession()); replay(); assertTrue(session.isInvalidated()); }