1 /* 2 * Copyright (c) 2003, 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 4927552 8026567 8071982 8162674 8175200 8175218 8183511 8186332 27 * 8169819 8074407 8191030 8182765 8184205 28 * @summary test generated docs for deprecated items 29 * @author jamieh 30 * @library ../../lib 31 * @modules jdk.javadoc/jdk.javadoc.internal.tool 32 * @build javadoc.tester.* 33 * @run main TestDeprecatedDocs 34 */ 35 36 import javadoc.tester.JavadocTester; 37 38 public class TestDeprecatedDocs extends JavadocTester { 39 40 public static void main(String... args) throws Exception { 41 TestDeprecatedDocs tester = new TestDeprecatedDocs(); 42 tester.runTests(); 43 } 44 45 @Test 46 public void test() { 47 javadoc("-d", "out", 48 "-sourcepath", testSrc, 49 "pkg"); 50 checkExit(Exit.OK); 51 52 checkOutput("deprecated-list.html", true, 53 "annotation_test1 passes", 54 "annotation_test2 passes", 55 "annotation_test3 passes", 56 "annotation_test4 passes.", 57 "class_test1 passes", 58 "class_test2 passes", 59 "class_test3 passes", 60 "class_test4 passes", 61 "enum_test1 passes", 62 "enum_test2 passes", 63 "error_test1 passes", 64 "error_test2 passes", 65 "error_test3 passes", 66 "error_test4 passes", 67 "exception_test1 passes", 68 "exception_test2 passes", 69 "exception_test3 passes", 70 "exception_test4 passes", 71 "interface_test1 passes", 72 "interface_test2 passes", 73 "interface_test3 passes", 74 "interface_test4 passes", 75 "pkg.DeprecatedClassByAnnotation", 76 "pkg.DeprecatedClassByAnnotation()", 77 "pkg.DeprecatedClassByAnnotation.method()", 78 "pkg.DeprecatedClassByAnnotation.field" 79 ); 80 81 checkOutput("pkg/DeprecatedClassByAnnotation.html", true, 82 "<pre>@Deprecated\n" 83 + "public class <span class=\"typeNameLabel\">DeprecatedClassByAnnotation</span>\n" 84 + "extends java.lang.Object</pre>", 85 "<pre>@Deprecated(forRemoval=true)\n" 86 + "public int field</pre>\n" 87 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span></div>", 88 "<pre>@Deprecated(forRemoval=true)\n" 89 + "public DeprecatedClassByAnnotation()</pre>\n" 90 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span></div>", 91 "<pre>@Deprecated\n" 92 + "public void method()</pre>\n" 93 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated.</span></div>"); 94 95 checkOutput("pkg/TestAnnotationType.html", true, 96 "<hr>\n" 97 + "<pre>@Deprecated(forRemoval=true)\n" 98 + "@Documented\n" 99 + "public @interface <span class=\"memberNameLabel\">TestAnnotationType</span></pre>\n" 100 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 101 + "<div class=\"deprecationComment\">annotation_test1 passes.</div>\n" 102 + "</div>", 103 "<pre>@Deprecated(forRemoval=true)\n" 104 + "static final int field</pre>\n" 105 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This " 106 + "API element is subject to removal in a future version.</span>\n" 107 + "<div class=\"deprecationComment\">annotation_test4 passes.</div>\n" 108 + "</div>", 109 "<pre>@Deprecated(forRemoval=true)\n" 110 + "int required</pre>\n" 111 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 112 + "<div class=\"deprecationComment\">annotation_test3 passes.</div>\n" 113 + "</div>", 114 "<pre>java.lang.String optional</pre>\n" 115 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated.</span>\n" 116 + "<div class=\"deprecationComment\">annotation_test2 passes.</div>\n" 117 + "</div>"); 118 119 checkOutput("pkg/TestClass.html", true, 120 "<hr>\n" 121 + "<pre>@Deprecated(forRemoval=true)\n" 122 + "public class <span class=\"typeNameLabel\">TestClass</span>\n" 123 + "extends java.lang.Object</pre>\n" 124 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 125 + "<div class=\"deprecationComment\">class_test1 passes.</div>\n" 126 + "</div>", 127 "<pre>@Deprecated(forRemoval=true)\n" 128 + "public TestClass()</pre>\n" 129 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 130 + "<div class=\"deprecationComment\">class_test3 passes. This is the second sentence of deprecated description for a constructor.</div>\n" 131 + "</div>", 132 "<td class=\"colLast\">\n" 133 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>\n" 134 + "<div class=\"deprecationComment\">class_test2 passes.</div>\n" 135 + "</div>\n" 136 + "</td>", 137 "<td class=\"colLast\">\n" 138 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 139 + "<div class=\"deprecationComment\">class_test3 passes.</div>\n" 140 + "</div>\n" 141 + "</td>", 142 "<td class=\"colLast\">\n" 143 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>\n" 144 + "<div class=\"deprecationComment\">class_test4 passes.</div>\n" 145 + "</div>\n" 146 + "</td>"); 147 148 checkOutput("pkg/TestClass.html", false, 149 "<div class=\"deprecationComment\">class_test2 passes. This is the second sentence of deprecated description for a field.</div>\n" 150 + "</div>\n" 151 + "</td>", 152 "<div class=\"deprecationComment\">class_test3 passes. This is the second sentence of deprecated description for a constructor.</div>\n" 153 + "</div>\n" 154 + "</td>", 155 "<div class=\"deprecationComment\">class_test4 passes. This is the second sentence of deprecated description for a method.</div>\n" 156 + "</div>\n" 157 + "</td>"); 158 159 checkOutput("pkg/TestEnum.html", true, 160 "<hr>\n" 161 + "<pre>@Deprecated(forRemoval=true)\n" 162 + "public enum <span class=\"typeNameLabel\">TestEnum</span>\n" 163 + "extends java.lang.Enum<<a href=\"TestEnum.html\" title=\"enum in pkg\">TestEnum</a>></pre>\n" 164 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 165 + "<div class=\"deprecationComment\">enum_test1 passes.</div>\n" 166 + "</div>", 167 "<pre>@Deprecated(forRemoval=true)\n" 168 + "public static final <a href=\"TestEnum.html\" title=\"enum in pkg\">TestEnum</a> FOR_REMOVAL</pre>\n" 169 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 170 + "<div class=\"deprecationComment\">enum_test3 passes.</div>\n" 171 + "</div>"); 172 173 checkOutput("pkg/TestError.html", true, 174 "<hr>\n" 175 + "<pre>@Deprecated(forRemoval=true)\n" 176 + "public class <span class=\"typeNameLabel\">TestError</span>\n" 177 + "extends java.lang.Error</pre>\n" 178 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 179 + "<div class=\"deprecationComment\">error_test1 passes.</div>\n" 180 + "</div>"); 181 182 checkOutput("pkg/TestException.html", true, 183 "<hr>\n" 184 + "<pre>@Deprecated(forRemoval=true)\n" 185 + "public class <span class=\"typeNameLabel\">TestException</span>\n" 186 + "extends java.lang.Exception</pre>\n" 187 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 188 + "<div class=\"deprecationComment\">exception_test1 passes.</div>\n" 189 + "</div>"); 190 191 checkOutput("pkg/TestInterface.html", true, 192 "<hr>\n" 193 + "<pre>@Deprecated(forRemoval=true)\n" 194 + "public class <span class=\"typeNameLabel\">TestInterface</span>\n" 195 + "extends java.lang.Object</pre>\n" 196 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n" 197 + "<div class=\"deprecationComment\">interface_test1 passes.</div>\n" 198 + "</div>"); 199 200 checkOutput("deprecated-list.html", true, 201 "<ul>\n" 202 + "<li><a href=\"#forRemoval\">For Removal</a></li>\n" 203 + "<li><a href=\"#class\">Classes</a></li>\n" 204 + "<li><a href=\"#enum\">Enums</a></li>\n" 205 + "<li><a href=\"#exception\">Exceptions</a></li>\n" 206 + "<li><a href=\"#error\">Errors</a></li>\n" 207 + "<li><a href=\"#annotation.type\">Annotation Types</a></li>\n" 208 + "<li><a href=\"#field\">Fields</a></li>\n" 209 + "<li><a href=\"#method\">Methods</a></li>\n" 210 + "<li><a href=\"#constructor\">Constructors</a></li>\n" 211 + "<li><a href=\"#enum.constant\">Enum Constants</a></li>\n" 212 + "<li><a href=\"#annotation.type.member\">Annotation Type Elements</a></li>\n" 213 + "</ul>", 214 "<a id=\"forRemoval\">", 215 "<div class=\"deprecatedSummary\">\n" 216 + "<table>\n" 217 + "<caption><span>For Removal</span><span class=\"tabEnd\"> </span></caption>\n" 218 + "<thead>\n" 219 + "<tr>\n" 220 + "<th class=\"colFirst\" scope=\"col\">Element</th>\n" 221 + "<th class=\"colLast\" scope=\"col\">Description</th>\n" 222 + "</tr>\n" 223 + "</thead>", 224 "<div class=\"deprecatedSummary\">\n" 225 + "<table>\n" 226 + "<caption><span>Enums</span><span class=\"tabEnd\"> </span></caption>\n" 227 + "<thead>\n" 228 + "<tr>\n" 229 + "<th class=\"colFirst\" scope=\"col\">Enum</th>\n" 230 + "<th class=\"colLast\" scope=\"col\">Description</th>\n" 231 + "</tr>\n" 232 + "</thead>\n" 233 + "<tbody>\n" 234 + "<tr class=\"altColor\">\n" 235 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestEnum.html\" title=\"enum in pkg\">pkg.TestEnum</a></th>\n" 236 + "<td class=\"colLast\">\n" 237 + "<div class=\"deprecationComment\">enum_test1 passes.</div>\n" 238 + "</td>\n" 239 + "</tr>\n" 240 + "</tbody>\n" 241 + "</table>\n" 242 + "</div>", 243 "<div class=\"deprecatedSummary\">\n" 244 + "<table>\n" 245 + "<caption><span>Exceptions</span><span class=\"tabEnd\"> </span></caption>\n" 246 + "<thead>\n" 247 + "<tr>\n" 248 + "<th class=\"colFirst\" scope=\"col\">Exceptions</th>\n" 249 + "<th class=\"colLast\" scope=\"col\">Description</th>\n" 250 + "</tr>\n" 251 + "</thead>\n" 252 + "<tbody>\n" 253 + "<tr class=\"altColor\">\n" 254 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestException.html\" title=\"class in pkg\">pkg.TestException</a></th>\n" 255 + "<td class=\"colLast\">\n" 256 + "<div class=\"deprecationComment\">exception_test1 passes.</div>\n" 257 + "</td>\n" 258 + "</tr>\n" 259 + "</tbody>\n" 260 + "</table>\n" 261 + "</div>", 262 "<div class=\"deprecatedSummary\">\n" 263 + "<table>\n" 264 + "<caption><span>Fields</span><span class=\"tabEnd\"> </span></caption>\n" 265 + "<thead>\n" 266 + "<tr>\n" 267 + "<th class=\"colFirst\" scope=\"col\">Field</th>\n" 268 + "<th class=\"colLast\" scope=\"col\">Description</th>\n" 269 + "</tr>\n" 270 + "</thead>\n" 271 + "<tbody>\n" 272 + "<tr class=\"altColor\">\n" 273 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/DeprecatedClassByAnnotation.html#field\">pkg.DeprecatedClassByAnnotation.field</a></th>\n" 274 + "<td class=\"colLast\"></td>\n" 275 + "</tr>\n" 276 + "<tr class=\"rowColor\">\n" 277 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestAnnotationType.html#field\">pkg.TestAnnotationType.field</a></th>\n" 278 + "<td class=\"colLast\">\n" 279 + "<div class=\"deprecationComment\">annotation_test4 passes.</div>\n" 280 + "</td>\n" 281 + "</tr>\n" 282 + "<tr class=\"altColor\">\n" 283 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestClass.html#field\">pkg.TestClass.field</a></th>\n" 284 + "<td class=\"colLast\">\n" 285 + "<div class=\"deprecationComment\">class_test2 passes. This is the second sentence of deprecated description for a field.</div>\n" 286 + "</td>\n" 287 + "</tr>\n" 288 + "<tr class=\"rowColor\">\n" 289 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestError.html#field\">pkg.TestError.field</a></th>\n" 290 + "<td class=\"colLast\">\n" 291 + "<div class=\"deprecationComment\">error_test2 passes.</div>\n" 292 + "</td>\n" 293 + "</tr>\n" 294 + "<tr class=\"altColor\">\n" 295 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestException.html#field\">pkg.TestException.field</a></th>\n" 296 + "<td class=\"colLast\">\n" 297 + "<div class=\"deprecationComment\">exception_test2 passes.</div>\n" 298 + "</td>\n" 299 + "</tr>\n" 300 + "<tr class=\"rowColor\">\n" 301 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestInterface.html#field\">pkg.TestInterface.field</a></th>\n" 302 + "<td class=\"colLast\">\n" 303 + "<div class=\"deprecationComment\">interface_test2 passes.</div>\n" 304 + "</td>\n" 305 + "</tr>\n" 306 + "</tbody>\n" 307 + "</table>\n" 308 + "</div>"); 309 } 310 }