test/tools/javadoc/6964914/Test.java

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 912
5e6c661891da
child 1490
fc4cb1577ad6
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

jjg@912 1 /*
jjg@912 2 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
jjg@912 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@912 4 *
jjg@912 5 * This code is free software; you can redistribute it and/or modify it
jjg@912 6 * under the terms of the GNU General Public License version 2 only, as
jjg@912 7 * published by the Free Software Foundation.
jjg@912 8 *
jjg@912 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@912 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@912 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@912 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@912 13 * accompanied this code).
jjg@912 14 *
jjg@912 15 * You should have received a copy of the GNU General Public License version
jjg@912 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@912 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@912 18 *
jjg@912 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jjg@912 20 * or visit www.oracle.com if you need additional information or have any
jjg@912 21 * questions.
jjg@912 22 */
jjg@912 23
jjg@912 24 /*
jjg@912 25 * @test
jjg@912 26 * @bug 6964914
jjg@912 27 * @summary javadoc does not output number of warnings using user written doclet
jjg@912 28 */
jjg@912 29
jjg@912 30 import java.io.*;
jjg@912 31
jjg@912 32 public class Test {
jjg@912 33 public static void main(String... args) throws Exception {
jjg@912 34 new Test().run();
jjg@912 35 }
jjg@912 36
jjg@912 37 public void run() throws Exception {
jjg@912 38 javadoc("Error.java", "1 error");
jjg@912 39 javadoc("JavacWarning.java", "1 warning");
jjg@912 40 javadoc("JavadocWarning.java", "1 warning");
jjg@912 41 if (errors > 0)
jjg@912 42 throw new Exception(errors + " errors found");
jjg@912 43 }
jjg@912 44
jjg@912 45 void javadoc(String path, String expect) {
jjg@912 46 File testSrc = new File(System.getProperty("test.src"));
jjg@912 47 String[] args = {
jjg@912 48 "-source", "1.4", // enables certain Parser warnings
jjg@912 49 "-bootclasspath", System.getProperty("sun.boot.class.path"),
jjg@912 50 "-classpath", ".",
jjg@912 51 "-package",
jjg@912 52 new File(testSrc, path).getPath()
jjg@912 53 };
jjg@912 54
jjg@912 55 StringWriter sw = new StringWriter();
jjg@912 56 PrintWriter pw = new PrintWriter(sw);
jjg@912 57 int rc = com.sun.tools.javadoc.Main.execute(
jjg@912 58 "javadoc",
jjg@912 59 pw, pw, pw,
jjg@912 60 com.sun.tools.doclets.standard.Standard.class.getName(),
jjg@912 61 args);
jjg@912 62 pw.close();
jjg@912 63 String out = sw.toString();
jjg@912 64 if (!out.isEmpty())
jjg@912 65 System.err.println(out);
jjg@912 66 System.err.println("javadoc exit: rc=" + rc);
jjg@912 67
jjg@912 68 if (!out.contains(expect))
jjg@912 69 error("expected text not found: " + expect);
jjg@912 70 }
jjg@912 71
jjg@912 72 void error(String msg) {
jjg@912 73 System.err.println("Error: " + msg);
jjg@912 74 errors++;
jjg@912 75 }
jjg@912 76
jjg@912 77 int errors;
jjg@912 78 }

mercurial