use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionApplicationStatePersistenceStrategyTest method check_exists_with_invalid_session.
@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();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionApplicationStatePersistenceStrategyTest method set_aso.
@SuppressWarnings("unchecked")
@Test
public void set_aso() {
Request request = mockRequest();
Session session = mockSession();
Class asoClass = ReadOnlyBean.class;
Object aso = new ReadOnlyBean();
String key = "sso:" + asoClass.getName();
train_getSession(request, true, session);
session.setAttribute(key, aso);
replay();
ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
strategy.set(asoClass, aso);
verify();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionApplicationStatePersistenceStrategyTest method get_aso_already_exists.
@SuppressWarnings("unchecked")
@Test
public void get_aso_already_exists() {
Request request = mockRequest();
Session session = mockSession();
Class asoClass = ReadOnlyBean.class;
Object aso = new ReadOnlyBean();
String key = "sso:" + asoClass.getName();
ApplicationStateCreator creator = mockApplicationStateCreator();
train_getSession(request, true, session);
train_getAttribute(session, key, aso);
replay();
ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
assertSame(strategy.get(asoClass, creator), aso);
verify();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionApplicationStatePersistenceStrategyTest method get_aso_needs_to_be_created.
@SuppressWarnings("unchecked")
@Test
public void get_aso_needs_to_be_created() {
Request request = mockRequest();
Session session = mockSession();
Class asoClass = ReadOnlyBean.class;
Object aso = new ReadOnlyBean();
String key = "sso:" + asoClass.getName();
ApplicationStateCreator creator = mockApplicationStateCreator();
// First for exists()
train_getSession(request, false, session);
train_isInvalidated(session, false);
train_getAttribute(session, key, null);
// Second for get()
train_getSession(request, true, session);
// Not in map
train_getAttribute(session, key, null);
train_create(creator, aso);
train_getSession(request, true, session);
session.setAttribute(key, aso);
// Then for exists() after
train_getSession(request, false, session);
train_isInvalidated(session, false);
train_getAttribute(session, key, aso);
replay();
ApplicationStatePersistenceStrategy strategy = new SessionApplicationStatePersistenceStrategy(request);
assertFalse(strategy.exists(asoClass));
assertSame(strategy.get(asoClass, creator), aso);
assertTrue(strategy.exists(asoClass));
verify();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionImplTest method http_session_invalidate.
@Test
public void http_session_invalidate() {
HttpSession hs = mockHttpSession();
HttpServletRequest hsr = mockHttpServletRequest();
SessionLock lock = mockLock();
train_getSession(hsr, false, hs);
replay();
Session session = new SessionImpl(hsr, hs, lock);
assertFalse(session.isInvalidated());
verify();
train_getSession(hsr, false, null);
replay();
assertTrue(session.isInvalidated());
verify();
train_getSession(hsr, false, mockHttpSession());
replay();
assertTrue(session.isInvalidated());
}
Aggregations