< prev index next >

test/jdk/java/util/Locale/LocaleTest.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 25,14 ***
   * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613
   * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951
   * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549
   * 6786276 7066203 7085757 8008577 8030696 8170840 8255086 8263202 8287868
   * @summary test Locales
-  * @library /java/text/testlib
   * @modules jdk.localedata
!  * @run main/othervm -Djava.locale.providers=COMPAT,SPI LocaleTest
!  * @run main/othervm -Djava.locale.providers=COMPAT,SPI -Djava.locale.useOldISOCodes=true LocaleTest
   */
  /*
   * This file is available under and governed by the GNU General Public
   * License version 2 only, as published by the Free Software Foundation.
   * However, the following notice accompanied the original version of this
--- 25,13 ---
   * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613
   * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951
   * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549
   * 6786276 7066203 7085757 8008577 8030696 8170840 8255086 8263202 8287868
   * @summary test Locales
   * @modules jdk.localedata
!  * @run junit/othervm -Djava.locale.providers=COMPAT,SPI LocaleTest
!  * @run junit/othervm -Djava.locale.providers=COMPAT,SPI -Djava.locale.useOldISOCodes=true LocaleTest
   */
  /*
   * This file is available under and governed by the GNU General Public
   * License version 2 only, as published by the Free Software Foundation.
   * However, the following notice accompanied the original version of this

*** 84,11 ***
  import java.util.Date;
  import java.util.List;
  import java.util.Locale;
  import java.util.MissingResourceException;
  
! public class LocaleTest extends IntlTest {
      public LocaleTest() {
      }
  
      private int ENGLISH = 0;
      private int FRENCH = 1;
--- 83,15 ---
  import java.util.Date;
  import java.util.List;
  import java.util.Locale;
  import java.util.MissingResourceException;
  
! import org.junit.jupiter.api.Test;
+ 
+ import static org.junit.jupiter.api.Assertions.fail;
+ 
+ public class LocaleTest {
      public LocaleTest() {
      }
  
      private int ENGLISH = 0;
      private int FRENCH = 1;

*** 189,77 ***
          {   "",     "",     "",     "",     "Nynorsk",   "",     ""},
          // display name (<root>)
          {   "English (United States)", "French (France)", "Croatian (Croatia)", "Greek (Greece)", "Norwegian (Norway,Nynorsk)", "Italian", "xx (YY)" },
      };
  
!     public static void main(String[] args) throws Exception {
-         new LocaleTest().run(args);
-     }
- 
      public void TestBasicGetters() {
          for (int i = 0; i <= MAX_LOCALES; i++) {
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
!             logln("Testing " + testLocale + "...");
  
              if (!testLocale.getLanguage().equals(dataTable[LANG][i])) {
!                 errln("  Language code mismatch: " + testLocale.getLanguage() + " versus "
                          + dataTable[LANG][i]);
              }
              if (!testLocale.getCountry().equals(dataTable[CTRY][i])) {
!                 errln("  Country code mismatch: " + testLocale.getCountry() + " versus "
                          + dataTable[CTRY][i]);
              }
              if (!testLocale.getVariant().equals(dataTable[VAR][i])) {
!                 errln("  Variant code mismatch: " + testLocale.getVariant() + " versus "
                          + dataTable[VAR][i]);
              }
              if (!testLocale.toString().equals(dataTable[NAME][i])) {
!                 errln("  Locale name mismatch: " + testLocale.toString() + " versus "
                          + dataTable[NAME][i]);
              }
          }
  
!         logln("Same thing without variant codes...");
          for (int i = 0; i <= MAX_LOCALES; i++) {
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i]);
!             logln("Testing " + testLocale + "...");
  
              if (!testLocale.getLanguage().equals(dataTable[LANG][i])) {
!                 errln("  Language code mismatch: " + testLocale.getLanguage() + " versus "
                          + dataTable[LANG][i]);
              }
              if (!testLocale.getCountry().equals(dataTable[CTRY][i])) {
!                 errln("  Country code mismatch: " + testLocale.getCountry() + " versus "
                          + dataTable[CTRY][i]);
              }
              if (!testLocale.getVariant().equals("")) {
!                 errln("  Variant code mismatch: " + testLocale.getVariant() + " versus \"\"");
              }
          }
      }
  
      public void TestSimpleResourceInfo() {
          for (int i = 0; i <= MAX_LOCALES; i++) {
              if (dataTable[LANG][i].equals("xx")) {
                  continue;
              }
  
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
!             logln("Testing " + testLocale + "...");
  
              if (!testLocale.getISO3Language().equals(dataTable[LANG3][i])) {
!                 errln("  ISO-3 language code mismatch: " + testLocale.getISO3Language()
                          + " versus " + dataTable[LANG3][i]);
              }
              if (!testLocale.getISO3Country().equals(dataTable[CTRY3][i])) {
!                 errln("  ISO-3 country code mismatch: " + testLocale.getISO3Country()
                          + " versus " + dataTable[CTRY3][i]);
              }
  /*
              // getLCID() is currently private
              if (!String.valueOf(testLocale.getLCID()).equals(dataTable[LCID][i]))
!                 errln("  LCID mismatch: " + testLocale.getLCID() + " versus "
                              + dataTable[LCID][i]);
  */
          }
      }
  
--- 192,75 ---
          {   "",     "",     "",     "",     "Nynorsk",   "",     ""},
          // display name (<root>)
          {   "English (United States)", "French (France)", "Croatian (Croatia)", "Greek (Greece)", "Norwegian (Norway,Nynorsk)", "Italian", "xx (YY)" },
      };
  
!     @Test
      public void TestBasicGetters() {
          for (int i = 0; i <= MAX_LOCALES; i++) {
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
!             System.out.println("Testing " + testLocale + "...");
  
              if (!testLocale.getLanguage().equals(dataTable[LANG][i])) {
!                 fail("  Language code mismatch: " + testLocale.getLanguage() + " versus "
                          + dataTable[LANG][i]);
              }
              if (!testLocale.getCountry().equals(dataTable[CTRY][i])) {
!                 fail("  Country code mismatch: " + testLocale.getCountry() + " versus "
                          + dataTable[CTRY][i]);
              }
              if (!testLocale.getVariant().equals(dataTable[VAR][i])) {
!                 fail("  Variant code mismatch: " + testLocale.getVariant() + " versus "
                          + dataTable[VAR][i]);
              }
              if (!testLocale.toString().equals(dataTable[NAME][i])) {
!                 fail("  Locale name mismatch: " + testLocale.toString() + " versus "
                          + dataTable[NAME][i]);
              }
          }
  
!         System.out.println("Same thing without variant codes...");
          for (int i = 0; i <= MAX_LOCALES; i++) {
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i]);
!             System.out.println("Testing " + testLocale + "...");
  
              if (!testLocale.getLanguage().equals(dataTable[LANG][i])) {
!                 fail("  Language code mismatch: " + testLocale.getLanguage() + " versus "
                          + dataTable[LANG][i]);
              }
              if (!testLocale.getCountry().equals(dataTable[CTRY][i])) {
!                 fail("  Country code mismatch: " + testLocale.getCountry() + " versus "
                          + dataTable[CTRY][i]);
              }
              if (!testLocale.getVariant().equals("")) {
!                 fail("  Variant code mismatch: " + testLocale.getVariant() + " versus \"\"");
              }
          }
      }
  
