Tue, 05 Feb 2013 18:55:13 +0000
8007504: Remove @ignore from tests that no longer need it
Reviewed-by: mcimadamore
1 /*
2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /*
25 * @test
26 * @bug 6306137
27 * @summary JSR 199: encoding option doesn't affect standard file manager
28 * @author Peter von der Ahé
29 */
31 import java.io.File;
32 import java.util.Arrays;
33 import javax.tools.*;
35 public class T6306137 {
36 boolean error;
37 final StandardJavaFileManager fm;
38 final JavaCompiler compiler;
39 Iterable<? extends JavaFileObject> files;
40 DiagnosticListener<JavaFileObject> dl;
42 T6306137() {
43 dl = new DiagnosticListener<JavaFileObject>() {
44 public void report(Diagnostic<? extends JavaFileObject> message) {
45 if (message.getKind() == Diagnostic.Kind.ERROR)
46 error = true;
47 System.out.println(message.getSource()
48 +":"+message.getStartPosition()+":"
49 +message.getStartPosition()+":"+message.getPosition());
50 System.out.println(message.toString());
51 System.out.format("Found problem: %s%n", message.getCode());
52 System.out.flush();
53 }
54 };
55 compiler = ToolProvider.getSystemJavaCompiler();
56 fm = compiler.getStandardFileManager(dl, null, null);
57 String srcdir = System.getProperty("test.src");
58 files =
59 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6306137.java")));
60 }
62 void test(String encoding, boolean good) {
63 error = false;
64 Iterable<String> args = Arrays.asList("-source", "6", "-encoding", encoding, "-d", ".");
65 compiler.getTask(null, fm, dl, args, null, files).call();
66 if (error == good) {
67 if (error) {
68 throw new AssertionError("Error reported");
69 } else {
70 throw new AssertionError("No error reported");
71 }
72 }
73 }
75 public static void main(String[] args) {
76 T6306137 self = new T6306137();
77 self.test("utf-8", true);
78 self.test("ascii", false);
79 self.test("utf-8", true);
80 }
81 }