HttpSessionNotifier implements SessionNotifier { @Override public void attributeBeingStored(RepositoryBackedSession session, String key, Object value) { if (session instanceof HttpSession && value instanceof HttpSessionActivationListener) { ((HttpSessionActivationListener)value).sessionWillPassivate(new HttpSessionEvent((HttpSession)session)); } } HttpSessionNotifier(ServletContextDescriptor descriptor); @Override void sessionCreated(RepositoryBackedSession session); @Override void attributeAdded(RepositoryBackedSession session, String key, Object value); @Override void attributeReplaced(RepositoryBackedSession session, String key, Object replacedValue); @Override void attributeRemoved(RepositoryBackedSession session, String key, Object removedValue); @Override void attributeBeingStored(RepositoryBackedSession session, String key, Object value); @Override void attributeHasBeenRestored(RepositoryBackedSession session, String key, Object value); @Override void sessionDestroyed(RepositoryBackedSession session, boolean shutdown); @Override void sessionIdChanged(RepositoryBackedSession session, String oldId);  }
@Test public void testAttributeBeingStored() { HttpSessionActivationListener object = mock(HttpSessionActivationListener.class); notifier.attributeBeingStored(mock(RepositoryBackedSession.class), "Test", object); notifier.attributeBeingStored(session, "Test", "dummy"); verify(object, never()).sessionWillPassivate(any(HttpSessionEvent.class)); notifier.attributeBeingStored(session, "Test", object); verify(object).sessionWillPassivate(any(HttpSessionEvent.class)); }