+     @Test
      public void TestSimpleResourceInfo() {
          for (int i = 0; i <= MAX_LOCALES; i++) {
              if (dataTable[LANG][i].equals("xx")) {
                  continue;
              }
  
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
!             System.out.println("Testing " + testLocale + "...");
  
              if (!testLocale.getISO3Language().equals(dataTable[LANG3][i])) {
!                 fail("  ISO-3 language code mismatch: " + testLocale.getISO3Language()
                          + " versus " + dataTable[LANG3][i]);
              }
              if (!testLocale.getISO3Country().equals(dataTable[CTRY3][i])) {
!                 fail("  ISO-3 country code mismatch: " + testLocale.getISO3Country()
                          + " versus " + dataTable[CTRY3][i]);
              }
  /*
              // getLCID() is currently private
              if (!String.valueOf(testLocale.getLCID()).equals(dataTable[LCID][i]))
!                 fail("  LCID mismatch: " + testLocale.getLCID() + " versus "
                              + dataTable[LCID][i]);
  */
          }
      }
  

*** 267,58 ***
       * @bug 4101316
       * @bug 4084688 (This bug appears to be a duplicate of something, because it was fixed
       *              between 1.1.5 and 1.1.6, but I included a new test for it anyway)
       * @bug 4052440 Stop falling back to the default locale.
       */
      public void TestDisplayNames() {
          Locale saveDefault = Locale.getDefault();
          Locale english = Locale.US;
          Locale french = Locale.FRANCE;
          Locale croatian = Locale.of("hr", "HR");
          Locale greek = Locale.of("el", "GR");
  
          Locale.setDefault(english);
!         logln("With default = en_US...");
!         logln("  In default locale...");
          doTestDisplayNames(null, DLANG_EN, false);
!         logln("  In locale = en_US...");
          doTestDisplayNames(english, DLANG_EN, false);
!         logln("  In locale = fr_FR...");
          doTestDisplayNames(french, DLANG_FR, false);
!         logln("  In locale = hr_HR...");
          doTestDisplayNames(croatian, DLANG_HR, false);
!         logln("  In locale = el_GR...");
          doTestDisplayNames(greek, DLANG_EL, false);
  
          Locale.setDefault(french);
!         logln("With default = fr_FR...");
!         logln("  In default locale...");
          doTestDisplayNames(null, DLANG_FR, true);
!         logln("  In locale = en_US...");
          doTestDisplayNames(english, DLANG_EN, true);
!         logln("  In locale = fr_FR...");
          doTestDisplayNames(french, DLANG_FR, true);
!         logln("  In locale = hr_HR...");
          doTestDisplayNames(croatian, DLANG_HR, true);
!         logln("  In locale = el_GR...");
          doTestDisplayNames(greek, DLANG_EL, true);
  
          Locale.setDefault(saveDefault);
      }
  
      private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
          String language = Locale.getDefault().getLanguage();
  
          if (defaultIsFrench && !language.equals("fr")) {
!             errln("Default locale should be French, but it's really " + language);
          } else if (!defaultIsFrench && !language.equals("en")) {
!             errln("Default locale should be English, but it's really " + language);
          }
  
          for (int i = 0; i <= MAX_LOCALES; i++) {
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
!             logln("  Testing " + testLocale + "...");
  
              String testLang;
              String testCtry;
              String testVar;
              String testName;
--- 268,59 ---
       * @bug 4101316
       * @bug 4084688 (This bug appears to be a duplicate of something, because it was fixed
       *              between 1.1.5 and 1.1.6, but I included a new test for it anyway)
       * @bug 4052440 Stop falling back to the default locale.
       */
+     @Test
      public void TestDisplayNames() {
          Locale saveDefault = Locale.getDefault();
          Locale english = Locale.US;
          Locale french = Locale.FRANCE;
          Locale croatian = Locale.of("hr", "HR");
          Locale greek = Locale.of("el", "GR");
  
          Locale.setDefault(english);
!         System.out.println("With default = en_US...");
!         System.out.println("  In default locale...");
          doTestDisplayNames(null, DLANG_EN, false);
!         System.out.println("  In locale = en_US...");
          doTestDisplayNames(english, DLANG_EN, false);
!         System.out.println("  In locale = fr_FR...");
          doTestDisplayNames(french, DLANG_FR, false);
!         System.out.println("  In locale = hr_HR...");
          doTestDisplayNames(croatian, DLANG_HR, false);
!         System.out.println("  In locale = el_GR...");
          doTestDisplayNames(greek, DLANG_EL, false);
  
          Locale.setDefault(french);
!         System.out.println("With default = fr_FR...");
!         System.out.println("  In default locale...");
          doTestDisplayNames(null, DLANG_FR, true);
!         System.out.println("  In locale = en_US...");
          doTestDisplayNames(english, DLANG_EN, true);
!         System.out.println("  In locale = fr_FR...");
          doTestDisplayNames(french, DLANG_FR, true);
!         System.out.println("  In locale = hr_HR...");
          doTestDisplayNames(croatian, DLANG_HR, true);
!         System.out.println("  In locale = el_GR...");
          doTestDisplayNames(greek, DLANG_EL, true);
  
          Locale.setDefault(saveDefault);
      }
  
      private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
          String language = Locale.getDefault().getLanguage();
  
          if (defaultIsFrench && !language.equals("fr")) {
!             fail("Default locale should be French, but it's really " + language);
          } else if (!defaultIsFrench && !language.equals("en")) {
!             fail("Default locale should be English, but it's really " + language);
          }
  
          for (int i = 0; i <= MAX_LOCALES; i++) {
              Locale testLocale = Locale.of(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
!             System.out.println("  Testing " + testLocale + "...");
  
              String testLang;
              String testCtry;
              String testVar;
              String testName;

*** 371,59 ***
              if (expectedName.equals("")) {
                  expectedName = dataTable[DNAME_ROOT][i];
              }
  
              if (!testLang.equals(expectedLang)) {
!                 errln("Display language mismatch: " + testLang + " versus " + expectedLang);
              }
              if (!testCtry.equals(expectedCtry)) {
!                 errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
              }
              if (!testVar.equals(expectedVar)) {
!                 errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
              }
              if (!testName.equals(expectedName)) {
!                 errln("Display name mismatch: " + testName + " versus " + expectedName);
              }
          }
      }
  
      @SuppressWarnings("deprecation")
      public void TestSimpleObjectStuff() {
          Locale test1 = new Locale("aa", "AA");
          Locale test2 = new Locale("aa", "AA");
          Locale test3 = (Locale) test1.clone();
          Locale test4 = Locale.of("zz", "ZZ");
  
          if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) {
!             errln("Some of the test variables point to the same locale!");
          }
  
          if (test3 == null) {
!             errln("clone() failed to produce a valid object!");
          }
  
          if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) {
!             errln("clone() or equals() failed: objects that should compare equal don't");
          }
  
          if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) {
!             errln("equals() failed: objects that shouldn't compare equal do");
          }
  
          int hash1 = test1.hashCode();
          int hash2 = test2.hashCode();
          int hash3 = test3.hashCode();
  
          if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) {
!             errln("hashCode() failed: objects that should have the same hash code don't");
          }
      }
  
      /**
       * @bug 4011756 4011380
       */
      public void TestISO3Fallback() {
          Locale test = Locale.of("xx", "YY");
          boolean gotException = false;
          String result = "";
  
--- 373,61 ---
              if (expectedName.equals("")) {
                  expectedName = dataTable[DNAME_ROOT][i];
              }
  
              if (!testLang.equals(expectedLang)) {
!                 fail("Display language mismatch: " + testLang + " versus " + expectedLang);
              }
              if (!testCtry.equals(expectedCtry)) {
!                 fail("Display country mismatch: " + testCtry + " versus " + expectedCtry);
              }
              if (!testVar.equals(expectedVar)) {
!                 fail("Display variant mismatch: " + testVar + " versus " + expectedVar);
              }
              if (!testName.equals(expectedName)) {
!                 fail("Display name mismatch: " + testName + " versus " + expectedName);
              }
          }
      }
  
      @SuppressWarnings("deprecation")
