Search in sources :

Example 21 with Request

use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.

the class SubmitTest method test_imagesubmit_event_fired.

@Test
public void test_imagesubmit_event_fired() {
    Request request = mockRequest();
    final ComponentResources resources = mockComponentResources();
    FormSupport formSupport = mockFormSupport();
    Asset image = mockAsset();
    String elementName = "myname";
    train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null);
    train_getParameter(request, elementName + ".x", "15");
    formSupport.defer(isA(Runnable.class));
    replay();
    Submit submit = new Submit(request);
    TestBase.set(submit, "resources", resources, "formSupport", formSupport, "image", image);
    submit.processSubmission("xyz", elementName);
    verify();
}
Also used : Request(org.apache.tapestry5.http.services.Request) Asset(org.apache.tapestry5.Asset) FormSupport(org.apache.tapestry5.services.FormSupport) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 22 with Request

use of org.apache.tapestry5.services.Request in project tapestry-5 by apache.

the class SubmitTest method test_submit_event_fired.

@Test
public void test_submit_event_fired() {
    Request request = mockRequest();
    final ComponentResources resources = mockComponentResources();
    FormSupport formSupport = mockFormSupport();
    String elementName = "myname";
    train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null);
    train_getParameter(request, elementName, "login");
    formSupport.defer(isA(Runnable.class));
    replay();
    Submit submit = new Submit(request);
    TestBase.set(submit, "resources", resources, "formSupport", formSupport);
    submit.processSubmission("xyz", elementName);
    verify();
}
Also used : Request(org.apache.tapestry5.http.services.Request) FormSupport(org.apache.tapestry5.services.FormSupport) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 23 with Request

use of org.apache.tapestry5.services.Request 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();
}
Also used : ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) Request(org.apache.tapestry5.http.services.Request) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Session(org.apache.tapestry5.http.services.Session) Issue(spock.lang.Issue) Test(org.testng.annotations.Test)

Example 24 with Request

use of org.apache.tapestry5.services.Request 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();
}
Also used : ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) Request(org.apache.tapestry5.http.services.Request) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 25 with Request

use of org.apache.tapestry5.services.Request 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();
}
Also used : ApplicationStatePersistenceStrategy(org.apache.tapestry5.services.ApplicationStatePersistenceStrategy) Request(org.apache.tapestry5.http.services.Request) ApplicationStateCreator(org.apache.tapestry5.services.ApplicationStateCreator) ReadOnlyBean(org.apache.tapestry5.internal.transform.pages.ReadOnlyBean) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)86 Request (org.apache.tapestry5.http.services.Request)83 Response (org.apache.tapestry5.http.services.Response)25 HttpServletRequest (javax.servlet.http.HttpServletRequest)19 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)19 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)18 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)17 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)15 HttpServletResponse (javax.servlet.http.HttpServletResponse)14 Session (org.apache.tapestry5.http.services.Session)14 Link (org.apache.tapestry5.http.Link)12 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)11 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)9 Context (org.apache.tapestry5.http.services.Context)8 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)8 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)8 IOException (java.io.IOException)7 BaseURLSourceImpl (org.apache.tapestry5.http.internal.services.BaseURLSourceImpl)7 BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)7 Dispatcher (org.apache.tapestry5.http.services.Dispatcher)7