예제 #1
0
 @Test(dataProvider = "calendarsystemtype")
 public void test_lookupLocale(Chronology chrono, String calendarType) {
   Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA");
   builder.setUnicodeLocaleKeyword("ca", calendarType);
   Locale locale = builder.build();
   assertEquals(Chronology.ofLocale(locale), chrono);
 }
예제 #2
0
  @Test(expectedExceptions = DateTimeException.class)
  public void test_lookupLocale() {
    Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA");
    builder.setUnicodeLocaleKeyword("ca", "xxx");

    Locale locale = builder.build();
    Chronology.ofLocale(locale);
  }
예제 #3
0
 /**
  * Test lookup by calendarType of each chronology. Verify that the calendar can be found by {@link
  * java.time.chrono.Chronology#ofLocale}.
  */
 @Test
 public void test_ofLocaleByType() {
   // Test that all available chronologies can be successfully found using ofLocale
   Set<Chronology> chronos = Chronology.getAvailableChronologies();
   for (Chronology chrono : chronos) {
     Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA");
     builder.setUnicodeLocaleKeyword("ca", chrono.getCalendarType());
     Locale locale = builder.build();
     assertEquals(Chronology.ofLocale(locale), chrono, "Lookup by type");
   }
 }
예제 #4
0
 @Test
 public void test_chrono_byLocale_iso() {
   Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO");
   Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO");
   Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO");
 }
예제 #5
0
 @Test
 public void test_chrono_byLocale_oldJP_variant() {
   Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
   Assert.assertEquals(test.getId(), "Japanese");
   Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 }
예제 #6
0
 @Test
 public void test_chrono_byLocale_oldJP_noVariant() {
   Chronology test = Chronology.ofLocale(new Locale("ja", "JP"));
   Assert.assertEquals(test.getId(), "ISO");
   Assert.assertEquals(test, IsoChronology.INSTANCE);
 }
예제 #7
0
 @Test
 public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() {
   Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese"));
   Assert.assertEquals(test.getId(), "Japanese");
   Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 }