+     @Test
      public void TestSimpleObjectStuff() {
          Locale test1 = new Locale("aa", "AA");
          Locale test2 = new Locale("aa", "AA");
          Locale test3 = (Locale) test1.clone();
          Locale test4 = Locale.of("zz", "ZZ");
  
          if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) {
!             fail("Some of the test variables point to the same locale!");
          }
  
          if (test3 == null) {
!             fail("clone() failed to produce a valid object!");
          }
  
          if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) {
!             fail("clone() or equals() failed: objects that should compare equal don't");
          }
  
          if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) {
!             fail("equals() failed: objects that shouldn't compare equal do");
          }
  
          int hash1 = test1.hashCode();
          int hash2 = test2.hashCode();
          int hash3 = test3.hashCode();
  
          if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) {
!             fail("hashCode() failed: objects that should have the same hash code don't");
          }
      }
  
      /**
       * @bug 4011756 4011380
       */
+     @Test
      public void TestISO3Fallback() {
          Locale test = Locale.of("xx", "YY");
          boolean gotException = false;
          String result = "";
  

*** 431,27 ***
              result = test.getISO3Language();
          } catch (MissingResourceException e) {
              gotException = true;
          }
          if (!gotException) {
!             errln("getISO3Language() on xx_YY returned " + result + " instead of throwing an exception");
          }
  
          gotException = false;
          try {
              result = test.getISO3Country();
          } catch (MissingResourceException e) {
              gotException = true;
          }
          if (!gotException) {
!             errln("getISO3Country() on xx_YY returned " + result + " instead of throwing an exception");
          }
      }
  
      /**
       * @bug 4106155 4118587 7066203 7085757
       */
      public void TestGetLangsAndCountries() {
          // It didn't seem right to just do an exhaustive test of everything here, so I check
          // for the following things:
          // 1) Does each list have the right total number of entries?
          // 2) Does each list contain certain language and country codes we think are important
--- 435,28 ---
              result = test.getISO3Language();
          } catch (MissingResourceException e) {
              gotException = true;
          }
          if (!gotException) {
!             fail("getISO3Language() on xx_YY returned " + result + " instead of throwing an exception");
          }
  
          gotException = false;
          try {
              result = test.getISO3Country();
          } catch (MissingResourceException e) {
              gotException = true;
          }
          if (!gotException) {
!             fail("getISO3Country() on xx_YY returned " + result + " instead of throwing an exception");
          }
      }
  
      /**
       * @bug 4106155 4118587 7066203 7085757
       */
