Search in sources :

Example 11 with PageRenderRequestParameters

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

the class ComponentEventLinkEncoderImplTest method illegal_activation_context_leads_to_http_404.

@Test
public // TAP5-2436
void illegal_activation_context_leads_to_http_404() throws Exception {
    ComponentClassResolver resolver = mockComponentClassResolver();
    Request request = mockRequest();
    Response response = mockResponse();
    LocalizationSetter ls = mockLocalizationSetter();
    MetaDataLocator metaDataLocator = neverWhitelistProtected();
    train_getPath(request, "/foo/pageid=123");
    train_setLocaleFromLocaleName(ls, "foo", false);
    train_isPageName(resolver, "foo/pageid=123", false);
    train_isPageName(resolver, "foo", false);
    train_isPageName(resolver, "", true);
    train_canonicalizePageName(resolver, "", "Index");
    replay();
    ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", metaDataLocator, null);
    PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
    assertNull(parameters);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentClassResolver(org.apache.tapestry5.services.ComponentClassResolver) Request(org.apache.tapestry5.http.services.Request) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 12 with PageRenderRequestParameters

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

the class ComponentEventLinkEncoderImplTest method page_activation_context_for_root_index_page.

/**
 * TAPESTRY-2226
 */
@Test
public void page_activation_context_for_root_index_page() throws Exception {
    ComponentClassResolver resolver = mockComponentClassResolver();
    Request request = mockRequest(false);
    LocalizationSetter ls = mockLocalizationSetter();
    MetaDataLocator metaDataLocator = neverWhitelistProtected();
    train_getPath(request, "/foo/bar");
    train_setLocaleFromLocaleName(ls, "foo", false);
    train_isPageName(resolver, "foo/bar", false);
    train_isPageName(resolver, "foo", false);
    train_isPageName(resolver, "", true);
    train_canonicalizePageName(resolver, "", "index");
    train_getLocale(request, Locale.ITALIAN);
    ls.setNonPersistentLocaleFromLocaleName("it");
    replay();
    ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, null, null, null, null, true, null, "", metaDataLocator, null);
    PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
    assertEquals(parameters.getLogicalPageName(), "index");
    assertArraysEqual(parameters.getActivationContext().toStrings(), "foo", "bar");
    assertFalse(parameters.isLoopback());
    verify();
}
Also used : PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentClassResolver(org.apache.tapestry5.services.ComponentClassResolver) Request(org.apache.tapestry5.http.services.Request) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 13 with PageRenderRequestParameters

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

the class ComponentEventLinkEncoderImplTest method not_a_page_request.

@Test
public void not_a_page_request() throws Exception {
    ComponentClassResolver resolver = mockComponentClassResolver();
    Request request = mockRequest();
    Response response = mockResponse();
    LocalizationSetter ls = mockLocalizationSetter();
    stub_isPageName(resolver, false);
    train_setLocaleFromLocaleName(ls, "foo", false);
    train_getPath(request, "/foo/Bar.baz");
    replay();
    ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", null, null);
    PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
    assertNull(parameters);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentClassResolver(org.apache.tapestry5.services.ComponentClassResolver) Request(org.apache.tapestry5.http.services.Request) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) Test(org.testng.annotations.Test)

Example 14 with PageRenderRequestParameters

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

the class ComponentEventLinkEncoderImplTest method empty_path.

@Test
public void empty_path() throws Exception {
    ComponentClassResolver resolver = mockComponentClassResolver();
    Request request = mockRequest();
    Response response = mockResponse();
    LocalizationSetter ls = mockLocalizationSetter();
    train_getPath(request, "");
    train_setLocaleFromLocaleName(ls, "", false);
    train_isPageName(resolver, "", false);
    replay();
    ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", null, null);
    PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
    assertNull(parameters);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentClassResolver(org.apache.tapestry5.services.ComponentClassResolver) Request(org.apache.tapestry5.http.services.Request) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) Test(org.testng.annotations.Test)

Example 15 with PageRenderRequestParameters

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

the class ComponentEventLinkEncoderImplTest method no_extra_context.

private void no_extra_context(boolean finalSlash) throws Exception {
    ComponentClassResolver resolver = mockComponentClassResolver();
    Request request = mockRequest(false);
    LocalizationSetter ls = mockLocalizationSetter();
    MetaDataLocator metaDataLocator = neverWhitelistProtected();
    String path = "/foo/Bar" + (finalSlash ? "/" : "");
    train_getPath(request, path);
    train_setLocaleFromLocaleName(ls, "foo", false);
    train_isPageName(resolver, "foo/Bar", true);
    train_canonicalizePageName(resolver, "foo/Bar", "foo/bar");
    replay();
    ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, null, null, null, null, true, null, "", metaDataLocator, null);
    PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
    assertEquals(parameters.getLogicalPageName(), "foo/bar");
    assertEquals(parameters.getActivationContext().getCount(), 0);
    assertFalse(parameters.isLoopback());
    verify();
}
Also used : PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentClassResolver(org.apache.tapestry5.services.ComponentClassResolver) Request(org.apache.tapestry5.http.services.Request) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator)

Aggregations

PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)24 Test (org.testng.annotations.Test)14 Request (org.apache.tapestry5.http.services.Request)12 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)11 Link (org.apache.tapestry5.http.Link)10 Response (org.apache.tapestry5.http.services.Response)10 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)9 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)8 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)8 EmptyEventContext (org.apache.tapestry5.internal.EmptyEventContext)6 EventContext (org.apache.tapestry5.EventContext)3 RequestGlobals (org.apache.tapestry5.http.services.RequestGlobals)3 ContextPathEncoder (org.apache.tapestry5.services.ContextPathEncoder)3 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)3 Page (org.apache.tapestry5.internal.structure.Page)2 PageRenderRequestHandler (org.apache.tapestry5.services.PageRenderRequestHandler)2 IOException (java.io.IOException)1 Locale (java.util.Locale)1 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)1 ArrayEventContext (org.apache.tapestry5.internal.services.ArrayEventContext)1