Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/util/Locale/Bug4152725.java
41149 views
1
/*
2
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
/*
24
* @test
25
* @bug 4152725
26
* @summary Verify that the default locale can be specified from the
27
* command line.
28
* @run main/othervm -Duser.language=de -Duser.country=DE -Duser.variant=EURO
29
* Bug4152725 de_DE_EURO
30
* @run main/othervm -Duser.language=ja -Duser.country= -Duser.variant=
31
* Bug4152725 ja
32
* @run main/othervm -Duser.language=en -Duser.country=SG -Duser.variant=
33
* Bug4152725 en_SG
34
* @run main/othervm -Duser.language= -Duser.country=DE -Duser.variant=EURO
35
* Bug4152725 _DE_EURO
36
* @run main/othervm -Duser.language=ja -Duser.country= -Duser.variant=YOMI
37
* Bug4152725 ja__YOMI
38
* @run main/othervm -Duser.language= -Duser.country= -Duser.variant=EURO
39
* Bug4152725 __EURO
40
* @run main/othervm -Duser.language=de -Duser.region=DE_EURO
41
* Bug4152725 de_DE_EURO
42
*/
43
44
import java.util.Locale;
45
46
public class Bug4152725 {
47
48
public static void main(String[] args) {
49
50
if (args.length != 1) {
51
throw new RuntimeException("expected locale needs to be specified");
52
}
53
54
Locale locale = Locale.getDefault();
55
56
// don't use Locale.toString - it's bogus
57
String language = locale.getLanguage();
58
String country = locale.getCountry();
59
String variant = locale.getVariant();
60
String localeID = null;
61
if (variant.length() > 0) {
62
localeID = language + "_" + country + "_" + variant;
63
} else if (country.length() > 0) {
64
localeID = language + "_" + country;
65
} else {
66
localeID = language;
67
}
68
69
if (localeID.equals(args[0])) {
70
System.out.println("Correctly set from command line: " + localeID);
71
} else {
72
throw new RuntimeException("expected default locale: " + args[0]
73
+ ", actual default locale: " + localeID);
74
}
75
}
76
}
77
78