1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/4846262/CheckEBCDICLocaleTest.java Tue Feb 19 17:53:16 2013 +0000 1.3 @@ -0,0 +1,99 @@ 1.4 +/* 1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +/* 1.28 + * @test 1.29 + * @bug 4846262 1.30 + * @summary check that javac operates correctly in EBCDIC locale 1.31 + * @library /tools/javac/lib 1.32 + * @build ToolBox 1.33 + * @run main CheckEBCDICLocaleTest 1.34 + */ 1.35 + 1.36 +import java.io.File; 1.37 +import java.nio.file.Files; 1.38 +import java.nio.file.Paths; 1.39 +import java.util.Arrays; 1.40 +import com.sun.tools.javac.util.ArrayUtils; 1.41 + 1.42 +//original test: test/tools/javac/4846262/Test.sh 1.43 +public class CheckEBCDICLocaleTest { 1.44 + 1.45 + private static final String TestSrc = 1.46 + "public class Test {\n" + 1.47 + " public void test() {\n" + 1.48 + " abcdefg\n" + 1.49 + " }\n" + 1.50 + "}"; 1.51 + 1.52 + private static final String TestOut = 1.53 + "output/Test.java:3: error: not a statement\n" + 1.54 + " abcdefg\n" + 1.55 + " ^\n" + 1.56 + "output/Test.java:3: error: ';' expected\n" + 1.57 + " abcdefg\n" + 1.58 + " ^\n" + 1.59 + "2 errors\n"; 1.60 + 1.61 + public static void main(String[] args) throws Exception { 1.62 + new CheckEBCDICLocaleTest().test(); 1.63 + } 1.64 + 1.65 + public void test() throws Exception { 1.66 + String native2asciiBinary = Paths.get( 1.67 + System.getProperty("test.jdk"),"bin", "native2ascii").toString(); 1.68 + String testVMOpts = System.getProperty("test.tool.vm.opts"); 1.69 + String[] mainArgs = ToolBox.getJavacBin(); 1.70 + 1.71 + ToolBox.createJavaFileFromSource(TestSrc); 1.72 + Files.createDirectory(Paths.get("output")); 1.73 + 1.74 +//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java 1.75 + ToolBox.AnyToolArgs nativeCmdParams = 1.76 + new ToolBox.AnyToolArgs() 1.77 + .setAllArgs(native2asciiBinary, testVMOpts, 1.78 + "-reverse", "-encoding", "IBM1047", 1.79 + "Test.java", "output/Test.java"); 1.80 + ToolBox.executeCommand(nativeCmdParams); 1.81 + 1.82 +//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp 1.83 + ToolBox.AnyToolArgs javacParams = 1.84 + new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) 1.85 + .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en", 1.86 + "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047", 1.87 + "output/Test.java")) 1.88 + .setErrOutput(new File("Test.tmp")); 1.89 + ToolBox.executeCommand(javacParams); 1.90 + 1.91 +//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out 1.92 + nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047", 1.93 + "Test.tmp", "Test.out"); 1.94 + ToolBox.executeCommand(nativeCmdParams); 1.95 + 1.96 +//diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out 1.97 + ToolBox.compareLines(Paths.get("Test.out"), 1.98 + Arrays.asList(TestOut.split("\n")), null); 1.99 + 1.100 + } 1.101 + 1.102 +}