JstlLocalization implements Localization { public Locale getLocale() { return localeFor(Config.FMT_LOCALE); } JstlLocalization(RequestInfo request); ResourceBundle getBundle(); Locale getLocale(); Locale getFallbackLocale(); String getMessage(String key, Object... parameters);  }
@Test public void findLocaleFromRequest() { when(request.getAttribute(FMT_LOCALE + ".request")).thenReturn(PT_BR); assertThat(localization.getLocale(), equalTo(PT_BR)); }
@Test public void findLocaleFromSession() { when(session.getAttribute(FMT_LOCALE + ".session")).thenReturn(PT_BR); assertThat(localization.getLocale(), equalTo(PT_BR)); }
@Test public void findLocaleFromServletContext() { when(servletContext.getInitParameter(FMT_LOCALE)).thenReturn(PT_BR.toString()); assertThat(localization.getLocale(), equalTo(PT_BR)); }
@Test public void findLocaleFromRequestLocale() { when(request.getLocale()).thenReturn(PT_BR); assertThat(localization.getLocale(), equalTo(PT_BR)); }
@Test public void testLocaleWithSessionNotRequest() { when(request.getAttribute(FMT_LOCALE + ".request")).thenReturn(PT_BR); when(session.getAttribute(FMT_LOCALE + ".session")).thenReturn(Locale.ENGLISH); assertThat(localization.getLocale(), equalTo(PT_BR)); }