8172695: (scanner) java/util/Scanner/ScanTest.java fails

Reviewed-by: smarks, bpb
This commit is contained in:
Christoph Langer 2019-03-21 09:16:58 +01:00
parent 762ce676b3
commit 26358daaee

View File

@ -1,5 +1,5 @@
/*
* 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
@ -24,7 +24,7 @@
/**
* @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
@ -49,26 +49,12 @@ public class ScanTest {
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.US);
skipTest();
findInLineTest();
findWithinHorizonTest();
@ -128,7 +114,7 @@ public class ScanTest {
System.err.println("OKAY: All tests passed.");
} finally {
// restore the default locale
Locale.setDefault(reservedLocale);
Locale.setDefault(defaultLocale);
}
}