32 |
32 |
33 import java.io.File; |
33 import java.io.File; |
34 import java.nio.file.Files; |
34 import java.nio.file.Files; |
35 import java.nio.file.Paths; |
35 import java.nio.file.Paths; |
36 import java.util.Arrays; |
36 import java.util.Arrays; |
37 import com.sun.tools.javac.util.ArrayUtils; |
|
38 |
37 |
39 //original test: test/tools/javac/4846262/Test.sh |
|
40 public class CheckEBCDICLocaleTest { |
38 public class CheckEBCDICLocaleTest { |
41 |
39 |
42 private static final String TestSrc = |
40 private static final String TestSrc = |
43 "public class Test {\n" + |
41 "public class Test {\n" + |
44 " public void test() {\n" + |
42 " public void test() {\n" + |
45 " abcdefg\n" + |
43 " abcdefg\n" + |
46 " }\n" + |
44 " }\n" + |
47 "}"; |
45 "}"; |
48 |
46 |
49 private static final String TestOut = |
47 private static final String TestOutTemplate = |
50 "output/Test.java:3: error: not a statement\n" + |
48 "output%1$sTest.java:3: error: not a statement\n" + |
51 " abcdefg\n" + |
49 " abcdefg\n" + |
52 " ^\n" + |
50 " ^\n" + |
53 "output/Test.java:3: error: ';' expected\n" + |
51 "output%1$sTest.java:3: error: ';' expected\n" + |
54 " abcdefg\n" + |
52 " abcdefg\n" + |
55 " ^\n" + |
53 " ^\n" + |
56 "2 errors\n"; |
54 "2 errors\n"; |
57 |
55 |
58 public static void main(String[] args) throws Exception { |
56 public static void main(String[] args) throws Exception { |
60 } |
58 } |
61 |
59 |
62 public void test() throws Exception { |
60 public void test() throws Exception { |
63 String native2asciiBinary = Paths.get( |
61 String native2asciiBinary = Paths.get( |
64 System.getProperty("test.jdk"),"bin", "native2ascii").toString(); |
62 System.getProperty("test.jdk"),"bin", "native2ascii").toString(); |
65 String testVMOpts = System.getProperty("test.tool.vm.opts"); |
|
66 String[] mainArgs = ToolBox.getJavacBin(); |
|
67 |
63 |
68 ToolBox.createJavaFileFromSource(TestSrc); |
64 ToolBox.createJavaFileFromSource(TestSrc); |
69 Files.createDirectory(Paths.get("output")); |
65 Files.createDirectory(Paths.get("output")); |
70 |
66 |
71 //"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java |
|
72 ToolBox.AnyToolArgs nativeCmdParams = |
67 ToolBox.AnyToolArgs nativeCmdParams = |
73 new ToolBox.AnyToolArgs() |
68 new ToolBox.AnyToolArgs() |
74 .setAllArgs(native2asciiBinary, testVMOpts, |
69 .appendArgs(native2asciiBinary) |
75 "-reverse", "-encoding", "IBM1047", |
70 .appendArgs(ToolBox.testToolVMOpts) |
76 "Test.java", "output/Test.java"); |
71 .appendArgs("-reverse", "-encoding", "IBM1047", "Test.java", |
|
72 "output/Test.java"); |
77 ToolBox.executeCommand(nativeCmdParams); |
73 ToolBox.executeCommand(nativeCmdParams); |
78 |
74 |
79 //"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp |
|
80 ToolBox.AnyToolArgs javacParams = |
75 ToolBox.AnyToolArgs javacParams = |
81 new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) |
76 new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) |
82 .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en", |
77 .appendArgs(ToolBox.javacBinary) |
|
78 .appendArgs(ToolBox.testToolVMOpts) |
|
79 .appendArgs("-J-Duser.language=en", |
83 "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047", |
80 "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047", |
84 "output/Test.java")) |
81 "output/Test.java") |
85 .setErrOutput(new File("Test.tmp")); |
82 .setErrOutput(new File("Test.tmp")); |
86 ToolBox.executeCommand(javacParams); |
83 ToolBox.executeCommand(javacParams); |
87 |
84 |
88 //"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out |
85 nativeCmdParams = new ToolBox.AnyToolArgs() |
89 nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047", |
86 .appendArgs(native2asciiBinary) |
90 "Test.tmp", "Test.out"); |
87 .appendArgs(ToolBox.testToolVMOpts) |
|
88 .appendArgs("-encoding", "IBM1047", "Test.tmp", "Test.out"); |
91 ToolBox.executeCommand(nativeCmdParams); |
89 ToolBox.executeCommand(nativeCmdParams); |
92 |
90 |
93 //diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out |
91 String goldenFile = String.format(TestOutTemplate, File.separator); |
94 ToolBox.compareLines(Paths.get("Test.out"), |
92 ToolBox.compareLines(Paths.get("Test.out"), |
95 Arrays.asList(TestOut.split("\n")), null); |
93 Arrays.asList(goldenFile.split("\n")), null, true); |
96 |
|
97 } |
94 } |
98 |
95 |
99 } |
96 } |