use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class ComponentEventDispatcherTest method page_activation_context_in_request.
@Test
public void page_activation_context_in_request() throws Exception {
ComponentRequestHandler handler = mockComponentRequestHandler();
Request request = mockRequest();
Response response = mockResponse();
ComponentClassResolver resolver = mockComponentClassResolver();
LocalizationSetter ls = mockLocalizationSetter();
MetaDataLocator metaDataLocator = neverWhitelistProtected();
ComponentEventRequestParameters expectedParameters = new ComponentEventRequestParameters("mypage", "mypage", "", "eventname", new URLEventContext(contextValueEncoder, new String[] { "alpha", "beta" }), new EmptyEventContext());
train_getPath(request, "/mypage:eventname");
expect(ls.isSupportedLocaleName("mypage:eventname")).andReturn(false);
train_isPageName(resolver, "mypage", true);
train_canonicalizePageName(resolver, "mypage", "mypage");
train_getParameter(request, InternalConstants.PAGE_CONTEXT_NAME, "alpha/beta");
train_getParameter(request, InternalConstants.CONTAINER_PAGE_NAME, null);
expect(request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND)).andStubReturn(null);
train_for_request_locale(request, ls);
handler.handleComponentEvent(expectedParameters);
replay();
Dispatcher dispatcher = new ComponentEventDispatcher(handler, new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", metaDataLocator, null));
assertTrue(dispatcher.dispatch(request, response));
verify();
}
use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class LocalizationSetterImplTest method get_selected_locale_names.
@Test
public void get_selected_locale_names() {
LocalizationSetter setter = new LocalizationSetterImpl(null, null, null, "en,fr");
Object localeNames = TestBase.get(setter, "supportedLocaleNames");
assertTrue(newSet("en", "fr").equals(localeNames));
}
use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class LocalizationSetterImplTest method known_locale.
@Test
public void known_locale() {
PersistentLocale pl = mockPersistentLocale();
ThreadLocale tl = mockThreadLocale();
Request request = mockRequest();
tl.setLocale(Locale.FRENCH);
pl.set(Locale.FRENCH);
replay();
LocalizationSetter setter = new LocalizationSetterImpl(request, pl, tl, "en,fr");
assertTrue(setter.setLocaleFromLocaleName("fr"));
verify();
}
use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class LocalizationSetterImplTest method to_locale_is_cached.
@Test
public void to_locale_is_cached() {
LocalizationSetter setter = new LocalizationSetterImpl(null, null, null, "en");
Locale l1 = setter.toLocale("en");
assertEquals(l1.toString(), "en");
checkLocale(l1, "en", "", "");
assertSame(setter.toLocale("en"), l1);
}
use of org.apache.tapestry5.services.LocalizationSetter in project tapestry-5 by apache.
the class LocalizationSetterImplTest method get_selected_locales.
@Test
public void get_selected_locales() {
LocalizationSetter setter = new LocalizationSetterImpl(null, null, null, "en,fr");
assertListsEquals(setter.getSupportedLocales(), Locale.ENGLISH, Locale.FRENCH);
}
Aggregations