< prev index next >

test/jdk/java/util/Scanner/ScanTest.java

Print this page
rev 54179 : 8172695: (scanner) java/util/Scanner/ScanTest.java fails

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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.

@@ -22,11 +22,11 @@
  */
 
 /**
  * @test
  * @bug 4313885 4926319 4927634 5032610 5032622 5049968 5059533 6223711 6277261 6269946 6288823
- *      8072722 8139414 8166261
+ *      8072722 8139414 8166261 8172695
  * @summary Basic tests of java.util.Scanner methods
  * @key randomness
  * @modules jdk.localedata
  * @run main/othervm ScanTest
  */

@@ -47,30 +47,16 @@
     private static int failCount = 0;
     private static int NUM_SOURCE_TYPES = 2;
     private static File inputFile = new File(System.getProperty("test.src", "."), "input.txt");
 
     public static void main(String[] args) throws Exception {
-
-        Locale reservedLocale = Locale.getDefault();
-        String lang = reservedLocale.getLanguage();
+        Locale defaultLocale = Locale.getDefault();
         try {
-            if (!"en".equals(lang) &&
-                !"zh".equals(lang) &&
-                !"ko".equals(lang) &&
-                !"ja".equals(lang)) {
-                //Before we have resource to improve the test to be ready for
-                //arbitrary locale, force the default locale to be "English"
-                //for now. First we check whether the "English" locale is
-                //available on the system as it could be absent due to varying
-                //configurations.
-                if (!Arrays.asList(Locale.getAvailableLocales())
-                    .contains(Locale.ENGLISH)) {
-                    throw new RuntimeException
-                       ("The \"English\" Locale is unavailable on this system");
-                }
-                Locale.setDefault(Locale.ENGLISH);
-            }
+            // Before we have resource to improve the test to be ready for
+            // arbitrary locale, force the default locale to be ROOT for now.
+            Locale.setDefault(Locale.ROOT);
+
             skipTest();
             findInLineTest();
             findWithinHorizonTest();
             findInEmptyLineTest();
             removeTest();

@@ -126,11 +112,11 @@
                 throw new RuntimeException("Failure in the scanning tests.");
             else
                 System.err.println("OKAY: All tests passed.");
         } finally {
             // restore the default locale
-            Locale.setDefault(reservedLocale);
+            Locale.setDefault(defaultLocale);
         }
     }
 
     public static void useCase1() throws Exception {
         try (Scanner sc = new Scanner(inputFile)) {
< prev index next >