jjg@912: /* jjg@912: * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. jjg@912: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@912: * jjg@912: * This code is free software; you can redistribute it and/or modify it jjg@912: * under the terms of the GNU General Public License version 2 only, as jjg@912: * published by the Free Software Foundation. jjg@912: * jjg@912: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@912: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@912: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@912: * version 2 for more details (a copy is included in the LICENSE file that jjg@912: * accompanied this code). jjg@912: * jjg@912: * You should have received a copy of the GNU General Public License version jjg@912: * 2 along with this work; if not, write to the Free Software Foundation, jjg@912: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@912: * jjg@912: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jjg@912: * or visit www.oracle.com if you need additional information or have any jjg@912: * questions. jjg@912: */ jjg@912: jjg@912: /* jjg@912: * @test jjg@912: * @bug 6964914 jjg@912: * @summary javadoc does not output number of warnings using user written doclet jjg@912: */ jjg@912: jjg@912: import java.io.*; jjg@912: jjg@912: public class Test { jjg@912: public static void main(String... args) throws Exception { jjg@912: new Test().run(); jjg@912: } jjg@912: jjg@912: public void run() throws Exception { jjg@912: javadoc("Error.java", "1 error"); jjg@912: javadoc("JavacWarning.java", "1 warning"); jjg@912: javadoc("JavadocWarning.java", "1 warning"); jjg@912: if (errors > 0) jjg@912: throw new Exception(errors + " errors found"); jjg@912: } jjg@912: jjg@912: void javadoc(String path, String expect) { jjg@912: File testSrc = new File(System.getProperty("test.src")); jjg@912: String[] args = { jjg@912: "-source", "1.4", // enables certain Parser warnings jjg@912: "-bootclasspath", System.getProperty("sun.boot.class.path"), jjg@912: "-classpath", ".", jjg@912: "-package", jjg@912: new File(testSrc, path).getPath() jjg@912: }; jjg@912: jjg@912: StringWriter sw = new StringWriter(); jjg@912: PrintWriter pw = new PrintWriter(sw); jjg@912: int rc = com.sun.tools.javadoc.Main.execute( jjg@912: "javadoc", jjg@912: pw, pw, pw, jjg@912: com.sun.tools.doclets.standard.Standard.class.getName(), jjg@912: args); jjg@912: pw.close(); jjg@912: String out = sw.toString(); jjg@912: if (!out.isEmpty()) jjg@912: System.err.println(out); jjg@912: System.err.println("javadoc exit: rc=" + rc); jjg@912: jjg@912: if (!out.contains(expect)) jjg@912: error("expected text not found: " + expect); jjg@912: } jjg@912: jjg@912: void error(String msg) { jjg@912: System.err.println("Error: " + msg); jjg@912: errors++; jjg@912: } jjg@912: jjg@912: int errors; jjg@912: }