use of cn.taketoday.core.i18n.SimpleLocaleContext in project today-infrastructure by TAKETODAY.
the class CookieLocaleResolverTests method testSetAndResolveLocaleContext.
@Test
public void testSetAndResolveLocaleContext() {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
MockServletRequestContext requestContext = new MockServletRequestContext(request, response);
CookieLocaleResolver resolver = new CookieLocaleResolver();
resolver.setLocaleContext(requestContext, new SimpleLocaleContext(new Locale("nl", "")));
Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
request = new MockHttpServletRequest();
request.setCookies(cookie);
resolver = new CookieLocaleResolver();
LocaleContext loc = resolver.resolveLocaleContext(requestContext);
assertThat(loc.getLocale().getLanguage()).isEqualTo("nl");
boolean condition = loc instanceof TimeZoneAwareLocaleContext;
assertThat(condition).isTrue();
assertThat(((TimeZoneAwareLocaleContext) loc).getTimeZone()).isNull();
}
use of cn.taketoday.core.i18n.SimpleLocaleContext in project today-framework by TAKETODAY.
the class CookieLocaleResolverTests method testSetAndResolveLocaleContext.
@Test
public void testSetAndResolveLocaleContext() {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
MockServletRequestContext requestContext = new MockServletRequestContext(request, response);
CookieLocaleResolver resolver = new CookieLocaleResolver();
resolver.setLocaleContext(requestContext, new SimpleLocaleContext(new Locale("nl", "")));
Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME);
request = new MockHttpServletRequest();
request.setCookies(cookie);
resolver = new CookieLocaleResolver();
LocaleContext loc = resolver.resolveLocaleContext(requestContext);
assertThat(loc.getLocale().getLanguage()).isEqualTo("nl");
boolean condition = loc instanceof TimeZoneAwareLocaleContext;
assertThat(condition).isTrue();
assertThat(((TimeZoneAwareLocaleContext) loc).getTimeZone()).isNull();
}
Aggregations