use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project cas by apereo.
the class CasLocaleChangeInterceptorTests method verifyRequestParamBeatsCasDefault.
@Test
public void verifyRequestParamBeatsCasDefault() throws Exception {
val request = new MockHttpServletRequest();
request.addParameter("locale", "it");
val response = new MockHttpServletResponse();
val resolver = new SessionLocaleResolver();
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, resolver);
getInterceptor(false).preHandle(request, response, new Object());
assertEquals(Locale.ITALIAN, resolver.resolveLocale(request));
}
use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project cas by apereo.
the class CasLocaleChangeInterceptorTests method verifyRequestHeaderBeatsCasDefault.
@Test
public void verifyRequestHeaderBeatsCasDefault() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val resolver = new SessionLocaleResolver();
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, resolver);
getInterceptor(false).preHandle(request, response, new Object());
assertEquals(Locale.ENGLISH, resolver.resolveLocale(request));
}
use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project cas by apereo.
the class CasLocaleChangeInterceptorTests method verifyForcedCasDefaultBeatsAll.
@Test
public void verifyForcedCasDefaultBeatsAll() throws Exception {
val request = new MockHttpServletRequest();
request.addParameter("locale", "it");
val response = new MockHttpServletResponse();
val resolver = new SessionLocaleResolver();
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, resolver);
getInterceptor(true).preHandle(request, response, new Object());
assertEquals(Locale.FRENCH, resolver.resolveLocale(request));
}
use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project cas by apereo.
the class CasLocaleChangeInterceptorTests method verifyServiceHasLocaleAssigned.
@Test
public void verifyServiceHasLocaleAssigned() throws Exception {
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val resolver = new SessionLocaleResolver();
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, resolver);
val service = RegisteredServiceTestUtils.getService();
when(argumentExtractor.extractService(any(HttpServletRequest.class))).thenReturn(service);
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
registeredService.setLocale("${T(java.util.Locale).GERMAN.getLanguage()}");
when(servicesManager.findServiceBy(any(Service.class))).thenReturn(registeredService);
getInterceptor(false).preHandle(request, response, new Object());
assertEquals(Locale.GERMAN, resolver.resolveLocale(request));
}
use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project nikita-noark5-core by HiOA-ABI.
the class AppWebMvcConfiguration method localeResolver.
/**
* Set the LocaleResolver for the GUI portion of the application
* By default english pages with be returned to the user
* @return LocaleResolver
*/
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(Locale.US);
return slr;
}
Aggregations