TestMemberInheritence.java revision 3233:b5d08bc0d224
1/*
2 * Copyright (c) 2002, 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 4638588 4635809 6256068 6270645 8025633 8026567
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 * @modules jdk.javadoc
32 * @build JavadocTester
33 * @run main TestMemberInheritence
34 */
35
36public class TestMemberInheritence extends JavadocTester {
37
38    public static void main(String... args) throws Exception {
39        TestMemberInheritence tester = new TestMemberInheritence();
40        tester.runTests();
41    }
42
43    @Test
44    void test() {
45        javadoc("-d", "out",
46                "-sourcepath", testSrc,
47                "pkg", "diamond", "inheritDist", "pkg1");
48        checkExit(Exit.OK);
49
50        checkOutput("pkg/SubClass.html", true,
51                // Public field should be inherited
52                "<a href=\"../pkg/BaseClass.html#pubField\">",
53                // Public method should be inherited
54                "<a href=\"../pkg/BaseClass.html#pubMethod--\">",
55                // Public inner class should be inherited.
56                "<a href=\"../pkg/BaseClass.pubInnerClass.html\" title=\"class in pkg\">",
57                // Protected field should be inherited
58                "<a href=\"../pkg/BaseClass.html#proField\">",
59                // Protected method should be inherited
60                "<a href=\"../pkg/BaseClass.html#proMethod--\">",
61                // Protected inner class should be inherited.
62                "<a href=\"../pkg/BaseClass.proInnerClass.html\" title=\"class in pkg\">",
63                // New labels as of 1.5.0
64                "Nested classes/interfaces inherited from class&nbsp;pkg."
65                + "<a href=\"../pkg/BaseClass.html\" title=\"class in pkg\">BaseClass</a>",
66                "Nested classes/interfaces inherited from interface&nbsp;pkg."
67                + "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</a>");
68
69        checkOutput("pkg/BaseClass.html", true,
70                // Test overriding/implementing methods with generic parameters.
71                "<dl>\n"
72                + "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
73                + "<dd><code><a href=\"../pkg/BaseInterface.html#getAnnotation-java.lang.Class-\">"
74                + "getAnnotation</a></code>&nbsp;in interface&nbsp;<code>"
75                + "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">"
76                + "BaseInterface</a></code></dd>\n"
77                + "</dl>");
78
79        checkOutput("diamond/Z.html", true,
80                // Test diamond inheritence member summary (6256068)
81                "<code><a href=\"../diamond/A.html#aMethod--\">aMethod</a></code>");
82
83        checkOutput("inheritDist/C.html", true,
84                // Test that doc is inherited from closed parent (6270645)
85                "<div class=\"block\">m1-B</div>");
86
87        checkOutput("pkg/SubClass.html", false,
88                "<a href=\"../pkg/BaseClass.html#staticMethod--\">staticMethod</a></code>");
89
90        checkOutput("pkg1/Implementer.html", true,
91                // ensure the method makes it
92                "<td class=\"colFirst\"><code>static java.time.Period</code></td>\n"
93                + "<td class=\"colLast\"><code><span class=\"memberNameLink\">"
94                + "<a href=\"../pkg1/Implementer.html#between-java.time.LocalDate-java.time.LocalDate-\">"
95                + "between</a></span>(java.time.LocalDate&nbsp;startDateInclusive,\n"
96                + "       java.time.LocalDate&nbsp;endDateExclusive)</code>&nbsp;</td>",
97                // check the inherited from interfaces
98                "<h3>Methods inherited from interface&nbsp;pkg1.<a href=\"../pkg1/Interface.html\""
99                + " title=\"interface in pkg1\">Interface</a></h3>\n"
100                + "<code><a href=\"../pkg1/Interface.html#between-java.time.chrono.ChronoLocalDate"
101                + "-java.time.chrono.ChronoLocalDate-\">between</a></code>"
102        );
103    }
104}
105