SessionApplicationStatePersistenceStrategy implements ApplicationStatePersistenceStrategy { public <T> boolean exists(Class<T> ssoClass) { Session session = request.getSession(false); return session != null && !session.isInvalidated() && session.getAttribute(buildKey(ssoClass)) != null; } SessionApplicationStatePersistenceStrategy(Request request); @SuppressWarnings("unchecked") T get(Class<T> ssoClass, ApplicationStateCreator<T> creator); T getIfExists(Class<T> ssoClass); void set(Class<T> ssoClass, T sso); boolean exists(Class<T> ssoClass);  }
@SuppressWarnings("unchecked") @Test public void check_exists_does_not_create_session() { Request request = mockRequest(); Class asoClass = ReadOnlyBean.class; train_getSession(request, false, null); replay(); ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request); assertFalse(strategy.exists(asoClass)); verify(); }
@SuppressWarnings("unchecked") @Test @Issue("TAP5-2537") public void check_exists_with_invalid_session() { Request request = mockRequest(); Session session = mockSession(); Class asoClass = ReadOnlyBean.class; train_getSession(request, false, session); train_isInvalidated(session, true); replay(); ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request); assertFalse(strategy.exists(asoClass)); verify(); }