@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");
}