+     @Test
      public void TestGetLangsAndCountries() {
          // It didn't seem right to just do an exhaustive test of everything here, so I check
          // for the following things:
          // 1) Does each list have the right total number of entries?
          // 2) Does each list contain certain language and country codes we think are important

*** 462,64 ***
          String[] test = Locale.getISOLanguages();
          String[] spotCheck1 = {"en", "es", "fr", "de", "it", "ja", "ko", "zh", "th",
              "he", "id", "iu", "ug", "yi", "za"};
  
          if (test.length != 188) {
!             errln("Expected getISOLanguages() to return 188 languages; it returned " + test.length);
          } else {
              for (int i = 0; i < spotCheck1.length; i++) {
                  int j;
                  for (j = 0; j < test.length; j++) {
                      if (test[j].equals(spotCheck1[i])) {
                          break;
                      }
                  }
                  if (j == test.length || !test[j].equals(spotCheck1[i])) {
!                     errln("Couldn't find " + spotCheck1[i] + " in language list.");
                  }
              }
          }
          for (int i = 0; i < test.length; i++) {
              if (!test[i].equals(test[i].toLowerCase())) {
!                 errln(test[i] + " is not all lower case.");
              }
              if (test[i].length() != 2) {
!                 errln(test[i] + " is not two characters long.");
              }
              if (i > 0 && test[i].compareTo(test[i - 1]) <= 0) {
!                 errln(test[i] + " appears in an out-of-order position in the list.");
              }
          }
  
          test = Locale.getISOCountries();
          String[] spotCheck2 = {"US", "CA", "GB", "FR", "DE", "IT", "JP", "KR", "CN", "TW", "TH"};
  
  
          if (test.length != 249) {
!             errln("Expected getISOCountries to return 249 countries; it returned " + test.length);
          } else {
              for (int i = 0; i < spotCheck2.length; i++) {
                  int j;
                  for (j = 0; j < test.length; j++) {
                      if (test[j].equals(spotCheck2[i])) {
                          break;
                      }
                  }
                  if (j == test.length || !test[j].equals(spotCheck2[i])) {
!                     errln("Couldn't find " + spotCheck2[i] + " in country list.");
                  }
              }
          }
          for (int i = 0; i < test.length; i++) {
              if (!test[i].equals(test[i].toUpperCase())) {
!                 errln(test[i] + " is not all upper case.");
              }
              if (test[i].length() != 2) {
!                 errln(test[i] + " is not two characters long.");
              }
              if (i > 0 && test[i].compareTo(test[i - 1]) <= 0) {
!                 errln(test[i] + " appears in an out-of-order position in the list.");
              }
          }
      }
  
      /**
--- 467,64 ---
          String[] test = Locale.getISOLanguages();
          String[] spotCheck1 = {"en", "es", "fr", "de", "it", "ja", "ko", "zh", "th",
              "he", "id", "iu", "ug", "yi", "za"};
  
          if (test.length != 188) {
!             fail("Expected getISOLanguages() to return 188 languages; it returned " + test.length);
          } else {
              for (int i = 0; i < spotCheck1.length; i++) {
                  int j;
                  for (j = 0; j < test.length; j++) {
                      if (test[j].equals(spotCheck1[i])) {
                          break;
                      }
                  }
                  if (j == test.length || !test[j].equals(spotCheck1[i])) {
!                     fail("Couldn't find " + spotCheck1[i] + " in language list.");
                  }
              }
          }
          for (int i = 0; i < test.length; i++) {
              if (!test[i].equals(test[i].toLowerCase())) {
!                 fail(test[i] + " is not all lower case.");
              }
              if (test[i].length() != 2) {
!                 fail(test[i] + " is not two characters long.");
              }
              if (i > 0 && test[i].compareTo(test[i - 1]) <= 0) {
!                 fail(test[i] + " appears in an out-of-order position in the list.");
              }
          }
  
          test = Locale.getISOCountries();
          String[] spotCheck2 = {"US", "CA", "GB", "FR", "DE", "IT", "JP", "KR", "CN", "TW", "TH"};
  
  
          if (test.length != 249) {
!             fail("Expected getISOCountries to return 249 countries; it returned " + test.length);
          } else {
              for (int i = 0; i < spotCheck2.length; i++) {
                  int j;
                  for (j = 0; j < test.length; j++) {
                      if (test[j].equals(spotCheck2[i])) {
                          break;
                      }
                  }
                  if (j == test.length || !test[j].equals(spotCheck2[i])) {
!                     fail("Couldn't find " + spotCheck2[i] + " in country list.");
                  }
              }
          }
          for (int i = 0; i < test.length; i++) {
              if (!test[i].equals(test[i].toUpperCase())) {
!                 fail(test[i] + " is not all upper case.");
              }
              if (test[i].length() != 2) {
!                 fail(test[i] + " is not two characters long.");
              }
              if (i > 0 && test[i].compareTo(test[i - 1]) <= 0) {
!                 fail(test[i] + " appears in an out-of-order position in the list.");
              }
          }
      }
  
      /**

*** 530,73 ***
  
          test = Locale.getISOCountries();
          test[0] = "SUCKER!!!";
          test = Locale.getISOCountries();
          if (test[0].equals("SUCKER!!!")) {
!             errln("Changed internal country code list!");
          }
  
          test = Locale.getISOLanguages();
          test[0] = "HAHAHAHA!!!";
          test = Locale.getISOLanguages();
          if (test[0].equals("HAHAHAHA!!!")) { // Fixed typo
!             errln("Changes internal language code list!");
          }
      }
  
      /**
       * @bug 4107014
       */
      public void TestGetAvailableLocales() {
          Locale[] locales = Locale.getAvailableLocales();
          if (locales == null || locales.length == 0) {
!             errln("Locale.getAvailableLocales() returned no installed locales!");
          } else {
!             logln("Locale.getAvailableLocales() returned a list of " + locales.length + " locales.");
              for (int i = 0; i < locales.length; i++) {
!                 logln(locales[i].toString());
              }
          }
      }
  
      /**
       * @bug 4135316
       */
      public void TestBug4135316() {
          Locale[] locales1 = Locale.getAvailableLocales();
          Locale[] locales2 = Locale.getAvailableLocales();
          if (locales1 == locales2) {
!             errln("Locale.getAvailableLocales() doesn't clone its internal storage!");
          }
      }
  
      /**
       * @bug 4107953
       */
  /*
  test commented out pending API-change approval
      public void TestGetLanguagesForCountry() {
          String[] languages = Locale.getLanguagesForCountry("US");
  
          if (!searchStringArrayFor("en", languages))
!             errln("Didn't get en as a language for US");
  
          languages = Locale.getLanguagesForCountry("FR");
          if (!searchStringArrayFor("fr", languages))
!             errln("Didn't get fr as a language for FR");
  
          languages = Locale.getLanguagesForCountry("CH");
          if (!searchStringArrayFor("fr", languages))
!             errln("Didn't get fr as a language for CH");
          if (!searchStringArrayFor("it", languages))
!             errln("Didn't get it as a language for CH");
          if (!searchStringArrayFor("de", languages))
!             errln("Didn't get de as a language for CH");
  
          languages = Locale.getLanguagesForCountry("JP");
          if (!searchStringArrayFor("ja", languages))
!             errln("Didn't get ja as a language for JP");
      }
  */
  
      private boolean searchStringArrayFor(String s, String[] array) {
          for (int i = 0; i < array.length; i++)
--- 535,76 ---
  
          test = Locale.getISOCountries();
          test[0] = "SUCKER!!!";
          test = Locale.getISOCountries();
          if (test[0].equals("SUCKER!!!")) {
!             fail("Changed internal country code list!");
          }
  
          test = Locale.getISOLanguages();
          test[0] = "HAHAHAHA!!!";
          test = Locale.getISOLanguages();
          if (test[0].equals("HAHAHAHA!!!")) { // Fixed typo
!             fail("Changes internal language code list!");
          }
      }
  
      /**
       * @bug 4107014
       */
+     @Test
      public void TestGetAvailableLocales() {
          Locale[] locales = Locale.getAvailableLocales();
          if (locales == null || locales.length == 0) {
!             fail("Locale.getAvailableLocales() returned no installed locales!");
          } else {
!             System.out.println("Locale.getAvailableLocales() returned a list of " + locales.length + " locales.");
              for (int i = 0; i < locales.length; i++) {
!                 System.out.println(locales[i].toString());
              }
          }
      }
  
      /**
       * @bug 4135316
       */
+     @Test
      public void TestBug4135316() {
          Locale[] locales1 = Locale.getAvailableLocales();
          Locale[] locales2 = Locale.getAvailableLocales();
          if (locales1 == locales2) {
!             fail("Locale.getAvailableLocales() doesn't clone its internal storage!");
          }
      }
  
      /**
       * @bug 4107953
       */
  /*
  test commented out pending API-change approval
+     @Test
      public void TestGetLanguagesForCountry() {
          String[] languages = Locale.getLanguagesForCountry("US");
  
          if (!searchStringArrayFor("en", languages))
!             fail("Didn't get en as a language for US");
  
          languages = Locale.getLanguagesForCountry("FR");
          if (!searchStringArrayFor("fr", languages))
!             fail("Didn't get fr as a language for FR");
  
          languages = Locale.getLanguagesForCountry("CH");
          if (!searchStringArrayFor("fr", languages))
!             fail("Didn't get fr as a language for CH");
          if (!searchStringArrayFor("it", languages))
!             fail("Didn't get it as a language for CH");
          if (!searchStringArrayFor("de", languages))
!             fail("Didn't get de as a language for CH");
  
          languages = Locale.getLanguagesForCountry("JP");
          if (!searchStringArrayFor("ja", languages))
!             fail("Didn't get ja as a language for JP");
      }
  */
  
      private boolean searchStringArrayFor(String s, String[] array) {
          for (int i = 0; i < array.length; i++)

*** 605,10 ***
--- 613,11 ---
          return false;
      }
      /**
       * @bug 4110613
       */
