author | prr |
Tue, 01 Jul 2014 10:20:56 -0700 | |
changeset 25211 | 2476da7d73bf |
parent 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
11364
diff
changeset
|
2 |
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
24 |
import java.io.BufferedReader; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
25 |
import java.io.BufferedWriter; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
26 |
import java.io.File; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
27 |
import java.io.IOException; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
28 |
import java.nio.charset.Charset; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
29 |
|
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
30 |
import static java.nio.file.Files.*; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
31 |
import static java.nio.file.StandardOpenOption.*; |
2 | 32 |
|
33 |
public class DefaultLocaleTest { |
|
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
34 |
|
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
35 |
static final String setting = |
2 | 36 |
"language:" + System.getProperty("user.language") + "_" + |
37 |
"country:" + System.getProperty("user.country") + "_" + |
|
38 |
"encoding:" + System.getProperty("file.encoding") + "_" + |
|
39 |
"jnuEncoding:"+ System.getProperty("sun.jnu.encoding"); |
|
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
40 |
|
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
41 |
public static void main(String[] args) throws IOException { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
42 |
if (args != null && args.length > 1) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
43 |
File f = new File(args[1]); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
44 |
switch (args[0]) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
45 |
case "-r": |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
46 |
System.out.println("reading file: " + args[1]); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
47 |
String str = null; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
48 |
try (BufferedReader in = newBufferedReader(f.toPath(), |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
49 |
Charset.defaultCharset())) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
50 |
str = in.readLine().trim(); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
51 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
52 |
if (setting.equals(str)) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
53 |
System.out.println("Compared ok"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
54 |
} else { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
55 |
System.out.println("Compare fails"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
56 |
System.out.println("EXPECTED: " + setting); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
57 |
System.out.println("OBTAINED: " + str); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
58 |
throw new RuntimeException("Test fails: compare failed"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
59 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
60 |
break; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
61 |
case "-w": |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
62 |
System.out.println("writing file: " + args[1]); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
63 |
try (BufferedWriter out = newBufferedWriter(f.toPath(), |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
64 |
Charset.defaultCharset(), CREATE_NEW)) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
65 |
out.write(setting); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
66 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
67 |
break; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
68 |
default: |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
69 |
throw new RuntimeException("ERROR: invalid arguments"); |
2 | 70 |
} |
71 |
} else { |
|
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
72 |
throw new RuntimeException("ERROR: invalid arguments"); |
2 | 73 |
} |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
5506
diff
changeset
|
74 |
} |
2 | 75 |
} |