TestWarnings.java revision 3255:7a0c34355149
1/*
2 * Copyright (c) 2004, 2016, 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 * @modules jdk.javadoc/jdk.javadoc.internal.tool
35 * @build    JavadocTester
36 * @run main TestWarnings
37 */
38
39public class TestWarnings extends JavadocTester {
40    public static void main(String... args) throws Exception  {
41        TestWarnings tester = new TestWarnings();
42        tester.runTests();
43    }
44
45    @Test
46    void testDefault() {
47        javadoc("-d", "out-default",
48                "-sourcepath", testSrc,
49                "pkg");
50        checkExit(Exit.FAILED);
51
52        checkOutput(Output.OUT, true,
53                "X.java:23: error: self-closing element not allowed");
54
55        checkOutput(Output.OUT, true,
56                "X.java:24: error: self-closing element not allowed");
57
58        checkOutput(Output.OUT, true,
59                "X.java:25: error: self-closing element not allowed");
60
61        checkOutput(Output.OUT, true,
62                "X.java:26: error: self-closing element not allowed");
63
64        checkOutput("pkg/X.html", false,
65                "can't find m()");
66        checkOutput("pkg/X.html", false,
67                "can't find X()");
68        checkOutput("pkg/X.html", false,
69                "can't find f");
70    }
71
72    @Test
73    void testPrivate() {
74        javadoc("-d", "out-private",
75                "-private",
76                "-sourcepath", testSrc,
77                "pkg");
78        checkExit(Exit.FAILED);
79
80        checkOutput("pkg/X.html", true,
81            "<a href=\"../pkg/X.html#m--\"><code>m()</code></a><br/>",
82            "<a href=\"../pkg/X.html#X--\"><code>X()</code></a><br/>",
83            "<a href=\"../pkg/X.html#f\"><code>f</code></a><br/>");
84    }
85}
86