+     @Test
      public void TestSerialization() throws ClassNotFoundException, OptionalDataException,
              IOException, StreamCorruptedException {
          ObjectOutputStream ostream;
          ByteArrayOutputStream obstream;
          byte[] bytes = null;

*** 625,17 ***
          ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
  
          Locale test2 = (Locale) (istream.readObject());
  
          if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) {
!             errln("Locale failed to deserialize correctly.");
          }
      }
  
      /**
       * @bug 4118587
       */
      public void TestSimpleDisplayNames() {
          // This test is different from TestDisplayNames because TestDisplayNames checks
          // fallback behavior, combination of language and country names to form locale
          // names, and other stuff like that.  This test just checks specific language
          // and country codes to make sure we have the correct names for them.
--- 634,18 ---
          ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
  
          Locale test2 = (Locale) (istream.readObject());
  
          if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) {
!             fail("Locale failed to deserialize correctly.");
          }
      }
  
      /**
       * @bug 4118587
       */
+     @Test
      public void TestSimpleDisplayNames() {
          // This test is different from TestDisplayNames because TestDisplayNames checks
          // fallback behavior, combination of language and country names to form locale
          // names, and other stuff like that.  This test just checks specific language
          // and country codes to make sure we have the correct names for them.

*** 644,80 ***
              "Zhuang"};
  
          for (int i = 0; i < languageCodes.length; i++) {
              String test = (Locale.of(languageCodes[i])).getDisplayLanguage(Locale.US);
              if (!test.equals(languageNames[i])) {
!                 errln("Got wrong display name for " + languageCodes[i] + ": Expected \""
                          + languageNames[i] + "\", got \"" + test + "\".");
              }
          }
      }
  
      /**
       * @bug 4118595
       */
      public void TestUninstalledISO3Names() {
          // This test checks to make sure getISO3Language and getISO3Country work right
          // even for locales that are not installed.
          String[] iso2Languages = {"am", "ba", "fy", "mr", "rn", "ss", "tw", "zu"};
          String[] iso3Languages = {"amh", "bak", "fry", "mar", "run", "ssw", "twi", "zul"};
  
          for (int i = 0; i < iso2Languages.length; i++) {
              String test = (Locale.of(iso2Languages[i])).getISO3Language();
              if (!test.equals(iso3Languages[i])) {
!                 errln("Got wrong ISO3 code for " + iso2Languages[i] + ": Expected \""
                          + iso3Languages[i] + "\", got \"" + test + "\".");
              }
          }
  
          String[] iso2Countries = {"AF", "BW", "KZ", "MO", "MN", "SB", "TC", "ZW"};
          String[] iso3Countries = {"AFG", "BWA", "KAZ", "MAC", "MNG", "SLB", "TCA", "ZWE"};
  
          for (int i = 0; i < iso2Countries.length; i++) {
              String test = (Locale.of("", iso2Countries[i])).getISO3Country();
              if (!test.equals(iso3Countries[i])) {
!                 errln("Got wrong ISO3 code for " + iso2Countries[i] + ": Expected \""
                          + iso3Countries[i] + "\", got \"" + test + "\".");
              }
          }
      }
  
      /**
       * @bug 4052404 4778440 8263202
       */
      public void TestChangedISO639Codes() {
          Locale hebrewOld = Locale.of("iw", "IL");
          Locale hebrewNew = Locale.of("he", "IL");
          Locale yiddishOld = Locale.of("ji", "IL");
          Locale yiddishNew = Locale.of("yi", "IL");
          Locale indonesianOld = Locale.of("in");
          Locale indonesianNew = Locale.of("id");
  
          if ("true".equalsIgnoreCase(System.getProperty("java.locale.useOldISOCodes"))) {
              if (!hebrewNew.getLanguage().equals("iw")) {
!                 errln("Got back wrong language code for new Hebrew: expected \"iw\", got \""
                          + hebrewNew.getLanguage() + "\"");
              }
              if (!yiddishNew.getLanguage().equals("ji")) {
!                 errln("Got back wrong language code for new Yiddish: expected \"ji\", got \""
                          + yiddishNew.getLanguage() + "\"");
              }
              if (!indonesianNew.getLanguage().equals("in")) {
!                 errln("Got back wrong language code for new Indonesian: expected \"in\", got \""
                          + indonesianNew.getLanguage() + "\"");
              }
          } else {
              if (!hebrewOld.getLanguage().equals("he")) {
!                 errln("Got back wrong language code for old Hebrew: expected \"he\", got \""
                          + hebrewNew.getLanguage() + "\"");
              }
              if (!yiddishOld.getLanguage().equals("yi")) {
!                 errln("Got back wrong language code for old Yiddish: expected \"yi\", got \""
                          + yiddishNew.getLanguage() + "\"");
              }
              if (!indonesianOld.getLanguage().equals("id")) {
!                 errln("Got back wrong language code for old Indonesian: expected \"id\", got \""
                          + indonesianNew.getLanguage() + "\"");
              }
          }
  
      }
--- 654,82 ---
              "Zhuang"};
  
          for (int i = 0; i < languageCodes.length; i++) {
              String test = (Locale.of(languageCodes[i])).getDisplayLanguage(Locale.US);
              if (!test.equals(languageNames[i])) {
!                 fail("Got wrong display name for " + languageCodes[i] + ": Expected \""
                          + languageNames[i] + "\", got \"" + test + "\".");
              }
          }
      }
  
      /**
       * @bug 4118595
       */
+     @Test
      public void TestUninstalledISO3Names() {
          // This test checks to make sure getISO3Language and getISO3Country work right
          // even for locales that are not installed.
          String[] iso2Languages = {"am", "ba", "fy", "mr", "rn", "ss", "tw", "zu"};
          String[] iso3Languages = {"amh", "bak", "fry", "mar", "run", "ssw", "twi", "zul"};
  
          for (int i = 0; i < iso2Languages.length; i++) {
              String test = (Locale.of(iso2Languages[i])).getISO3Language();
              if (!test.equals(iso3Languages[i])) {
!                 fail("Got wrong ISO3 code for " + iso2Languages[i] + ": Expected \""
                          + iso3Languages[i] + "\", got \"" + test + "\".");
              }
          }
  
          String[] iso2Countries = {"AF", "BW", "KZ", "MO", "MN", "SB", "TC", "ZW"};
          String[] iso3Countries = {"AFG", "BWA", "KAZ", "MAC", "MNG", "SLB", "TCA", "ZWE"};
  
          for (int i = 0; i < iso2Countries.length; i++) {
              String test = (Locale.of("", iso2Countries[i])).getISO3Country();
              if (!test.equals(iso3Countries[i])) {
!                 fail("Got wrong ISO3 code for " + iso2Countries[i] + ": Expected \""
                          + iso3Countries[i] + "\", got \"" + test + "\".");
              }
          }
      }
  
      /**
       * @bug 4052404 4778440 8263202
       */
