8081538: test CheckEBCDICLocaleTest is failing
authorjjg
Fri, 29 May 2015 17:15:10 -0700
changeset 31002 b99fa15b3717
parent 31001 cd83acd5f6b5
child 31003 c4c8cbd9b3b4
8081538: test CheckEBCDICLocaleTest is failing Reviewed-by: vromero
langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java
--- a/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java	Fri May 29 15:50:31 2015 -0700
+++ b/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java	Fri May 29 17:15:10 2015 -0700
@@ -29,16 +29,17 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
- * @ignore 8081538 test CheckEBCDICLocaleTest is failing
  * @build ToolBox
  * @run main CheckEBCDICLocaleTest
  */
 
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintStream;
+import java.io.PrintWriter;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
-import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.List;
@@ -70,16 +71,19 @@
         tb.writeFile("Test.java", TestSrc);
         tb.createDirectories("output");
 
-        Native2Ascii n2a = new Native2Ascii(Charset.forName("IBM1047"));
+        Charset ebcdic = Charset.forName("IBM1047");
+        Native2Ascii n2a = new Native2Ascii(ebcdic);
         n2a.asciiToNative(Paths.get("Test.java"), Paths.get("output", "Test.java"));
 
-        tb.new JavacTask(ToolBox.Mode.EXEC)
-                .redirect(ToolBox.OutputKind.STDERR, "Test.tmp")
-                .options("-J-Duser.language=en",
-                        "-J-Duser.region=US",
-                        "-J-Dfile.encoding=IBM1047")
-                .files("output/Test.java")
-                .run(ToolBox.Expect.FAIL);
+        // Use -encoding to specify the encoding with which to read source files
+        // Use a suitable configured output stream for javac diagnostics
+        int rc;
+        try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream("Test.tmp"), ebcdic))) {
+            String[] args = { "-encoding", ebcdic.name(), "output/Test.java" };
+            rc = com.sun.tools.javac.Main.compile(args, out);
+            if (rc != 1)
+                throw new Exception("unexpected exit from javac: " + rc);
+        }
 
         n2a.nativeToAscii(Paths.get("Test.tmp"), Paths.get("Test.out"));