vromero@1591: /* vromero@1591: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. vromero@1591: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. vromero@1591: * vromero@1591: * This code is free software; you can redistribute it and/or modify it vromero@1591: * under the terms of the GNU General Public License version 2 only, as vromero@1591: * published by the Free Software Foundation. vromero@1591: * vromero@1591: * This code is distributed in the hope that it will be useful, but WITHOUT vromero@1591: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or vromero@1591: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License vromero@1591: * version 2 for more details (a copy is included in the LICENSE file that vromero@1591: * accompanied this code). vromero@1591: * vromero@1591: * You should have received a copy of the GNU General Public License version vromero@1591: * 2 along with this work; if not, write to the Free Software Foundation, vromero@1591: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. vromero@1591: * vromero@1591: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA vromero@1591: * or visit www.oracle.com if you need additional information or have any vromero@1591: * questions. vromero@1591: */ vromero@1591: vromero@1591: /* vromero@1591: * @test vromero@1591: * @bug 4846262 vromero@1591: * @summary check that javac operates correctly in EBCDIC locale vromero@1591: * @library /tools/javac/lib vromero@1591: * @build ToolBox vromero@1591: * @run main CheckEBCDICLocaleTest vromero@1591: */ vromero@1591: vromero@1591: import java.io.File; vromero@1591: import java.nio.file.Files; vromero@1591: import java.nio.file.Paths; vromero@1591: import java.util.Arrays; vromero@1591: vromero@1591: public class CheckEBCDICLocaleTest { vromero@1591: vromero@1591: private static final String TestSrc = vromero@1591: "public class Test {\n" + vromero@1591: " public void test() {\n" + vromero@1591: " abcdefg\n" + vromero@1591: " }\n" + vromero@1591: "}"; vromero@1591: vromero@1637: private static final String TestOutTemplate = vromero@1637: "output%1$sTest.java:3: error: not a statement\n" + vromero@1591: " abcdefg\n" + vromero@1591: " ^\n" + vromero@1637: "output%1$sTest.java:3: error: ';' expected\n" + vromero@1591: " abcdefg\n" + vromero@1591: " ^\n" + vromero@1591: "2 errors\n"; vromero@1591: vromero@1591: public static void main(String[] args) throws Exception { vromero@1591: new CheckEBCDICLocaleTest().test(); vromero@1591: } vromero@1591: vromero@1591: public void test() throws Exception { vromero@1591: String native2asciiBinary = Paths.get( vromero@1591: System.getProperty("test.jdk"),"bin", "native2ascii").toString(); vromero@1591: vromero@1591: ToolBox.createJavaFileFromSource(TestSrc); vromero@1591: Files.createDirectory(Paths.get("output")); vromero@1591: vromero@1591: ToolBox.AnyToolArgs nativeCmdParams = vromero@1591: new ToolBox.AnyToolArgs() vromero@1637: .appendArgs(native2asciiBinary) vromero@1637: .appendArgs(ToolBox.testToolVMOpts) vromero@1637: .appendArgs("-reverse", "-encoding", "IBM1047", "Test.java", vromero@1637: "output/Test.java"); vromero@1591: ToolBox.executeCommand(nativeCmdParams); vromero@1591: vromero@1591: ToolBox.AnyToolArgs javacParams = vromero@1591: new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) vromero@1637: .appendArgs(ToolBox.javacBinary) vromero@1637: .appendArgs(ToolBox.testToolVMOpts) vromero@1637: .appendArgs("-J-Duser.language=en", vromero@1591: "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047", vromero@1637: "output/Test.java") vromero@1591: .setErrOutput(new File("Test.tmp")); vromero@1591: ToolBox.executeCommand(javacParams); vromero@1591: vromero@1637: nativeCmdParams = new ToolBox.AnyToolArgs() vromero@1637: .appendArgs(native2asciiBinary) vromero@1637: .appendArgs(ToolBox.testToolVMOpts) vromero@1637: .appendArgs("-encoding", "IBM1047", "Test.tmp", "Test.out"); vromero@1591: ToolBox.executeCommand(nativeCmdParams); vromero@1591: vromero@1637: String goldenFile = String.format(TestOutTemplate, File.separator); vromero@1591: ToolBox.compareLines(Paths.get("Test.out"), vromero@1637: Arrays.asList(goldenFile.split("\n")), null, true); vromero@1591: } vromero@1591: vromero@1591: }