use of org.apache.tapestry5.http.internal.services.SessionLock 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());
}
use of org.apache.tapestry5.http.internal.services.SessionLock in project tapestry-5 by apache.
the class SessionImplTest method dirty_persisted_object_is_forced_to_update.
@Test
public void dirty_persisted_object_is_forced_to_update() {
HttpSession hs = mockHttpSession();
HttpServletRequest hsr = mockHttpServletRequest();
SessionPersistedObjectAnalyzer analyzer = newMock(SessionPersistedObjectAnalyzer.class);
Object dirty = new Object();
SessionLock lock = mockLock();
lock.acquireWriteLock();
train_getAttribute(hs, "dirty", dirty);
replay();
Session session = new ClusteredSessionImpl(hsr, hs, lock, analyzer);
assertSame(session.getAttribute("dirty"), dirty);
verify();
expect(analyzer.checkAndResetDirtyState(dirty)).andReturn(true);
train_getSession(hsr, false, hs);
lock.acquireWriteLock();
hs.setAttribute("dirty", dirty);
replay();
session.restoreDirtyObjects();
verify();
}
use of org.apache.tapestry5.http.internal.services.SessionLock in project tapestry-5 by apache.
the class SessionImplTest method get_attribute_names.
@Test
public void get_attribute_names() {
Enumeration e = Collections.enumeration(Arrays.asList("fred", "barney"));
HttpSession hs = mockHttpSession();
SessionLock lock = mockLock();
lock.acquireReadLock();
expect(hs.getAttributeNames()).andReturn(e);
replay();
Session session = new SessionImpl(null, hs, lock);
assertEquals(session.getAttributeNames(), Arrays.asList("barney", "fred"));
verify();
}
use of org.apache.tapestry5.http.internal.services.SessionLock in project tapestry-5 by apache.
the class SessionImplTest method invalidate.
@Test
public void invalidate() {
HttpSession hs = mockHttpSession();
SessionLock lock = mockLock();
hs.invalidate();
replay();
Session session = new SessionImpl(null, hs, lock);
session.invalidate();
verify();
}
use of org.apache.tapestry5.http.internal.services.SessionLock in project tapestry-5 by apache.
the class SessionImplTest method get_attribute_names_by_prefix.
@Test
public void get_attribute_names_by_prefix() {
Enumeration e = Collections.enumeration(Arrays.asList("fred", "barney", "fanny"));
HttpSession hs = mockHttpSession();
SessionLock lock = mockLock();
lock.acquireReadLock();
expect(hs.getAttributeNames()).andReturn(e);
replay();
Session session = new SessionImpl(null, hs, lock);
assertEquals(session.getAttributeNames("f"), Arrays.asList("fanny", "fred"));
verify();
}
Aggregations