TestWarnings.java revision 2365:6207608205b8
1/* 2 * Copyright (c) 2004, 2014, 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 */ 23 24/* 25 * @test 26 * @bug 4515705 4804296 4702454 4697036 8025633 27 * @summary Make sure that first sentence warning only appears once. 28 * Make sure that only warnings/errors are printed when quiet is used. 29 * Make sure that links to private/unincluded methods do not cause 30 * a "link unresolved" warning. 31 * Make sure error message starts with "error -". 32 * @author jamieh 33 * @library ../lib/ 34 * @build JavadocTester 35 * @build TestWarnings 36 * @run main TestWarnings 37 */ 38 39public class TestWarnings extends JavadocTester { 40 41 //Test information. 42 private static final String BUG_ID = "4515705-4804296-4702454-4697036"; 43 44 //Javadoc arguments. 45 private static final String[] ARGS = new String[] { 46 "-Xdoclint:none", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" 47 }; 48 49 private static final String[] ARGS2 = new String[] { 50 "-Xdoclint:none", "-d", BUG_ID, "-private", "-sourcepath", SRC_DIR, 51 "pkg" 52 }; 53 54 //Input for string search tests. 55 private static final String[][] TEST = { 56 {WARNING_OUTPUT, 57 "X.java:11: warning - Missing closing '}' character for inline tag"}, 58 {ERROR_OUTPUT, 59 "package.html: error - Body tag missing from HTML"}, 60 61 }; 62 private static final String[][] NEGATED_TEST = { 63 {BUG_ID + "/pkg/X.html", "can't find m()"}, 64 {BUG_ID + "/pkg/X.html", "can't find X()"}, 65 {BUG_ID + "/pkg/X.html", "can't find f"}, 66 }; 67 68 private static final String[][] TEST2 = { 69 {BUG_ID + "/pkg/X.html", 70 "<a href=\"../pkg/X.html#m--\"><code>m()</code></a><br/>"}, 71 {BUG_ID + "/pkg/X.html", 72 "<a href=\"../pkg/X.html#X--\"><code>X()</code></a><br/>"}, 73 {BUG_ID + "/pkg/X.html", 74 "<a href=\"../pkg/X.html#f\"><code>f</code></a><br/>"}, 75 }; 76 77 private static final String[][] NEGATED_TEST2 = NO_TEST; 78 79 80 /** 81 * The entry point of the test. 82 * @param args the array of command line arguments. 83 */ 84 public static void main(String[] args) { 85 TestWarnings tester = new TestWarnings(); 86 run(tester, ARGS, TEST, NEGATED_TEST); 87 run(tester, ARGS2, TEST2, NEGATED_TEST2); 88 tester.printSummary(); 89 } 90 91 /** 92 * {@inheritDoc} 93 */ 94 public String getBugId() { 95 return BUG_ID; 96 } 97 98 /** 99 * {@inheritDoc} 100 */ 101 public String getBugName() { 102 return getClass().getName(); 103 } 104} 105