use of org.apache.tapestry5.http.services.Session 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.services.Session in project tapestry-5 by apache.
the class SessionImplTest method get_max_inactive.
@Test
public void get_max_inactive() {
HttpSession hs = mockHttpSession();
int seconds = 999;
expect(hs.getMaxInactiveInterval()).andReturn(seconds);
replay();
Session session = new SessionImpl(null, hs, null);
assertEquals(session.getMaxInactiveInterval(), seconds);
verify();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionPersistentFieldStrategyTest method post_change_to_root_component.
@Test
public void post_change_to_root_component() {
Session session = mockSession();
Request request = mockRequest();
Object value = new Object();
train_getSession(request, true, session);
session.setAttribute("state:foo.Bar::field", value);
replay();
SessionPersistentFieldStrategy strategy = new SessionPersistentFieldStrategy(request);
strategy.postChange("foo.Bar", null, "field", value);
verify();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionPersistentFieldStrategyTest method post_change_to_nested_component.
@Test
public void post_change_to_nested_component() {
Session session = mockSession();
Request request = mockRequest();
Object value = new Object();
train_getSession(request, true, session);
session.setAttribute("state:foo.Bar:fee.fum:field", value);
replay();
SessionPersistentFieldStrategy strategy = new SessionPersistentFieldStrategy(request);
strategy.postChange("foo.Bar", "fee.fum", "field", value);
verify();
}
use of org.apache.tapestry5.http.services.Session in project tapestry-5 by apache.
the class SessionPersistentFieldStrategyTest method discard_changes.
/**
* TAPESTRY-1475
*/
@Test
public void discard_changes() {
Session session = mockSession();
Request request = mockRequest();
train_getSession(request, false, session);
train_getAttributeNames(session, "state:foo.Bar:", "state:foo.Bar:baz:field");
session.setAttribute("state:foo.Bar:baz:field", null);
replay();
SessionPersistentFieldStrategy strategy = new SessionPersistentFieldStrategy(request);
strategy.discardChanges("foo.Bar");
verify();
}
Aggregations