]> granicus.if.org Git - icu/commitdiff
ICU-22279 Fix invalid new Locale in testing
authorMihai Nita <mnita@google.com>
Thu, 9 Mar 2023 19:25:03 +0000 (11:25 -0800)
committerMihai Nita <nmihai_2000@yahoo.com>
Fri, 10 Mar 2023 06:19:44 +0000 (22:19 -0800)
icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationAPITest.java
icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMiscTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/CompactDecimalFormatTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/TimeUnitTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/FormatHandler.java

index 6e9b126d5844815af25752d31116baef144ea82e..662a353df53b21efa9c6bb13d52039ca73810288 100644 (file)
@@ -1582,7 +1582,7 @@ public class CollationAPITest extends TestFmwk {
          */
         try {
             TestCreateCollator tcc = new TestCreateCollator();
-            tcc.createCollator(new Locale("en_US"));
+            tcc.createCollator(new Locale("en", "US"));
         } catch (Exception e) {
             errln("Collator.createCollator(Locale) was not suppose to " + "return an exception.");
         }
@@ -1602,7 +1602,7 @@ public class CollationAPITest extends TestFmwk {
          */
         try {
             TestCreateCollator tcc = new TestCreateCollator();
-            tcc.getDisplayName(new Locale("en_US"), new Locale("jp_JP"));
+            tcc.getDisplayName(new Locale("en", "US"), new Locale("jp", "JP"));
         } catch (Exception e) {
             errln("Collator.getDisplayName(Locale,Locale) was not suppose to return an exception.");
         }
index 904a7d8be24d851e71efe3a82d5047d633470892..be857bfb6572739e41738d0e143304901d38369b 100644 (file)
@@ -1263,7 +1263,7 @@ public class CollationMiscTest extends TestFmwk {
 
         // no such locale in icu4j
         // logln("Using ko__LOTUS locale\n");
-        // genericLocaleStarter(new Locale("ko__LOTUS", ""), koreanData);
+        // genericLocaleStarter(new Locale("ko", "", "LOTUS"), koreanData);
     }
 
     @Test
index 1f98d383c3ab97f299ae9aaba6050cb49a196afc..c37a24276dee62b5b3f3984d000f0601b0745aff 100644 (file)
@@ -285,7 +285,7 @@ public class JapaneseTest extends CalendarTestFmwk {
         SimpleDateFormat fmt = (SimpleDateFormat)c.getDateTimeFormat(1,1,new ULocale("en_US@calendar=japanese"));
         fmt.applyPattern("G y");
         logln("fmt's locale = " + fmt.getLocale(ULocale.ACTUAL_LOCALE));
-        //SimpleDateFormat fmt = new SimpleDateFormat("G y", new Locale("en_US@calendar=japanese"));
+        //SimpleDateFormat fmt = new SimpleDateFormat("G y", new ULocale("en_US@calendar=japanese"));
         long aDateLong = -3197117222000L; // 1868-09-08 00:00 Pacific Time (GMT-07:52:58)
         if (TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK) {
             // Java time zone implementation does not support LMTs
index a0c344dfaba2a815dffcaf5ee9670bb1d7970755..f30d33504a9089536e5c0f402d0f71c617c17d2c 100644 (file)
@@ -399,7 +399,7 @@ public class CompactDecimalFormatTest extends TestFmwk {
     @Test
     public void TestArabicLongStyle() {
         NumberFormat cdf =
-                CompactDecimalFormat.getInstance(new Locale("ar-EG"), CompactStyle.LONG);
+                CompactDecimalFormat.getInstance(new Locale("ar", "EG"), CompactStyle.LONG);
         assertEquals("Arabic Long", "\u061C-\u0665\u066B\u0663 \u0623\u0644\u0641", cdf.format(-5300));
     }
 
index ade03a88eacd9127131a3f372dc77b87ff5d743b..6e760b998caaa569cb9179510c02d02ef80aa820 100644 (file)
@@ -1273,7 +1273,7 @@ public class DateFormatRegressionTest extends TestFmwk {
     @Test
     public void TestT10110() {
         try {
-            SimpleDateFormat formatter = new SimpleDateFormat("Gy年M月d日E", new Locale("zh_Hans"));
+            SimpleDateFormat formatter = new SimpleDateFormat("Gy年M月d日E", Locale.forLanguageTag("zh-Hans"));
             /* Object parsed = */ formatter.parseObject("610000");
         }
         catch(ParseException pe) {
index da0f83a882e2dfdaf664244a8cbb2bc55a92be45..c7f1daaf8c9ade5e97aa4b2bbcf2d88e08902c3b 100644 (file)
@@ -2465,13 +2465,13 @@ public class DateFormatTest extends TestFmwk {
         sym.equals(null);
 
         sym = new ChineseDateFormatSymbols();
-        sym = new ChineseDateFormatSymbols(new Locale("en_US"));
+        sym = new ChineseDateFormatSymbols(new Locale("en", "US"));
         try{
-            sym = new ChineseDateFormatSymbols(null, new Locale("en_US"));
+            sym = new ChineseDateFormatSymbols(null, new Locale("en", "US"));
             errln("ChineseDateFormatSymbols(Calender, Locale) was suppose to return a null " +
                     "pointer exception for a null paramater.");
         } catch(Exception e){}
-        sym = new ChineseDateFormatSymbols(new ChineseCalendar(), new Locale("en_US"));
+        sym = new ChineseDateFormatSymbols(new ChineseCalendar(), new Locale("en", "US"));
         try{
             sym = new ChineseDateFormatSymbols(null, new ULocale("en_US"));
             errln("ChineseDateFormatSymbols(Calender, ULocale) was suppose to return a null " +
@@ -4011,8 +4011,8 @@ public class DateFormatTest extends TestFmwk {
         try{
             @SuppressWarnings("unused")
             DateFormat df = DateFormat.getPatternInstance("");
-            df = DateFormat.getPatternInstance("", new Locale("en_US"));
-            df = DateFormat.getPatternInstance(null, "", new Locale("en_US"));
+            df = DateFormat.getPatternInstance("", new Locale("en", "US"));
+            df = DateFormat.getPatternInstance(null, "", new Locale("en", "US"));
         } catch(Exception e) {
             errln("DateFormat.getPatternInstance is not suppose to return an exception, got: " + e.toString());
             //e.printStackTrace();
index b2218efd18924e4b2ae7e6948cec56cf210b3e39..0cda121a4226d83f0069d3aa85d611267136ba31 100644 (file)
@@ -2241,13 +2241,13 @@ public class DateIntervalFormatTest extends TestFmwk {
     public void testTicket20707() {
         TimeZone tz = TimeZone.getTimeZone("UTC");
         Locale locales[] = {
-            new Locale("en-u-hc-h24"),
-            new Locale("en-u-hc-h23"),
-            new Locale("en-u-hc-h12"),
-            new Locale("en-u-hc-h11"),
-            new Locale("en"),
-            new Locale("en-u-hc-h25"),
-            new Locale("hi-IN-u-hc-h11")
+            Locale.forLanguageTag("en-u-hc-h24"),
+            Locale.forLanguageTag("en-u-hc-h23"),
+            Locale.forLanguageTag("en-u-hc-h12"),
+            Locale.forLanguageTag("en-u-hc-h11"),
+            Locale.forLanguageTag("en"),
+            Locale.forLanguageTag("en-u-hc-h25"),
+            Locale.forLanguageTag("hi-IN-u-hc-h11")
         };
 
         // Clomuns: hh, HH, kk, KK, jj, JJs, CC
index c65be9fbbe21361026df302022dd9948115c072a..a55c57a438d3159e69f948276d129d14ca48810f 100644 (file)
@@ -115,7 +115,7 @@ public class TimeUnitTest extends TestFmwk {
         format.setLocale(es);
         formatParsing(format);
 
-        format.setLocale(new Locale("pt_BR"));
+        format.setLocale(new Locale("pt", "BR"));
         formatParsing(format);
         format = new TimeUnitFormat(new Locale("de"));
         formatParsing(format);
@@ -343,7 +343,7 @@ public class TimeUnitTest extends TestFmwk {
         }
         for (int i = 0; i < cases.length; i++) {
             try {
-                TimeUnitFormat tuf = new TimeUnitFormat(new Locale("en_US"), cases[i]);
+                TimeUnitFormat tuf = new TimeUnitFormat(new Locale("en", "US"), cases[i]);
                 errln("TimeUnitFormat(ULocale,int) was suppose to return an " + "exception for a style value of "
                         + cases[i] + "passed into the constructor.");
             } catch (Exception e) {
@@ -358,7 +358,7 @@ public class TimeUnitTest extends TestFmwk {
     public void TestSetLocale() {
         // Tests when "if ( locale != this.locale )" is false
         TimeUnitFormat tuf = new TimeUnitFormat(new ULocale("en_US"));
-        if (!tuf.setLocale(new ULocale("en_US")).equals(tuf) && !tuf.setLocale(new Locale("en_US")).equals(tuf)) {
+        if (!tuf.setLocale(new ULocale("en_US")).equals(tuf) && !tuf.setLocale(new Locale("en", "US")).equals(tuf)) {
             errln("TimeUnitFormat.setLocale(ULocale) was suppose to "
                     + "return the same TimeUnitFormat object if the same " + "ULocale is entered as a parameter.");
         }
index 72df5c9467905c7a19f4bdc661d14a8f8e004542..47b0980f7a4531d8f7721919ccf106952396c8cc 100644 (file)
@@ -1743,7 +1743,7 @@ public class FormatHandler
         {
             CurrencyPluralInfo currencyPluralInfo[] = {
                 new CurrencyPluralInfo(), new CurrencyPluralInfo(new ULocale("en_US")),
-                CurrencyPluralInfo.getInstance(), CurrencyPluralInfo.getInstance(new Locale("en_US")),
+                CurrencyPluralInfo.getInstance(), CurrencyPluralInfo.getInstance(new Locale("en", "US")),
                 CurrencyPluralInfo.getInstance(new ULocale("en_US"))
             };
             for(int i=0; i<currencyPluralInfo.length; i++){