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