1/*
2 * Copyright (c) 2003, 2015, 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      4682448 4947464 5029946 8025633 8026567
27 * @summary  Verify that the public modifier does not show up in the
28 *           documentation for public methods, as recommended by the JLS.
29 *           If A implements I and B extends A, B should be in the list of
30 *           implementing classes in the documentation for I.
31 * @author   jamieh
32 * @library  ../lib
33 * @modules jdk.javadoc
34 * @build    JavadocTester
35 * @run main TestInterface
36 */
37
38public class TestInterface extends JavadocTester {
39
40    public static void main(String... args) throws Exception {
41        TestInterface tester = new TestInterface();
42        tester.runTests();
43    }
44
45    @Test
46    void test() {
47        javadoc("-d", "out",
48                "-sourcepath", testSrc,
49                "pkg");
50        checkExit(Exit.OK);
51
52        checkOutput("pkg/Interface.html", true,
53                "<pre>int&nbsp;method()</pre>",
54                "<pre>static final&nbsp;int field</pre>",
55                // Make sure known implementing class list is correct and omits type parameters.
56                "<dl>\n"
57                + "<dt>All Known Implementing Classes:</dt>\n"
58                + "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child"
59                + "</a>, <a href=\"../pkg/Parent.html\" title=\"class in pkg\">Parent"
60                + "</a></dd>\n"
61                + "</dl>");
62
63        checkOutput("pkg/Child.html", true,
64                // Make sure "All Implemented Interfaces": has substituted type parameters
65                "<dl>\n"
66                + "<dt>All Implemented Interfaces:</dt>\n"
67                + "<dd><a href=\"../pkg/Interface.html\" title=\"interface in pkg\">"
68                + "Interface</a>&lt;T&gt;</dd>\n"
69                + "</dl>",
70                //Make sure Class Tree has substituted type parameters.
71                "<ul class=\"inheritance\">\n"
72                + "<li>java.lang.Object</li>\n"
73                + "<li>\n"
74                + "<ul class=\"inheritance\">\n"
75                + "<li><a href=\"../pkg/Parent.html\" title=\"class in pkg\">"
76                + "pkg.Parent</a>&lt;T&gt;</li>\n"
77                + "<li>\n"
78                + "<ul class=\"inheritance\">\n"
79                + "<li>pkg.Child&lt;T&gt;</li>\n"
80                + "</ul>\n"
81                + "</li>\n"
82                + "</ul>\n"
83                + "</li>\n"
84                + "</ul>",
85                //Make sure "Specified By" has substituted type parameters.
86                "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
87                + "<dd><code><a href=\"../pkg/Interface.html#method--\">method</a>"
88                + "</code>&nbsp;in interface&nbsp;<code>"
89                + "<a href=\"../pkg/Interface.html\" title=\"interface in pkg\">"
90                + "Interface</a>&lt;<a href=\"../pkg/Child.html\" title=\"type parameter in Child\">"
91                + "T</a>&gt;</code></dd>",
92                //Make sure "Overrides" has substituted type parameters.
93                "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
94                + "<dd><code><a href=\"../pkg/Parent.html#method--\">method</a>"
95                + "</code>&nbsp;in class&nbsp;<code><a href=\"../pkg/Parent.html\" "
96                + "title=\"class in pkg\">Parent</a>&lt;<a href=\"../pkg/Child.html\" "
97                + "title=\"type parameter in Child\">T</a>&gt;</code></dd>");
98
99        checkOutput("pkg/Parent.html", true,
100                //Make sure "Direct Know Subclasses" omits type parameters
101                "<dl>\n"
102                + "<dt>Direct Known Subclasses:</dt>\n"
103                + "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child"
104                + "</a></dd>\n"
105                + "</dl>");
106
107        checkOutput("pkg/Interface.html", false,
108                "public int&nbsp;method()",
109                "public static final&nbsp;int field");
110    }
111}
112