HttpSessionNotifier implements SessionNotifier { @Override public void sessionCreated(RepositoryBackedSession session) { if (session instanceof HttpSession) { HttpSessionEvent event = new HttpSessionEvent((HttpSession)session); for (HttpSessionListener listener : descriptor.getHttpSessionListeners()) { listener.sessionCreated(event); } } } 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 testSessionCreated() { HttpSessionListener listener = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener); notifier.sessionCreated(session); verify(listener).sessionCreated(any(HttpSessionEvent.class)); HttpSessionListener listener2 = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener2); notifier.sessionCreated(session); verify(listener, times(2)).sessionCreated(any(HttpSessionEvent.class)); verify(listener2).sessionCreated(any(HttpSessionEvent.class)); }