Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java
38813 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 484626226* @summary check that javac operates correctly in EBCDIC locale27* @library /tools/javac/lib28* @build ToolBox29* @run main CheckEBCDICLocaleTest30*/3132import java.io.File;33import java.nio.file.Files;34import java.nio.file.Paths;35import java.util.Arrays;3637public class CheckEBCDICLocaleTest {3839private static final String TestSrc =40"public class Test {\n" +41" public void test() {\n" +42" abcdefg\n" +43" }\n" +44"}";4546private static final String TestOutTemplate =47"output%1$sTest.java:3: error: not a statement\n" +48" abcdefg\n" +49" ^\n" +50"output%1$sTest.java:3: error: ';' expected\n" +51" abcdefg\n" +52" ^\n" +53"2 errors\n";5455public static void main(String[] args) throws Exception {56new CheckEBCDICLocaleTest().test();57}5859public void test() throws Exception {60String native2asciiBinary = Paths.get(61System.getProperty("test.jdk"),"bin", "native2ascii").toString();6263ToolBox.createJavaFileFromSource(TestSrc);64Files.createDirectory(Paths.get("output"));6566ToolBox.AnyToolArgs nativeCmdParams =67new ToolBox.AnyToolArgs()68.appendArgs(native2asciiBinary)69.appendArgs(ToolBox.testToolVMOpts)70.appendArgs("-reverse", "-encoding", "IBM1047", "Test.java",71"output/Test.java");72ToolBox.executeCommand(nativeCmdParams);7374ToolBox.AnyToolArgs javacParams =75new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)76.appendArgs(ToolBox.javacBinary)77.appendArgs(ToolBox.testToolVMOpts)78.appendArgs("-J-Duser.language=en",79"-J-Duser.region=US", "-J-Dfile.encoding=IBM1047",80"output/Test.java")81.setErrOutput(new File("Test.tmp"));82ToolBox.executeCommand(javacParams);8384nativeCmdParams = new ToolBox.AnyToolArgs()85.appendArgs(native2asciiBinary)86.appendArgs(ToolBox.testToolVMOpts)87.appendArgs("-encoding", "IBM1047", "Test.tmp", "Test.out");88ToolBox.executeCommand(nativeCmdParams);8990String goldenFile = String.format(TestOutTemplate, File.separator);91ToolBox.compareLines(Paths.get("Test.out"),92Arrays.asList(goldenFile.split("\n")), null, true);93}9495}969798