+     @Test
      public void TestChangedISO639Codes() {
          Locale hebrewOld = Locale.of("iw", "IL");
          Locale hebrewNew = Locale.of("he", "IL");
          Locale yiddishOld = Locale.of("ji", "IL");
          Locale yiddishNew = Locale.of("yi", "IL");
          Locale indonesianOld = Locale.of("in");
          Locale indonesianNew = Locale.of("id");
  
          if ("true".equalsIgnoreCase(System.getProperty("java.locale.useOldISOCodes"))) {
              if (!hebrewNew.getLanguage().equals("iw")) {
!                 fail("Got back wrong language code for new Hebrew: expected \"iw\", got \""
                          + hebrewNew.getLanguage() + "\"");
              }
              if (!yiddishNew.getLanguage().equals("ji")) {
!                 fail("Got back wrong language code for new Yiddish: expected \"ji\", got \""
                          + yiddishNew.getLanguage() + "\"");
              }
              if (!indonesianNew.getLanguage().equals("in")) {
!                 fail("Got back wrong language code for new Indonesian: expected \"in\", got \""
                          + indonesianNew.getLanguage() + "\"");
              }
          } else {
              if (!hebrewOld.getLanguage().equals("he")) {
!                 fail("Got back wrong language code for old Hebrew: expected \"he\", got \""
                          + hebrewNew.getLanguage() + "\"");
              }
              if (!yiddishOld.getLanguage().equals("yi")) {
!                 fail("Got back wrong language code for old Yiddish: expected \"yi\", got \""
                          + yiddishNew.getLanguage() + "\"");
              }
              if (!indonesianOld.getLanguage().equals("id")) {
!                 fail("Got back wrong language code for old Indonesian: expected \"id\", got \""
                          + indonesianNew.getLanguage() + "\"");
              }
          }
  
      }

*** 737,10 ***
--- 749,11 ---
       * display names if run under a ja locale. Eventually, he LocaleElements should probably
       * be updated to contain more localized language and region display names.
       * 1999-11-19 joconner
       *
       */
+     @Test
      public void TestAtypicalLocales() {
          Locale[] localesToTest = { Locale.of("de", "CA"),
                                     Locale.of("ja", "ZA"),
                                     Locale.of("ru", "MX"),
                                     Locale.of("en", "FR"),

*** 782,31 ***
          Locale defaultLocale = Locale.getDefault();
          Locale.setDefault(Locale.US);
  
          for (int i = 0; i < localesToTest.length; i++) {
              String name = localesToTest[i].getDisplayName(Locale.US);
!             logln(name);
              if (!name.equals(englishDisplayNames[i])) {
!                 errln("Lookup in English failed: expected \"" + englishDisplayNames[i]
                          + "\", got \"" + name + "\"");
              }
          }
  
          for (int i = 0; i < localesToTest.length; i++) {
              String name = localesToTest[i].getDisplayName(Locale.of("es", "ES"));
!             logln(name);
              if (!name.equals(spanishDisplayNames[i])) {
!                 errln("Lookup in Spanish failed: expected \"" + spanishDisplayNames[i]
                          + "\", got \"" + name + "\"");
              }
          }
  
          for (int i = 0; i < localesToTest.length; i++) {
              String name = localesToTest[i].getDisplayName(Locale.FRANCE);
!             logln(name);
              if (!name.equals(frenchDisplayNames[i])) {
!                 errln("Lookup in French failed: expected \"" + frenchDisplayNames[i]
                          + "\", got \"" + name + "\"");
              }
          }
  
          // restore the default locale for other tests
--- 795,31 ---
          Locale defaultLocale = Locale.getDefault();
          Locale.setDefault(Locale.US);
  
          for (int i = 0; i < localesToTest.length; i++) {
              String name = localesToTest[i].getDisplayName(Locale.US);
!             System.out.println(name);
              if (!name.equals(englishDisplayNames[i])) {
!                 fail("Lookup in English failed: expected \"" + englishDisplayNames[i]
                          + "\", got \"" + name + "\"");
              }
          }
  
          for (int i = 0; i < localesToTest.length; i++) {
              String name = localesToTest[i].getDisplayName(Locale.of("es", "ES"));
!             System.out.println(name);
              if (!name.equals(spanishDisplayNames[i])) {
!                 fail("Lookup in Spanish failed: expected \"" + spanishDisplayNames[i]
                          + "\", got \"" + name + "\"");
              }
          }
  
          for (int i = 0; i < localesToTest.length; i++) {
              String name = localesToTest[i].getDisplayName(Locale.FRANCE);
!             System.out.println(name);
              if (!name.equals(frenchDisplayNames[i])) {
!                 fail("Lookup in French failed: expected \"" + frenchDisplayNames[i]
                          + "\", got \"" + name + "\"");
              }
          }
  
          // restore the default locale for other tests

*** 814,10 ***
--- 827,11 ---
      }
  
      /**
       * @bug 4126371
       */
+     @Test
      public void TestNullDefault() {
          // why on earth anyone would ever try to do this is beyond me, but we should
          // definitely make sure we don't let them
          boolean gotException = false;
          try {

*** 825,31 ***
          } catch (NullPointerException e) {
              // all other exception types propagate through here back to the test harness
              gotException = true;
          }
          if (Locale.getDefault() == null) {
!             errln("Locale.getDefault() allowed us to set default to NULL!");
          }
          if (!gotException) {
!             errln("Trying to set default locale to NULL didn't throw exception!");
          }
      }
  
      /**
       * @bug 4135752
       * This would be better tested by the LocaleDataTest.  Will move it when I
       * get the LocaleDataTest working again.
       */
      public void TestThaiCurrencyFormat() {
          DecimalFormat thaiCurrency = (DecimalFormat) NumberFormat.getCurrencyInstance(
                  Locale.of("th", "TH"));
          if (!thaiCurrency.getPositivePrefix().equals("\u0e3f")) {
!             errln("Thai currency prefix wrong: expected \"\u0e3f\", got \""
                      + thaiCurrency.getPositivePrefix() + "\"");
          }
          if (!thaiCurrency.getPositiveSuffix().equals("")) {
!             errln("Thai currency suffix wrong: expected \"\", got \""
                      + thaiCurrency.getPositiveSuffix() + "\"");
          }
      }
  
      /**
--- 839,32 ---
          } catch (NullPointerException e) {
              // all other exception types propagate through here back to the test harness
              gotException = true;
          }
          if (Locale.getDefault() == null) {
!             fail("Locale.getDefault() allowed us to set default to NULL!");
          }
          if (!gotException) {
!             fail("Trying to set default locale to NULL didn't throw exception!");
          }
      }
  
      /**
       * @bug 4135752
       * This would be better tested by the LocaleDataTest.  Will move it when I
       * get the LocaleDataTest working again.
       */
+     @Test
      public void TestThaiCurrencyFormat() {
          DecimalFormat thaiCurrency = (DecimalFormat) NumberFormat.getCurrencyInstance(
                  Locale.of("th", "TH"));
          if (!thaiCurrency.getPositivePrefix().equals("\u0e3f")) {
!             fail("Thai currency prefix wrong: expected \"\u0e3f\", got \""
                      + thaiCurrency.getPositivePrefix() + "\"");
          }
          if (!thaiCurrency.getPositiveSuffix().equals("")) {
!             fail("Thai currency suffix wrong: expected \"\", got \""
                      + thaiCurrency.getPositiveSuffix() + "\"");
          }
      }
  
      /**

*** 863,10 ***
--- 878,11 ---
       * test must be updated.
       *
       * DON'T ASSUME: Any specific countries support the Euro.  Instead,
       * iterate through all locales.
       */
+     @Test
      public void TestEuroSupport() {
          final String EURO_VARIANT = "EURO";
          final String EURO_CURRENCY = "\u20AC"; // Look for this string in formatted Euro currency
  
          Locale[] locales = NumberFormat.getAvailableLocales();

*** 876,14 ***
                  NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
                  String pos = nf.format(271828.182845);
                  String neg = nf.format(-271828.182845);
                  if (pos.indexOf(EURO_CURRENCY) >= 0
                          && neg.indexOf(EURO_CURRENCY) >= 0) {
!                     logln("Ok: " + loc.toString()
                              + ": " + pos + " / " + neg);
                  } else {
!                     errln("Fail: " + loc.toString()
                              + " formats without " + EURO_CURRENCY
                              + ": " + pos + " / " + neg
                              + "\n*** THIS FAILURE MAY ONLY MEAN THAT LOCALE DATA HAS CHANGED ***");
                  }
              }
--- 892,14 ---
                  NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
                  String pos = nf.format(271828.182845);
                  String neg = nf.format(-271828.182845);
                  if (pos.indexOf(EURO_CURRENCY) >= 0
                          && neg.indexOf(EURO_CURRENCY) >= 0) {
!                     System.out.println("Ok: " + loc.toString()
                              + ": " + pos + " / " + neg);
                  } else {
!                     fail("Fail: " + loc.toString()
                              + " formats without " + EURO_CURRENCY
                              + ": " + pos + " / " + neg
                              + "\n*** THIS FAILURE MAY ONLY MEAN THAT LOCALE DATA HAS CHANGED ***");
                  }
              }

