author | ksrini |
Fri, 30 Mar 2012 17:22:02 -0700 | |
changeset 12303 | 498f8b38423b |
parent 11687 | f13cadbb0bb5 |
child 37540 | e92d95400f31 |
permissions | -rw-r--r-- |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
1 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
4 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
8 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
14 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
18 |
* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
21 |
* questions. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
22 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
23 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
24 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
25 |
* @test |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
26 |
* @bug 4761384 |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
27 |
* @compile -XDignore.symbol.file I18NTest.java |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
28 |
* @run main I18NTest |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
29 |
* @summary Test to see if class files with non-ASCII characters can be run |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
30 |
* @author Joseph D. Darcy, Kumar Srinivasan |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
31 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
32 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
33 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
34 |
import java.util.ArrayList; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
35 |
import java.io.File; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
36 |
import java.util.List; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
37 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
38 |
public class I18NTest extends TestHelper { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
39 |
static String fileName = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
40 |
public static void main(String... args) throws Exception { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
41 |
String defaultEncoding = System.getProperty("file.encoding"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
42 |
if (defaultEncoding == null) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
43 |
System.err.println("Default encoding not found; Error."); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
44 |
return; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
45 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
46 |
if (!defaultEncoding.equals("Cp1252")) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
47 |
System.err.println("Warning: required encoding not found, test skipped."); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
48 |
return; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
49 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
50 |
// for some reason the shell test version insisted on cleaning out the |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
51 |
// directory, likely being pedantic. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
52 |
File cwd = new File("."); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
53 |
for (File f : cwd.listFiles(createFilter(CLASS_FILE_EXT))) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
54 |
f.delete(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
55 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
56 |
for (File f : cwd.listFiles(createFilter(JAVA_FILE_EXT))) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
57 |
f.delete(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
58 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
59 |
createPlatformFile(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
60 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
61 |
// compile the generate code using the javac compiler vs. the api, to |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
62 |
// as a bonus point to see if the argument is passed correctly |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
63 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
64 |
tr = doExec(javacCmd, fileName + JAVA_FILE_EXT); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
65 |
if (!tr.isOK()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
66 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
67 |
throw new Error("compilation failed..."); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
68 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
69 |
tr = doExec(javaCmd, "-cp", ".", fileName); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
70 |
if (!tr.isOK()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
71 |
System.out.println(tr); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
72 |
throw new RuntimeException("run failed with encoding " + defaultEncoding); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
73 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
74 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
75 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
76 |
public static void createPlatformFile() throws Exception { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
77 |
List<String> buffer = new ArrayList<>(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
78 |
// "HelloWorld" with an accented e |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
79 |
fileName = "i18nH\u00e9lloWorld"; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
80 |
buffer.clear(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
81 |
buffer.add("public class i18nH\u00e9lloWorld {"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
82 |
buffer.add(" public static void main(String [] argv) {"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
83 |
buffer.add(" System.out.println(\"Hello Cp1252 World\");"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
84 |
buffer.add(" }"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
85 |
buffer.add("}"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
86 |
File outFile = new File(fileName + JAVA_FILE_EXT); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
87 |
createFile(outFile, buffer); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
88 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
diff
changeset
|
89 |
} |