コード例 #1
0
 @Test
 public void defaultLocale() {
   Locale originalDefaultLocale = Locale.getDefault();
   try {
     Locale newDefaultLocale =
         originalDefaultLocale.equals(Locale.GERMANY) ? Locale.FRANCE : Locale.GERMANY;
     Locale.setDefault(newDefaultLocale);
     // Create the request after changing the default locale.
     MockHttpServletRequest request = new MockHttpServletRequest();
     assertFalse(newDefaultLocale.equals(request.getLocale()));
     assertEquals(Locale.ENGLISH, request.getLocale());
   } finally {
     Locale.setDefault(originalDefaultLocale);
   }
 }
コード例 #2
0
  @Test
  public void locale() throws Exception {
    Locale locale = new Locale("nl", "nl");
    this.builder.locale(locale);

    MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

    assertEquals(locale, request.getLocale());
  }