use of org.apache.tapestry5.http.services.Request 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.Request 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.Request 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.Request 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();
}
use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.
the class PageRenderRequestHandlerImplTest method loopback_request.
@Test
public void loopback_request() throws Exception {
RequestPageCache cache = mockRequestPageCache();
ComponentEventResultProcessor processor = mockComponentEventResultProcessor();
PageResponseRenderer renderer = mockPageResponseRenderer();
Page page = mockPage();
EventContext context = mockEventContext();
ComponentPageElement root = mockComponentPageElement();
InternalComponentResources pageResources = mockInternalComponentResources();
PageActivator activator = newMock(PageActivator.class);
Request request = mockRequest();
train_getAttribute(request, InternalConstants.BYPASS_ACTIVATION, null);
train_get(cache, "foo/Bar", page);
train_getRootElement(page, root);
train_getComponentResources(root, pageResources);
expect(activator.activatePage(pageResources, context, processor)).andReturn(false);
// Skips the pageReset()
renderer.renderPageResponse(page);
replay();
PageRenderRequestHandler handler = new PageRenderRequestHandlerImpl(cache, processor, renderer, activator, request);
PageRenderRequestParameters parameters = new PageRenderRequestParameters("foo/Bar", context, true);
handler.handle(parameters);
verify();
}
Aggregations