Package org.springframework.web.servlet

Examples of org.springframework.web.servlet.LocaleContextResolver


      }
    }

    // check LocaleContext
    if (localeResolver instanceof LocaleContextResolver) {
      LocaleContextResolver localeContextResolver = (LocaleContextResolver) localeResolver;
      LocaleContext localeContext = localeContextResolver.resolveLocaleContext(request);
      if (shouldSet) {
        assertEquals(localeContext.getLocale(), Locale.GERMANY);
      }
      else {
        assertEquals(localeContext.getLocale(), Locale.UK);
      }
      assertTrue(localeContext instanceof TimeZoneAwareLocaleContext);
      assertNull(((TimeZoneAwareLocaleContext) localeContext).getTimeZone());

      if (localeContextResolver instanceof AbstractLocaleContextResolver) {
        ((AbstractLocaleContextResolver) localeContextResolver).setDefaultTimeZone(TimeZone.getTimeZone("GMT+1"));
        assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+1"));
      }

      try {
        localeContextResolver.setLocaleContext(request, response, new SimpleLocaleContext(Locale.US));
        if (!shouldSet) {
          fail("should not be able to set Locale");
        }
        localeContext = localeContextResolver.resolveLocaleContext(request);
        assertEquals(localeContext.getLocale(), Locale.US);
        if (localeContextResolver instanceof AbstractLocaleContextResolver) {
          assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+1"));
        }
        else {
          assertNull(((TimeZoneAwareLocaleContext) localeContext).getTimeZone());
        }

        localeContextResolver.setLocaleContext(request, response,
            new SimpleTimeZoneAwareLocaleContext(Locale.GERMANY, TimeZone.getTimeZone("GMT+2")));
        localeContext = localeContextResolver.resolveLocaleContext(request);
        assertEquals(localeContext.getLocale(), Locale.GERMANY);
        assertTrue(localeContext instanceof TimeZoneAwareLocaleContext);
        assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+2"));

        localeContextResolver.setLocaleContext(request, response,
            new SimpleTimeZoneAwareLocaleContext(null, TimeZone.getTimeZone("GMT+3")));
        localeContext = localeContextResolver.resolveLocaleContext(request);
        assertEquals(localeContext.getLocale(), Locale.UK);
        assertTrue(localeContext instanceof TimeZoneAwareLocaleContext);
        assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+3"));

        if (localeContextResolver instanceof AbstractLocaleContextResolver) {
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.LocaleContextResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.