private HttpSessionEvent createHttpSessionEvent(AbstractSessionEvent event) { Session session = event.getSession(); HttpSession httpSession = new HttpSessionAdapter<>(session, this.context); return new HttpSessionEvent(httpSession); }
public static void assertSessionContent(Supplier<Stream<ApplicationEvent>> eventCollector, Class<? extends AbstractSessionEvent> eventClass, String sessionId, String attName, String attValue, int timeout, TimeUnit timeoutUnit) { long stopTime = System.currentTimeMillis() + timeoutUnit.toMillis(timeout); List<Session> sessions = null; while (System.currentTimeMillis() < stopTime) { sessions = eventCollector.get() .filter(e -> e.getClass() == eventClass) .map(e -> eventClass.cast(e)) .filter(e -> e.getSessionId().equals(sessionId)) .map(e -> (Session) e.getSession()) .collect(Collectors.toList()); if (sessions.size() > 0) { break; } } assertEquals(1, sessions.size()); assertEquals(attValue, sessions.get(0).getAttribute(attName)); }