*** 892,10 ***
--- 908,11 ---
  
      /**
       * @bug 4139504
       * toString() doesn't work with language_VARIANT.
       */
+     @Test
      public void TestToString() {
          Object[] DATA = {
              Locale.of("xx", "", ""), "xx",
              Locale.of("", "YY", ""), "_YY",
              Locale.of("", "", "ZZ"), "",

*** 906,28 ***
          };
          for (int i = 0; i < DATA.length; i += 2) {
              Locale loc = (Locale) DATA[i];
              String fmt = (String) DATA[i + 1];
              if (!loc.toString().equals(fmt)) {
!                 errln("Fail: Locale.toString(" + fmt + ")=>" + loc);
              }
          }
      }
  
      /**
       * @bug 4105828
       * Currency symbol in zh is wrong.  We will test this at the NumberFormat
       * end to test the whole pipe.
       */
      public void Test4105828() {
          Locale[] LOC = {Locale.CHINESE, Locale.of("zh", "CN"),
              Locale.of("zh", "TW"), Locale.of("zh", "HK")};
          for (int i = 0; i < LOC.length; ++i) {
              NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
              String result = fmt.format(1);
              if (!result.equals("100%")) {
!                 errln("Percent for " + LOC[i] + " should be 100%, got " + result);
              }
          }
      }
  
      /**
--- 923,29 ---
          };
          for (int i = 0; i < DATA.length; i += 2) {
              Locale loc = (Locale) DATA[i];
              String fmt = (String) DATA[i + 1];
              if (!loc.toString().equals(fmt)) {
!                 fail("Fail: Locale.toString(" + fmt + ")=>" + loc);
              }
          }
      }
  
      /**
       * @bug 4105828
       * Currency symbol in zh is wrong.  We will test this at the NumberFormat
       * end to test the whole pipe.
       */
+     @Test
      public void Test4105828() {
          Locale[] LOC = {Locale.CHINESE, Locale.of("zh", "CN"),
              Locale.of("zh", "TW"), Locale.of("zh", "HK")};
          for (int i = 0; i < LOC.length; ++i) {
              NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
              String result = fmt.format(1);
              if (!result.equals("100%")) {
!                 fail("Percent for " + LOC[i] + " should be 100%, got " + result);
              }
          }
      }
  
      /**

*** 944,48 ***
       * right character in it, so I wanted to check the rest of the pipeline -- a
       * very remote possibility, but I wanted to be sure.  The other possibility
       * is that something is wrong with the font mapping subsystem, but we can't
       * test that here.
       */
      public void Test4139940() {
          Locale mylocale = Locale.of("hu");
          @SuppressWarnings("deprecation")
          Date mydate = new Date(98, 3, 13); // A Monday
          DateFormat df_full = new SimpleDateFormat("EEEE", mylocale);
          String str = df_full.format(mydate);
          // Make sure that o circumflex (\u00F4) is NOT there, and
          // o double acute (\u0151) IS.
          if (str.indexOf('\u0151') < 0 || str.indexOf('\u00F4') >= 0) {
!             errln("Fail: Monday in Hungarian is wrong");
          }
      }
  
      /**
       * @bug 4143951
       * Russian first day of week should be Monday. Confirmed.
       */
      public void Test4143951() {
          Calendar cal = Calendar.getInstance(Locale.of("ru"));
          if (cal.getFirstDayOfWeek() != Calendar.MONDAY) {
!             errln("Fail: First day of week in Russia should be Monday");
          }
      }
  
      /**
       * @bug 4147315
       * java.util.Locale.getISO3Country() works wrong for non ISO-3166 codes.
       * Should throw an exception for unknown locales
       */
      public void Test4147315() {
          // Try with codes that are the wrong length but happen to match text
          // at a valid offset in the mapping table
          Locale locale = Locale.of("aaa", "CCC");
  
          try {
              String result = locale.getISO3Country();
  
!             errln("ERROR: getISO3Country() returns: " + result
                      + " for locale '" + locale + "' rather than exception");
          } catch (MissingResourceException e) {
          }
      }
  
