RepositoryBackedSession { public void invalidate() { assertValid(); doInvalidate(false); } RepositoryBackedSession(SessionData sessionData, SessionManager manager, SessionFactory factory); protected  RepositoryBackedSession(RepositoryBackedSession linked); void setMaxInactiveInterval(int maxInactiveInterval); Object getAttribute(String key); @SuppressWarnings({ "rawtypes" }) Enumeration getAttributeNames(); List<String> getAttributeNamesWithValues(); long getCreationTime(); String getId(); long getLastAccessedTime(); int getMaxInactiveInterval(); void invalidate(); void doInvalidate(boolean expired); boolean isNew(); void removeAttribute(String name); Attribute getAttributeFromCache(String name); void setAttribute(String key, Object value); synchronized void commit(); boolean isValid(); boolean isExpired(); boolean isDirty(); Runnable getCommitter(); SessionData getSessionData(); boolean isCommitted(); void setCommitted(boolean committed); SessionManager getSessionManager(); int getConcurrentUses();  }
@Test(expected = IllegalStateException.class) public void testInvalidate() { RepositoryBackedSession rbs = new RepositoryBackedSession(sessionData, manager, factory); rbs.setAttribute("Test", "value"); rbs.setAttribute("Test2", "value2"); when(repository.prepareRemove(sessionData("1"))).thenReturn(Boolean.TRUE); rbs.invalidate(); verify(repository).prepareRemove(sessionData("1")); verify(manager).remove(sessionData); verify(notifier).sessionDestroyed(refEq(rbs), eq(false)); assertFalse(rbs.isValid()); rbs.getAttribute("Test"); }