use of org.apache.tapestry5.services.PersistentLocale in project tapestry-5 by apache.
the class PersistentLocaleImplTest method set_to_unsupported_locale.
/**
* TAP5-537
*/
@Test
public void set_to_unsupported_locale() {
PersistentLocale pl = new PersistentLocaleImpl(new PerthreadManagerImpl(null), "en,fr");
try {
pl.set(Locale.CHINESE);
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Locale 'zh' is not supported by this application. Supported locales are 'en,fr'; this is configured via the tapestry.supported-locales symbol.");
}
}
use of org.apache.tapestry5.services.PersistentLocale in project tapestry-5 by apache.
the class LocalizationSetterImplTest method set_nonpersistent_locale.
@Test
public void set_nonpersistent_locale() {
PersistentLocale pl = mockPersistentLocale();
ThreadLocale tl = mockThreadLocale();
Request request = mockRequest();
tl.setLocale(Locale.FRENCH);
replay();
LocalizationSetterImpl setter = new LocalizationSetterImpl(request, pl, tl, "en,fr");
setter.setNonPersistentLocaleFromLocaleName("fr_BE");
verify();
}
use of org.apache.tapestry5.services.PersistentLocale in project tapestry-5 by apache.
the class LocalizationSetterImplTest method is_supported_locale_name.
@Test
public void is_supported_locale_name() {
PersistentLocale pl = mockPersistentLocale();
ThreadLocale tl = mockThreadLocale();
Request request = mockRequest();
replay();
LocalizationSetterImpl setter = new LocalizationSetterImpl(request, pl, tl, "de, de_DE, de_CH,en");
assertTrue(setter.isSupportedLocaleName("de"));
assertTrue(setter.isSupportedLocaleName("de_de"));
assertTrue(setter.isSupportedLocaleName("de_de"));
assertTrue(setter.isSupportedLocaleName("de_DE"));
assertTrue(setter.isSupportedLocaleName("de_ch"));
assertTrue(setter.isSupportedLocaleName("de_CH"));
assertTrue(setter.isSupportedLocaleName("en"));
verify();
}
use of org.apache.tapestry5.services.PersistentLocale in project tapestry-5 by apache.
the class LocalizationSetterImplTest method unsupported_locale_in_request_uses_default_locale.
@Test
public void unsupported_locale_in_request_uses_default_locale() {
PersistentLocale pl = mockPersistentLocale();
ThreadLocale tl = mockThreadLocale();
Request request = mockRequest();
tl.setLocale(Locale.ITALIAN);
train_getLocale(request, Locale.CHINESE);
replay();
LocalizationSetterImpl setter = new LocalizationSetterImpl(request, pl, tl, "it,en,fr");
assertFalse(setter.setLocaleFromLocaleName("unknown"));
verify();
}
use of org.apache.tapestry5.services.PersistentLocale 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();
}
Aggregations