1 /* 2 * Copyright (c) 2017, 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 8157000 8192850 8182765 27 * @summary test the behavior of --override-methods option 28 * @library ../../lib 29 * @modules jdk.javadoc/jdk.javadoc.internal.tool 30 * @build javadoc.tester.* 31 * @run main TestOverrideMethods 32 */ 33 34 import javadoc.tester.JavadocTester; 35 36 public class TestOverrideMethods extends JavadocTester { 37 public static void main(String... args) throws Exception { 38 TestOverrideMethods tester = new TestOverrideMethods(); 39 tester.runTests(); 40 } 41 42 @Test 43 public void testInvalidOption() { 44 // Make sure an invalid argument fails 45 javadoc("-d", "out-bad-option", 46 "-sourcepath", testSrc, 47 "-javafx", 48 "--disable-javafx-strict-checks", 49 "--override-methods=nonsense", 50 "pkg5"); 51 52 checkExit(Exit.CMDERR); 53 } 54 55 @Test 56 public void testDetail() { 57 // Make sure the option works 58 javadoc("-d", "out-detail", 59 "-sourcepath", testSrc, 60 "-javafx", 61 "--disable-javafx-strict-checks", 62 "--override-methods=detail", 63 "pkg5"); 64 65 checkExit(Exit.OK); 66 } 67 68 @Test 69 public void testSummary() { 70 javadoc("-d", "out-summary", 71 "-sourcepath", testSrc, 72 "-javafx", 73 "--disable-javafx-strict-checks", 74 "--override-methods=summary", 75 "pkg5", "pkg6"); 76 77 checkExit(Exit.OK); 78 79 checkOrder("pkg5/Classes.C.html", 80 // Check properties 81 "Properties declared in class pkg5.<a href=\"Classes.P.html", 82 "Classes.P", 83 "Classes.P.html#rateProperty\">rate", 84 85 // Check nested classes 86 "Nested classes/interfaces declared in class pkg5.", 87 "Classes.P", 88 "Classes.P.PN.html", 89 "Classes.P.PN.html", 90 "type parameter in Classes.P.PN\">K", 91 "type parameter in Classes.P.PN", 92 "V", 93 94 // Check fields 95 "Fields declared in class pkg5.<a href=\"Classes.P.html", 96 "Classes.P", 97 "Classes.P.html#field0\">field0", 98 99 // Check method summary 100 "Method Summary", 101 "void", 102 "#m1()\">m1", 103 "A modified method", 104 105 "void", 106 "#m4(java.lang.String,java.lang.String)\">m4", 107 "java.lang.String k,", 108 "java.lang.String", 109 " v)", 110 111 // Check footnotes 112 "Methods declared in class pkg5.<a href=\"Classes.GP.html", 113 "Classes.GP", 114 "Classes.GP.html#m0()\">m0", 115 116 // Check method details for override 117 "overrideSpecifyLabel", 118 "Overrides:", 119 "Classes.GP.html#m7()\">m7", 120 "in class", 121 "Classes.GP.html", 122 "Classes.GP" 123 ); 124 125 checkOrder("pkg5/Classes.C.html", 126 // Check footnotes 2 127 "Methods declared in class pkg5.", 128 "Classes.P.html#getRate()\">getRate", 129 "Classes.P.html#m2()\">m2", 130 "Classes.P.html#m3()\">m3", 131 "Classes.P.html#m4(K,V)\">m4", 132 "Classes.P.html#rateProperty()\">rateProperty", 133 "Classes.P.html#setRate(double)\">setRate", 134 135 // Check @link 136 "A test of links to the methods in this class. <p>\n", 137 "Classes.GP.html#m0()", 138 "Classes.GP.m0()", 139 "#m1()", 140 "m1()", 141 "Classes.P.html#m2()", 142 "Classes.P.m2()", 143 "Classes.P.html#m3()", 144 "Classes.P.m3()", 145 "m4(java.lang.String,java.lang.String)", 146 "Classes.P.html#m5()", 147 "Classes.P.m5()", 148 "#m6()", 149 "m6()", 150 "#m7()", 151 "m7()", 152 "End of links", 153 154 // Check @see 155 "See Also:", 156 "Classes.GP.html#m0()", 157 "Classes.GP.m0()", 158 "#m1()", 159 "m1()", 160 "Classes.P.html#m2()", 161 "Classes.P.m2()", 162 "Classes.P.html#m3()", 163 "Classes.P.m3()", 164 "#m4(java.lang.String,java.lang.String)", 165 "m4(String k, String v)", 166 "Classes.P.html#m5()\"><code>Classes.P.m5()", 167 "#m6()\"><code>m6()", 168 "#m7()\"><code>m7()" 169 ); 170 171 // Tests for interfaces 172 173 // Make sure the static methods in the super interface 174 // do not make it to this interface 175 checkOutput("pkg5/Interfaces.D.html", false, 176 "msd", "msn"); 177 178 checkOrder("pkg5/Interfaces.D.html", 179 "Start of links <p>", 180 "Interfaces.A.html#m0()\"><code>Interfaces.A.m0()", 181 "Interfaces.A.html#m1()\"><code>Interfaces.A.m1()", 182 "Interfaces.A.html#m2()\"><code>Interfaces.A.m2()", 183 "Interfaces.A.html#m3()\"><code>Interfaces.A.m3()", 184 "#m()\"><code>m()", 185 "#n()\"><code>n()", 186 "Interfaces.C.html#o()\"><code>Interfaces.C.o()", 187 "End of links", 188 189 // Check @see links 190 "See Also:", 191 "Interfaces.A.html#m0()\"><code>Interfaces.A.m0()", 192 "Interfaces.A.html#m1()\"><code>Interfaces.A.m1()", 193 "Interfaces.A.html#m2()\"><code>Interfaces.A.m2()", 194 "Interfaces.A.html#m3()\"><code>Interfaces.A.m3()", 195 "#m()\"><code>m()", 196 "#n()\"><code>n()", 197 "Interfaces.C.html#o()\"><code>Interfaces.C.o()", 198 199 // Check properties 200 "Properties declared in interface pkg5.<a href=\"Interfaces.A.html\" " 201 + "title=\"interface in pkg5\">Interfaces.A</a>", 202 203 // Check nested classes 204 "Nested classes/interfaces declared in interface pkg5.", 205 "Interfaces.A", 206 "Interfaces.A.AA.html", 207 "Interfaces.A.AA", 208 209 // Check Fields 210 "Fields declared in interface pkg5.<a href=\"Interfaces.A.html", 211 "Interfaces.A.html#f", 212 "Interfaces.A.html#QUOTE\">QUOTE", 213 "Interfaces.A.html#rate\">rate", 214 215 // Check Method Summary 216 "Method Summary", 217 "#m()\">m", 218 "#n()\">n", 219 220 // Check footnotes 221 "Methods declared in interface pkg5.<a href=\"Interfaces.A.html", 222 "Interfaces.A.html#getRate()\">getRate", 223 "Interfaces.A.html#rateProperty()\">rateProperty", 224 "Interfaces.A.html#setRate(double)", 225 "Methods declared in interface pkg5.<a href=\"Interfaces.B.html", 226 "Interfaces.B.html#m1()\">m1", 227 "Interfaces.B.html#m3()\">m3", 228 "Methods declared in interface pkg5.<a href=\"Interfaces.C.html", 229 "<a href=\"Interfaces.C.html#o()\">o</a>" 230 ); 231 232 // Test synthetic values and valuesof of an enum. 233 checkOrder("index-all.html", 234 "<h2 class=\"title\">M</h2>", 235 "<a href=\"pkg5/Interfaces.C.html#m()\">m()", 236 "<a href=\"pkg5/Interfaces.D.html#m()\">m()</a>", 237 "<a href=\"pkg5/Classes.GP.html#m0()\">m0()", 238 "<a href=\"pkg5/Interfaces.A.html#m0()\">m0()</a>", 239 "<a href=\"pkg5/Classes.C.html#m1()\">m1()</a>", 240 "<a href=\"pkg5/Classes.P.html#m1()\">m1()</a>", 241 "<a href=\"pkg5/Interfaces.A.html#m1()\">m1()</a>", 242 "<a href=\"pkg5/Interfaces.B.html#m1()\">m1()</a>", 243 "<a href=\"pkg5/Classes.P.html#m2()\">m2()</a>", 244 "<a href=\"pkg5/Interfaces.A.html#m2()\">m2()</a>", 245 "<a href=\"pkg5/Classes.P.html#m3()\">m3()</a>", 246 "<a href=\"pkg5/Interfaces.A.html#m3()\">m3()</a>", 247 "<a href=\"pkg5/Interfaces.B.html#m3()\">m3()</a>", 248 "<a href=\"pkg5/Classes.C.html#m4(java.lang.String,java.lang.String)\">m4(String, String)</a>", 249 "<a href=\"pkg5/Classes.P.html#m4(K,V)\">m4(K, V)</a>", 250 "<a href=\"pkg5/Classes.P.html#m5()\">m5()</a>", 251 "<a href=\"pkg5/Classes.C.html#m6()\">m6()</a>", 252 "<a href=\"pkg5/Classes.P.html#m6()\">m6()</a>", 253 "<a href=\"pkg5/Classes.C.html#m7()\">m7()</a>", 254 "<a href=\"pkg5/Classes.GP.html#m7()\">m7()</a>", 255 "Returns the enum constant of this type with the specified name.", 256 "Returns an array containing the constants of this enum type, in\n" + 257 "the order they are declared." 258 ); 259 260 // Check methods with covariant return types 261 // Only m2 should be shown in summary; m1 and m3 should listed as declared in Base 262 checkOutput("pkg6/Sub.html", true, 263 "<table aria-labelledby=\"t0\">\n" 264 + "<thead>\n" 265 + "<tr>\n" 266 + "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n" 267 + "<th class=\"colSecond\" scope=\"col\">Method</th>\n" 268 + "<th class=\"colLast\" scope=\"col\">Description</th>\n" 269 + "</tr>\n" 270 + "</thead>\n" 271 + "<tbody>\n" 272 + "<tr class=\"altColor\" id=\"i0\">\n" 273 + "<td class=\"colFirst\"><code>java.lang.String</code></td>\n" 274 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\"><a href=\"#m2()\">m2</a></span>()</code></th>\n" 275 + "<td class=\"colLast\">\n" 276 + "<div class=\"block\">This is Base::m2.</div>\n" 277 + "</td>\n" 278 + "</tr>\n" 279 + "</tbody>\n" 280 + "</table>\n", 281 "<div class=\"inheritedList\">\n" 282 + "<h3>Methods declared in class pkg6.<a href=\"Base.html\" title=\"class in pkg6\">Base</a></h3>\n" 283 + "<a id=\"methods.inherited.from.class.pkg6.Base\">\n" 284 + "<!-- -->\n" 285 + "</a><code><a href=\"Base.html#m1()\">m1</a>, <a href=\"Base.html#m3()\">m3</a></code></div>\n"); 286 } 287 }