Tue, 14 May 2013 10:14:56 -0700
8012311: Cleanup names and duplicatre code in TagletManager
Reviewed-by: darcy
1 /*
2 * Copyright (c) 2012, 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 /* @test
25 * @bug 8004832
26 * @summary Add new doclint package
27 * @bug 8000103
28 * @summary Create doclint utility
29 */
31 import com.sun.tools.doclint.DocLint;
32 import com.sun.tools.doclint.DocLint.BadArgs;
33 import java.io.ByteArrayOutputStream;
34 import java.io.File;
35 import java.io.FilterOutputStream;
36 import java.io.IOException;
37 import java.io.OutputStream;
38 import java.io.PrintStream;
39 import java.io.PrintWriter;
40 import java.io.StringWriter;
41 import java.lang.annotation.Annotation;
42 import java.lang.annotation.Retention;
43 import java.lang.annotation.RetentionPolicy;
44 import java.lang.reflect.InvocationTargetException;
45 import java.lang.reflect.Method;
47 /** javadoc error on toplevel: a & b. */
48 public class RunTest {
49 /** javadoc error on member: a < b */
50 public static void main(String... args) throws Exception {
51 new RunTest().run();
52 }
55 File testSrc = new File(System.getProperty("test.src"));
56 File thisFile = new File(testSrc, RunTest.class.getSimpleName() + ".java");
58 void run() throws Exception {
59 for (Method m: getClass().getDeclaredMethods()) {
60 Annotation a = m.getAnnotation(Test.class);
61 if (a != null) {
62 System.err.println("test: " + m.getName());
63 try {
64 StringWriter sw = new StringWriter();
65 PrintWriter pw = new PrintWriter(sw);;
66 m.invoke(this, new Object[] { pw });
67 String out = sw.toString();
68 System.err.println(">>> " + out.replace("\n", "\n>>> "));
69 if (!out.contains("a < b"))
70 error("\"a < b\" not found");
71 if (!out.contains("a & b"))
72 error("\"a & b\" not found");
73 } catch (InvocationTargetException e) {
74 Throwable cause = e.getCause();
75 throw (cause instanceof Exception) ? ((Exception) cause) : e;
76 }
77 System.err.println();
78 }
79 }
81 if (errors > 0)
82 throw new Exception(errors + " errors occurred");
83 }
86 void error(String msg) {
87 System.err.println("Error: " + msg);
88 errors++;
89 }
91 int errors;
93 /** Marker annotation for test cases. */
94 @Retention(RetentionPolicy.RUNTIME)
95 @interface Test { }
97 @Test
98 void testMain(PrintWriter pw) throws BadArgs, IOException {
99 String[] args = { "-Xmsgs", thisFile.getPath() };
100 DocLint d = new DocLint();
101 d.run(pw, args);
102 }
103 }