use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method page_requires_whitelist_and_client_on_whitelist.
@Test
public void page_requires_whitelist_and_client_on_whitelist() throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest(false);
LocalizationSetter ls = mockLocalizationSetter();
MetaDataLocator metaDataLocator = mockMetaDataLocator();
ClientWhitelist whitelist = newMock(ClientWhitelist.class);
String path = "/foo/Bar";
train_getPath(request, path);
train_setLocaleFromLocaleName(ls, "foo", false);
train_isPageName(resolver, "foo/Bar", true);
train_canonicalizePageName(resolver, "foo/Bar", "foo/bar");
expect(metaDataLocator.findMeta(MetaDataConstants.WHITELIST_ONLY_PAGE, "foo/bar", boolean.class)).andReturn(true);
expect(whitelist.isClientRequestOnWhitelist()).andReturn(true);
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, null, null, null, null, true, null, "", metaDataLocator, whitelist);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertEquals(parameters.getLogicalPageName(), "foo/bar");
assertEquals(parameters.getActivationContext().getCount(), 0);
assertFalse(parameters.isLoopback());
verify();
}
use of org.apache.tapestry5.services.LocalizationSetter 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();
}
use of org.apache.tapestry5.services.LocalizationSetter 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();
}
use of org.apache.tapestry5.services.LocalizationSetter 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();
}
use of org.apache.tapestry5.services.LocalizationSetter 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();
}
Aggregations