Search in sources :

Example 1 with PersistentLocale

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.");
    }
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) PerthreadManagerImpl(org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl) Test(org.testng.annotations.Test)

Example 2 with PersistentLocale

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();
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) ThreadLocale(org.apache.tapestry5.ioc.services.ThreadLocale) Request(org.apache.tapestry5.http.services.Request) Test(org.testng.annotations.Test)

Example 3 with PersistentLocale

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();
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) ThreadLocale(org.apache.tapestry5.ioc.services.ThreadLocale) Request(org.apache.tapestry5.http.services.Request) Test(org.testng.annotations.Test)

Example 4 with PersistentLocale

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();
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) ThreadLocale(org.apache.tapestry5.ioc.services.ThreadLocale) Request(org.apache.tapestry5.http.services.Request) Test(org.testng.annotations.Test)

Example 5 with PersistentLocale

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();
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) ThreadLocale(org.apache.tapestry5.ioc.services.ThreadLocale) Request(org.apache.tapestry5.http.services.Request) LocalizationSetter(org.apache.tapestry5.services.LocalizationSetter) Test(org.testng.annotations.Test)

Aggregations

PersistentLocale (org.apache.tapestry5.services.PersistentLocale)6 Test (org.testng.annotations.Test)6 Request (org.apache.tapestry5.http.services.Request)5 ThreadLocale (org.apache.tapestry5.ioc.services.ThreadLocale)5 PerthreadManagerImpl (org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl)1 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)1