Search in sources :

Example 11 with MessageSourceAccessor

use of org.springframework.context.support.MessageSourceAccessor in project gocd by gocd.

the class LocalizerTest method shouldReturnTheLocalizedMessageForTheCurrentLocale.

@Test
public void shouldReturnTheLocalizedMessageForTheCurrentLocale() {
    CurrentLocale locale = new CurrentLocale();
    ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setBasename("test_message");
    MessageSourceAccessor accessor = new MessageSourceAccessor(source);
    Localizer localizer = new Localizer(accessor, locale);
    assertThat(localizer.localize("hello_world"), is("Hello World"));
    locale.setLocaleString(Localizer.LOCALE_KANNADA);
    assertThat(localizer.localize("hello_world"), is("ನಮಸ್ಕಾರ"));
}
Also used : MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) ReloadableResourceBundleMessageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) Test(org.junit.Test)

Aggregations

MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)11 Test (org.junit.Test)6 ReloadableResourceBundleMessageSource (org.springframework.context.support.ReloadableResourceBundleMessageSource)3 Locale (java.util.Locale)2 DateTime (org.joda.time.DateTime)1 Duration (org.joda.time.Duration)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)1 DefaultLoginPageGeneratingFilter (org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter)1