--- 962,51 ---
       * right character in it, so I wanted to check the rest of the pipeline -- a
       * very remote possibility, but I wanted to be sure.  The other possibility
       * is that something is wrong with the font mapping subsystem, but we can't
       * test that here.
       */
+     @Test
      public void Test4139940() {
          Locale mylocale = Locale.of("hu");
          @SuppressWarnings("deprecation")
          Date mydate = new Date(98, 3, 13); // A Monday
          DateFormat df_full = new SimpleDateFormat("EEEE", mylocale);
          String str = df_full.format(mydate);
          // Make sure that o circumflex (\u00F4) is NOT there, and
          // o double acute (\u0151) IS.
          if (str.indexOf('\u0151') < 0 || str.indexOf('\u00F4') >= 0) {
!             fail("Fail: Monday in Hungarian is wrong");
          }
      }
  
      /**
       * @bug 4143951
       * Russian first day of week should be Monday. Confirmed.
       */
+     @Test
      public void Test4143951() {
          Calendar cal = Calendar.getInstance(Locale.of("ru"));
          if (cal.getFirstDayOfWeek() != Calendar.MONDAY) {
!             fail("Fail: First day of week in Russia should be Monday");
          }
      }
  
      /**
       * @bug 4147315
       * java.util.Locale.getISO3Country() works wrong for non ISO-3166 codes.
       * Should throw an exception for unknown locales
       */
+     @Test
      public void Test4147315() {
          // Try with codes that are the wrong length but happen to match text
          // at a valid offset in the mapping table
          Locale locale = Locale.of("aaa", "CCC");
  
          try {
              String result = locale.getISO3Country();
  
!             fail("ERROR: getISO3Country() returns: " + result
                      + " for locale '" + locale + "' rather than exception");
          } catch (MissingResourceException e) {
          }
      }
  

*** 993,37 ***
       * @bug 4147317 4940539
       * java.util.Locale.getISO3Language() works wrong for non ISO-639 codes.
       * Should throw an exception for unknown locales, except they have three
       * letter language codes.
       */
      public void Test4147317() {
          // Try a three letter language code, and check whether it is
          // returned as is.
          Locale locale = Locale.of("aaa", "CCC");
  
          String result = locale.getISO3Language();
          if (!result.equals("aaa")) {
!             errln("ERROR: getISO3Language() returns: " + result
                      + " for locale '" + locale + "' rather than returning it as is");
          }
  
          // Try an invalid two letter language code, and check whether it
          // throws a MissingResourceException.
          locale = Locale.of("zz", "CCC");
  
          try {
              result = locale.getISO3Language();
  
!             errln("ERROR: getISO3Language() returns: " + result
                      + " for locale '" + locale + "' rather than exception");
          } catch (MissingResourceException e) {
          }
      }
  
      /*
       * @bug 4147552 4778440 8030696
       */
      public void Test4147552() {
          Locale[] locales = {Locale.of("no", "NO"), Locale.of("no", "NO", "B"),
              Locale.of("no", "NO", "NY"), Locale.of("nb", "NO"),
              Locale.of("nn", "NO")};
          String[] englishDisplayNames = {"Norwegian (Norway)",
--- 1014,39 ---
       * @bug 4147317 4940539
       * java.util.Locale.getISO3Language() works wrong for non ISO-639 codes.
       * Should throw an exception for unknown locales, except they have three
       * letter language codes.
       */
+     @Test
      public void Test4147317() {
          // Try a three letter language code, and check whether it is
          // returned as is.
          Locale locale = Locale.of("aaa", "CCC");
  
          String result = locale.getISO3Language();
          if (!result.equals("aaa")) {
!             fail("ERROR: getISO3Language() returns: " + result
                      + " for locale '" + locale + "' rather than returning it as is");
          }
  
          // Try an invalid two letter language code, and check whether it
          // throws a MissingResourceException.
          locale = Locale.of("zz", "CCC");
  
          try {
              result = locale.getISO3Language();
  
!             fail("ERROR: getISO3Language() returns: " + result
                      + " for locale '" + locale + "' rather than exception");
          } catch (MissingResourceException e) {
          }
      }
  
      /*
       * @bug 4147552 4778440 8030696
       */
+     @Test
      public void Test4147552() {
          Locale[] locales = {Locale.of("no", "NO"), Locale.of("no", "NO", "B"),
              Locale.of("no", "NO", "NY"), Locale.of("nb", "NO"),
              Locale.of("nn", "NO")};
          String[] englishDisplayNames = {"Norwegian (Norway)",

*** 1036,29 ***
              "norsk bokm\u00e5l (Norge)", "norsk nynorsk (Noreg)"};
  
          for (int i = 0; i < locales.length; i++) {
              Locale loc = locales[i];
              if (!loc.getDisplayName(Locale.US).equals(englishDisplayNames[i])) {
!                 errln("English display-name mismatch: expected "
                          + englishDisplayNames[i] + ", got " + loc.getDisplayName());
              }
              if (!loc.getDisplayName(loc).equals(norwegianDisplayNames[i])) {
!                 errln("Norwegian display-name mismatch: expected "
                          + norwegianDisplayNames[i] + ", got "
                          + loc.getDisplayName(loc));
              }
          }
      }
  
      /*
       * @bug 8030696
       */
      public void Test8030696() {
          List<Locale> av = Arrays.asList(Locale.getAvailableLocales());
          if (!av.contains(Locale.of("nb", "NO"))
                  || !av.contains(Locale.of("nn", "NO"))) {
!             errln("\"nb-NO\" and/or \"nn-NO\" locale(s) not returned from getAvailableLocales().");
          }
      }
  
      static String escapeUnicode(String s) {
          StringBuffer buf = new StringBuffer();
--- 1059,30 ---
              "norsk bokm\u00e5l (Norge)", "norsk nynorsk (Noreg)"};
  
          for (int i = 0; i < locales.length; i++) {
              Locale loc = locales[i];
              if (!loc.getDisplayName(Locale.US).equals(englishDisplayNames[i])) {
!                 fail("English display-name mismatch: expected "
                          + englishDisplayNames[i] + ", got " + loc.getDisplayName());
              }
              if (!loc.getDisplayName(loc).equals(norwegianDisplayNames[i])) {
!                 fail("Norwegian display-name mismatch: expected "
                          + norwegianDisplayNames[i] + ", got "
                          + loc.getDisplayName(loc));
              }
          }
      }
  
      /*
       * @bug 8030696
       */
+     @Test
      public void Test8030696() {
          List<Locale> av = Arrays.asList(Locale.getAvailableLocales());
          if (!av.contains(Locale.of("nb", "NO"))
                  || !av.contains(Locale.of("nn", "NO"))) {
!             fail("\"nb-NO\" and/or \"nn-NO\" locale(s) not returned from getAvailableLocales().");
          }
      }
  
      static String escapeUnicode(String s) {
          StringBuffer buf = new StringBuffer();
< prev index next >