TestMemberInheritence.java revision 1934:8c55df2442c1
1/*
2 * Copyright (c) 2002, 2013, 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 4638588 4635809 6256068 6270645
27 * @summary Test to make sure that members are inherited properly in the Javadoc.
28 *          Verify that inheritence labels are correct.
29 * @author jamieh
30 * @library ../lib/
31 * @build JavadocTester
32 * @build TestMemberInheritence
33 * @run main TestMemberInheritence
34 */
35
36public class TestMemberInheritence extends JavadocTester {
37
38    private static final String BUG_ID = "4638588-4635809-6256068-6270645";
39
40    private static final String[][] TEST = {
41        //Public field should be inherited
42        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
43         "<a href=\"../pkg/BaseClass.html#pubField\">"},
44
45        //Public method should be inherited
46        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
47         "<a href=\"../pkg/BaseClass.html#pubMethod()\">"},
48
49        //Public inner class should be inherited.
50        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
51         "<a href=\"../pkg/BaseClass.pubInnerClass.html\" title=\"class in pkg\">"},
52
53        //Protected field should be inherited
54        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
55         "<a href=\"../pkg/BaseClass.html#proField\">"},
56
57        //Protected method should be inherited
58        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
59         "<a href=\"../pkg/BaseClass.html#proMethod()\">"},
60
61        //Protected inner class should be inherited.
62        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
63         "<a href=\"../pkg/BaseClass.proInnerClass.html\" title=\"class in pkg\">"},
64
65        // New labels as of 1.5.0
66        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
67         "Nested classes/interfaces inherited from class&nbsp;pkg." +
68                 "<a href=\"../pkg/BaseClass.html\" title=\"class in pkg\">BaseClass</a>"},
69        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
70         "Nested classes/interfaces inherited from interface&nbsp;pkg." +
71                 "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</a>"},
72
73         // Test overriding/implementing methods with generic parameters.
74                 {BUG_ID + FS + "pkg" + FS + "BaseClass.html",
75         "<dl>" + NL + "<dt><span class=\"strong\">Specified by:</span></dt>" + NL +
76                          "<dd><code><a href=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">" +
77                          "getAnnotation</a></code>&nbsp;in interface&nbsp;<code>" +
78                          "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">" +
79                          "BaseInterface</a></code></dd>" + NL + "</dl>"},
80
81         // Test diamond inheritence member summary (6256068)
82                 {BUG_ID + FS + "diamond" + FS + "Z.html",
83                 "<code><a href=\"../diamond/A.html#aMethod()\">aMethod</a></code>"},
84
85         // Test that doc is inherited from closed parent (6270645)
86                 {BUG_ID + FS + "inheritDist" + FS + "C.html",
87                 "<div class=\"block\">m1-B</div>"},
88
89    };
90
91    private static final String[][] NEGATED_TEST = {
92        {BUG_ID + FS + "pkg" + FS + "SubClass.html",
93        "<a href=\"../pkg/BaseClass.html#staticMethod()\">staticMethod</a></code>"},
94    };
95    private static final String[] ARGS =
96        new String[] {
97            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "diamond", "inheritDist"};
98
99    /**
100     * The entry point of the test.
101     * @param args the array of command line arguments.
102     */
103    public static void main(String[] args) {
104        TestMemberInheritence tester = new TestMemberInheritence();
105        run(tester, ARGS, TEST, NEGATED_TEST);
106        tester.printSummary();
107    }
108
109    /**
110     * {@inheritDoc}
111     */
112    public String getBugId() {
113        return BUG_ID;
114    }
115
116    /**
117     * {@inheritDoc}
118     */
119    public String getBugName() {
120        return getClass().getName();
121    }
122}
123