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                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated(forRemoval=true)\n"
  86                 + "</span><span class=\"modifiers\">public</span>&nbsp;<span class=\"returnType\">int</span>"
  87                 + "&nbsp;<span class=\"memberName\">field</span></div>\n"
  88                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span></div>",
  89                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated(forRemoval=true)\n"
  90                 + "</span><span class=\"modifiers\">public</span>&nbsp;<span class=\"memberName\">DeprecatedClassByAnnotation</span>()</div>\n"
  91                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span></div>",
  92                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated\n"
  93                 + "</span><span class=\"modifiers\">public</span>&nbsp;<span class=\"returnType\">"
  94                 + "void</span>&nbsp;<span class=\"memberName\">method</span>()</div>\n"
  95                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated.</span></div>");
  96 
  97         checkOutput("pkg/TestAnnotationType.html", true,
  98                 "<hr>\n"
  99                 + "<pre>@Deprecated(forRemoval=true)\n"
 100                 + "@Documented\n"
 101                 + "public @interface <span class=\"memberNameLabel\">TestAnnotationType</span></pre>\n"
 102                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 103                 + "<div class=\"deprecationComment\">annotation_test1 passes.</div>\n"
 104                 + "</div>",
 105                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated(forRemoval=true)\n" +
 106                         "</span><span class=\"modifiers\">static final</span>&nbsp;<span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">field</span></div>\n"
 107                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This "
 108                 + "API element is subject to removal in a future version.</span>\n"
 109                 + "<div class=\"deprecationComment\">annotation_test4 passes.</div>\n"
 110                 + "</div>",
 111                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated(forRemoval=true)\n"
 112                 + "</span><span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">required</span></div>\n"
 113                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 114                 + "<div class=\"deprecationComment\">annotation_test3 passes.</div>\n"
 115                 + "</div>",
 116                 "<div class=\"memberSignature\"><span class=\"returnType\">java.lang.String</span>"
 117                 + "&nbsp;<span class=\"memberName\">optional</span></div>\n"
 118                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated.</span>\n"
 119                 + "<div class=\"deprecationComment\">annotation_test2 passes.</div>\n"
 120                 + "</div>");
 121 
 122         checkOutput("pkg/TestClass.html", true,
 123                 "<hr>\n"
 124                 + "<pre>@Deprecated(forRemoval=true)\n"
 125                 + "public class <span class=\"typeNameLabel\">TestClass</span>\n"
 126                 + "extends java.lang.Object</pre>\n"
 127                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 128                 + "<div class=\"deprecationComment\">class_test1 passes.</div>\n"
 129                 + "</div>",
 130                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated(forRemoval=true)\n"
 131                 + "</span><span class=\"modifiers\">public</span>&nbsp;<span class=\"memberName\">TestClass</span>()</div>\n"
 132                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 133                 + "<div class=\"deprecationComment\">class_test3 passes. This is the second sentence of deprecated description for a constructor.</div>\n"
 134                 + "</div>",
 135                 "<td class=\"colLast\">\n"
 136                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>\n"
 137                 + "<div class=\"deprecationComment\">class_test2 passes.</div>\n"
 138                 + "</div>\n"
 139                 + "</td>",
 140                 "<td class=\"colLast\">\n"
 141                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 142                 + "<div class=\"deprecationComment\">class_test3 passes.</div>\n"
 143                 + "</div>\n"
 144                 + "</td>",
 145                 "<td class=\"colLast\">\n"
 146                 + "<div class=\"block\"><span class=\"deprecatedLabel\">Deprecated.</span>\n"
 147                 + "<div class=\"deprecationComment\">class_test4 passes.</div>\n"
 148                 + "</div>\n"
 149                 + "</td>");
 150 
 151         checkOutput("pkg/TestClass.html", false,
 152                 "<div class=\"deprecationComment\">class_test2 passes. This is the second sentence of deprecated description for a field.</div>\n"
 153                 + "</div>\n"
 154                 + "</td>",
 155                 "<div class=\"deprecationComment\">class_test3 passes. This is the second sentence of deprecated description for a constructor.</div>\n"
 156                 + "</div>\n"
 157                 + "</td>",
 158                 "<div class=\"deprecationComment\">class_test4 passes. This is the second sentence of deprecated description for a method.</div>\n"
 159                 + "</div>\n"
 160                 + "</td>");
 161 
 162         checkOutput("pkg/TestEnum.html", true,
 163                 "<hr>\n"
 164                 + "<pre>@Deprecated(forRemoval=true)\n"
 165                 + "public enum <span class=\"typeNameLabel\">TestEnum</span>\n"
 166                 + "extends java.lang.Enum&lt;<a href=\"TestEnum.html\" title=\"enum in pkg\">TestEnum</a>&gt;</pre>\n"
 167                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 168                 + "<div class=\"deprecationComment\">enum_test1 passes.</div>\n"
 169                 + "</div>",
 170                 "<div class=\"memberSignature\"><span class=\"annotations\">@Deprecated(forRemoval=true)\n"
 171                 + "</span><span class=\"modifiers\">public static final</span>&nbsp;<span class=\"returnType\">"
 172                 + "<a href=\"TestEnum.html\" title=\"enum in pkg\">TestEnum</a></span>&nbsp;<span class=\"memberName\">FOR_REMOVAL</span></div>\n"
 173                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 174                 + "<div class=\"deprecationComment\">enum_test3 passes.</div>\n"
 175                 + "</div>");
 176 
 177         checkOutput("pkg/TestError.html", true,
 178                 "<hr>\n"
 179                 + "<pre>@Deprecated(forRemoval=true)\n"
 180                 + "public class <span class=\"typeNameLabel\">TestError</span>\n"
 181                 + "extends java.lang.Error</pre>\n"
 182                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 183                 + "<div class=\"deprecationComment\">error_test1 passes.</div>\n"
 184                 + "</div>");
 185 
 186         checkOutput("pkg/TestException.html", true,
 187                 "<hr>\n"
 188                 + "<pre>@Deprecated(forRemoval=true)\n"
 189                 + "public class <span class=\"typeNameLabel\">TestException</span>\n"
 190                 + "extends java.lang.Exception</pre>\n"
 191                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 192                 + "<div class=\"deprecationComment\">exception_test1 passes.</div>\n"
 193                 + "</div>");
 194 
 195         checkOutput("pkg/TestInterface.html", true,
 196                 "<hr>\n"
 197                 + "<pre>@Deprecated(forRemoval=true)\n"
 198                 + "public class <span class=\"typeNameLabel\">TestInterface</span>\n"
 199                 + "extends java.lang.Object</pre>\n"
 200                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal: This API element is subject to removal in a future version.</span>\n"
 201                 + "<div class=\"deprecationComment\">interface_test1 passes.</div>\n"
 202                 + "</div>");
 203 
 204         checkOutput("deprecated-list.html", true,
 205                 "<ul>\n"
 206                 + "<li><a href=\"#forRemoval\">For Removal</a></li>\n"
 207                 + "<li><a href=\"#class\">Classes</a></li>\n"
 208                 + "<li><a href=\"#enum\">Enums</a></li>\n"
 209                 + "<li><a href=\"#exception\">Exceptions</a></li>\n"
 210                 + "<li><a href=\"#error\">Errors</a></li>\n"
 211                 + "<li><a href=\"#annotation.type\">Annotation Types</a></li>\n"
 212                 + "<li><a href=\"#field\">Fields</a></li>\n"
 213                 + "<li><a href=\"#method\">Methods</a></li>\n"
 214                 + "<li><a href=\"#constructor\">Constructors</a></li>\n"
 215                 + "<li><a href=\"#enum.constant\">Enum Constants</a></li>\n"
 216                 + "<li><a href=\"#annotation.type.member\">Annotation Type Elements</a></li>\n"
 217                 + "</ul>",
 218                 "<a id=\"forRemoval\">",
 219                 "<div class=\"deprecatedSummary\">\n"
 220                 + "<table>\n"
 221                 + "<caption><span>For Removal</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
 222                 + "<thead>\n"
 223                 + "<tr>\n"
 224                 + "<th class=\"colFirst\" scope=\"col\">Element</th>\n"
 225                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
 226                 + "</tr>\n"
 227                 + "</thead>",
 228                 "<div class=\"deprecatedSummary\">\n"
 229                 + "<table>\n"
 230                 + "<caption><span>Enums</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
 231                 + "<thead>\n"
 232                 + "<tr>\n"
 233                 + "<th class=\"colFirst\" scope=\"col\">Enum</th>\n"
 234                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
 235                 + "</tr>\n"
 236                 + "</thead>\n"
 237                 + "<tbody>\n"
 238                 + "<tr class=\"altColor\">\n"
 239                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestEnum.html\" title=\"enum in pkg\">pkg.TestEnum</a></th>\n"
 240                 + "<td class=\"colLast\">\n"
 241                 + "<div class=\"deprecationComment\">enum_test1 passes.</div>\n"
 242                 + "</td>\n"
 243                 + "</tr>\n"
 244                 + "</tbody>\n"
 245                 + "</table>\n"
 246                 + "</div>",
 247                 "<div class=\"deprecatedSummary\">\n"
 248                 + "<table>\n"
 249                 + "<caption><span>Exceptions</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
 250                 + "<thead>\n"
 251                 + "<tr>\n"
 252                 + "<th class=\"colFirst\" scope=\"col\">Exceptions</th>\n"
 253                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
 254                 + "</tr>\n"
 255                 + "</thead>\n"
 256                 + "<tbody>\n"
 257                 + "<tr class=\"altColor\">\n"
 258                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestException.html\" title=\"class in pkg\">pkg.TestException</a></th>\n"
 259                 + "<td class=\"colLast\">\n"
 260                 + "<div class=\"deprecationComment\">exception_test1 passes.</div>\n"
 261                 + "</td>\n"
 262                 + "</tr>\n"
 263                 + "</tbody>\n"
 264                 + "</table>\n"
 265                 + "</div>",
 266                 "<div class=\"deprecatedSummary\">\n"
 267                 + "<table>\n"
 268                 + "<caption><span>Fields</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
 269                 + "<thead>\n"
 270                 + "<tr>\n"
 271                 + "<th class=\"colFirst\" scope=\"col\">Field</th>\n"
 272                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
 273                 + "</tr>\n"
 274                 + "</thead>\n"
 275                 + "<tbody>\n"
 276                 + "<tr class=\"altColor\">\n"
 277                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/DeprecatedClassByAnnotation.html#field\">pkg.DeprecatedClassByAnnotation.field</a></th>\n"
 278                 + "<td class=\"colLast\"></td>\n"
 279                 + "</tr>\n"
 280                 + "<tr class=\"rowColor\">\n"
 281                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestAnnotationType.html#field\">pkg.TestAnnotationType.field</a></th>\n"
 282                 + "<td class=\"colLast\">\n"
 283                 + "<div class=\"deprecationComment\">annotation_test4 passes.</div>\n"
 284                 + "</td>\n"
 285                 + "</tr>\n"
 286                 + "<tr class=\"altColor\">\n"
 287                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestClass.html#field\">pkg.TestClass.field</a></th>\n"
 288                 + "<td class=\"colLast\">\n"
 289                 + "<div class=\"deprecationComment\">class_test2 passes. This is the second sentence of deprecated description for a field.</div>\n"
 290                 + "</td>\n"
 291                 + "</tr>\n"
 292                 + "<tr class=\"rowColor\">\n"
 293                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestError.html#field\">pkg.TestError.field</a></th>\n"
 294                 + "<td class=\"colLast\">\n"
 295                 + "<div class=\"deprecationComment\">error_test2 passes.</div>\n"
 296                 + "</td>\n"
 297                 + "</tr>\n"
 298                 + "<tr class=\"altColor\">\n"
 299                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestException.html#field\">pkg.TestException.field</a></th>\n"
 300                 + "<td class=\"colLast\">\n"
 301                 + "<div class=\"deprecationComment\">exception_test2 passes.</div>\n"
 302                 + "</td>\n"
 303                 + "</tr>\n"
 304                 + "<tr class=\"rowColor\">\n"
 305                 + "<th class=\"colDeprecatedItemName\" scope=\"row\"><a href=\"pkg/TestInterface.html#field\">pkg.TestInterface.field</a></th>\n"
 306                 + "<td class=\"colLast\">\n"
 307                 + "<div class=\"deprecationComment\">interface_test2 passes.</div>\n"
 308                 + "</td>\n"
 309                 + "</tr>\n"
 310                 + "</tbody>\n"
 311                 + "</table>\n"
 312                 + "</div>");
 313     }
 314 }
--- EOF ---