use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocaleServiceImplTest method get_bundle_no_locale.
@Test
public void get_bundle_no_locale() {
final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), null);
assertNotNull(bundle);
assertEquals(7, bundle.getKeys().size());
assertEquals("default", bundle.localize("msg"));
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocaleServiceImplTest method get_bundle_no_application.
@Test
public void get_bundle_no_application() {
final MessageBundle bundle = localeService.getBundle(null, Locale.ENGLISH);
assertNull(bundle);
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocaleServiceImplTest method get_bundle_norwegian_no.
@Test
public void get_bundle_norwegian_no() {
final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), Locale.forLanguageTag("no"), "norwegian");
assertThat(bundle.asMap()).containsExactlyInAnyOrderEntriesOf(Map.of("a", "default", "b", "nb", "d", "no"));
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocaleServiceImplTest method get_bundle_with_variant.
@Test
public void get_bundle_with_variant() {
final Locale locale = new Locale("en", "US", "1");
final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), locale);
assertNotNull(bundle);
assertEquals(10, bundle.getKeys().size());
assertEquals("en_US_1", bundle.localize("msg"));
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocaleServiceImplTest method bundleInvalidateCaching.
@Test
public void bundleInvalidateCaching() {
final ResourceKeys resourceKeys = ResourceKeys.empty();
when(resourceService.findFiles(any(), anyString())).thenReturn(resourceKeys);
final ApplicationKey myApp = ApplicationKey.from("myapplication");
final ApplicationKey otherApp = ApplicationKey.from("otherapp");
MessageBundle bundleCached = localeService.getBundle(myApp, Locale.ENGLISH, "/phrases", "/override");
MessageBundle bundle = localeService.getBundle(myApp, Locale.ENGLISH, "/phrases", "/override");
MessageBundle otherBundleCached = localeService.getBundle(otherApp, Locale.ENGLISH, "/texts");
MessageBundle otherBundle = localeService.getBundle(otherApp, Locale.ENGLISH, "/texts");
assertSame(bundle, bundleCached);
assertSame(otherBundle, otherBundleCached);
Application application = Mockito.mock(Application.class);
when(application.getKey()).thenReturn(myApp);
localeService.activated(application);
bundle = localeService.getBundle(myApp, Locale.ENGLISH, "/phrases", "/override");
otherBundle = localeService.getBundle(otherApp, Locale.ENGLISH, "/texts");
assertNotSame(bundle, bundleCached);
assertSame(otherBundle, otherBundleCached);
}
Aggregations