TestInterface.java revision 2365:6207608205b8
1/*
2 * Copyright (c) 2003, 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      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 * @build    JavadocTester
34 * @build    TestInterface
35 * @run main TestInterface
36 */
37
38public class TestInterface extends JavadocTester {
39
40    //Test information.
41    private static final String BUG_ID = "4682448-4947464-5029946";
42
43    //Javadoc arguments.
44    private static final String[] ARGS = new String[] {
45        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
46    };
47
48    //Input for string search tests.
49    private static final String[][] TEST = {
50        {BUG_ID + "/pkg/Interface.html",
51            "<pre>int&nbsp;method()</pre>"},
52        {BUG_ID + "/pkg/Interface.html",
53            "<pre>static final&nbsp;int field</pre>"},
54
55
56        // Make sure known implementing class list is correct and omits type parameters.
57        {BUG_ID + "/pkg/Interface.html",
58            "<dl>\n" +
59            "<dt>All Known Implementing Classes:</dt>\n" +
60            "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child" +
61            "</a>, <a href=\"../pkg/Parent.html\" title=\"class in pkg\">Parent" +
62            "</a></dd>\n" +
63            "</dl>"},
64
65         // Make sure "All Implemented Interfaces": has substituted type parameters
66         {BUG_ID + "/pkg/Child.html",
67            "<dl>\n" +
68            "<dt>All Implemented Interfaces:</dt>\n" +
69            "<dd><a href=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
70            "Interface</a>&lt;T&gt;</dd>\n" +
71            "</dl>"
72         },
73         //Make sure Class Tree has substituted type parameters.
74         {BUG_ID + "/pkg/Child.html",
75            "<ul class=\"inheritance\">\n" +
76            "<li>java.lang.Object</li>\n" +
77            "<li>\n" +
78            "<ul class=\"inheritance\">\n" +
79            "<li><a href=\"../pkg/Parent.html\" title=\"class in pkg\">" +
80            "pkg.Parent</a>&lt;T&gt;</li>\n" +
81            "<li>\n" +
82            "<ul class=\"inheritance\">\n" +
83            "<li>pkg.Child&lt;T&gt;</li>\n" +
84            "</ul>\n" +
85            "</li>\n" +
86            "</ul>\n" +
87            "</li>\n" +
88            "</ul>"
89         },
90         //Make sure "Direct Know Subclasses" omits type parameters
91        {BUG_ID + "/pkg/Parent.html",
92            "<dl>\n" +
93            "<dt>Direct Known Subclasses:</dt>\n" +
94            "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child" +
95            "</a></dd>\n" +
96            "</dl>"
97        },
98        //Make sure "Specified By" has substituted type parameters.
99        {BUG_ID + "/pkg/Child.html",
100            "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n" +
101            "<dd><code><a href=\"../pkg/Interface.html#method--\">method</a>" +
102            "</code>&nbsp;in interface&nbsp;<code>" +
103            "<a href=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
104            "Interface</a>&lt;<a href=\"../pkg/Child.html\" title=\"type parameter in Child\">" +
105            "T</a>&gt;</code></dd>"
106         },
107        //Make sure "Overrides" has substituted type parameters.
108        {BUG_ID + "/pkg/Child.html",
109            "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n" +
110            "<dd><code><a href=\"../pkg/Parent.html#method--\">method</a>" +
111            "</code>&nbsp;in class&nbsp;<code><a href=\"../pkg/Parent.html\" " +
112            "title=\"class in pkg\">Parent</a>&lt;<a href=\"../pkg/Child.html\" " +
113            "title=\"type parameter in Child\">T</a>&gt;</code></dd>"
114         },
115    };
116    private static final String[][] NEGATED_TEST = {
117        {BUG_ID + "/pkg/Interface.html",
118            "public int&nbsp;method()"},
119        {BUG_ID + "/pkg/Interface.html",
120            "public static final&nbsp;int field"},
121    };
122
123    /**
124     * The entry point of the test.
125     * @param args the array of command line arguments.
126     */
127    public static void main(String[] args) {
128        TestInterface tester = new TestInterface();
129        run(tester, ARGS, TEST, NEGATED_TEST);
130        tester.printSummary();
131    }
132
133    /**
134     * {@inheritDoc}
135     */
136    public String getBugId() {
137        return BUG_ID;
138    }
139
140    /**
141     * {@inheritDoc}
142     */
143    public String getBugName() {
144        return getClass().getName();
145    }
146}
147