1 /*
   2  * Copyright (c) 2004, 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      4973609 8015249 8025633 8026567 6469561 8071982 8162363 8182765
  27  * @summary  Make sure that annotation types with 0 members does not have
  28  *           extra HR tags.
  29  * @author   jamieh
  30  * @library  ../../lib
  31  * @modules jdk.javadoc/jdk.javadoc.internal.tool
  32  * @build    javadoc.tester.*
  33  * @run main TestAnnotationTypes
  34  */
  35 
  36 import javadoc.tester.JavadocTester;
  37 
  38 public class TestAnnotationTypes extends JavadocTester {
  39 
  40     public static void main(String... args) throws Exception {
  41         TestAnnotationTypes tester = new TestAnnotationTypes();
  42         tester.runTests();
  43     }
  44 
  45     @Test
  46     public void test() {
  47         javadoc("-d", "out-1",
  48                 "-sourcepath", testSrc,
  49                 "pkg");
  50         checkExit(Exit.OK);
  51 
  52         checkOutput("pkg/AnnotationTypeField.html", true,
  53                 "<li>Summary:&nbsp;</li>\n"
  54                 + "<li><a href=\"#annotation.type."
  55                 + "field.summary\">Field</a>&nbsp;|&nbsp;</li>",
  56                 "<li>Detail:&nbsp;</li>\n"
  57                 + "<li><a href=\"#annotation.type."
  58                 + "field.detail\">Field</a>&nbsp;|&nbsp;</li>",
  59                 "<!-- =========== ANNOTATION TYPE FIELD SUMMARY =========== -->",
  60                 "<h2>Field Summary</h2>",
  61                 "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\"><a href=\"#DEFAULT_NAME\">DEFAULT_NAME</a></span>"
  62                 + "</code></th>",
  63                 "<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== -->",
  64                 "<h3>DEFAULT_NAME</h3>\n"
  65                 + "<a id=\"DEFAULT_NAME\">\n"
  66                 + "<!--   -->\n"
  67                 + "</a>\n"
  68                 + "<div class=\"memberSignature\"><span class=\"modifiers\">static final</span>&nbsp;"
  69                 + "<span class=\"returnType\">java.lang.String</span>&nbsp;"
  70                 + "<span class=\"memberName\">DEFAULT_NAME</span></div>\n");
  71 
  72         checkOutput("pkg/AnnotationType.html", true,
  73                 "<li>Summary:&nbsp;</li>\n"
  74                 + "<li>Field&nbsp;|&nbsp;</li>",
  75                 "<li>Detail:&nbsp;</li>\n"
  76                 + "<li>Field&nbsp;|&nbsp;</li>");
  77 
  78         checkOutput("pkg/AnnotationType.html", true,
  79                     "<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->",
  80                     "<ul class=\"blockList\">",
  81                     "<li class=\"blockList\">",
  82                     "<section class=\"memberDetails\">",
  83                     "<h2>Element Details</h2>",
  84                     "<a id=\"annotation.type.element.detail\">",
  85                     "<!--   -->",
  86                     "</a>",
  87                     "<ul class=\"blockList\">",
  88                     "<li class=\"blockListLast\">",
  89                     "<section class=\"detail\">",
  90                     "<h3>value</h3>",
  91                     "<a id=\"value()\">",
  92                     "<!--   -->",
  93                     "</a>",
  94                     "<div class=\"memberSignature\"><span class=\"returnType\">int</span>"
  95                     + "&nbsp;<span class=\"memberName\">value</span></div>");
  96 
  97         checkOutput("pkg/AnnotationType.html", false,
  98                 "<HR>\n\n"
  99                 + "<P>\n\n"
 100                 + "<P>"
 101                 + "<!-- ========= END OF CLASS DATA ========= -->" + "<HR>");
 102     }
 103 
 104     @Test
 105     public void testLinkSource() {
 106         javadoc("-d", "out-2",
 107                 "-linksource",
 108                 "-sourcepath", testSrc,
 109                 "pkg");
 110         checkExit(Exit.OK);
 111 
 112         checkOutput("src-html/pkg/AnnotationType.html", true,
 113                 "<title>Source code</title>",
 114                 "@Documented public @interface AnnotationType {");
 115 
 116         checkOutput("src-html/pkg/AnnotationTypeField.html", true,
 117                 "<title>Source code</title>",
 118                 "@Documented public @interface AnnotationTypeField {");
 119 
 120         checkOutput("pkg/AnnotationType.html", true,
 121                 "public @interface <a href=\"../src-html/pkg/AnnotationType.html#line.34"
 122                 + "\">AnnotationType</a></pre>");
 123 
 124         checkOutput("pkg/AnnotationTypeField.html", true,
 125                 "public @interface <a href=\"../src-html/pkg/AnnotationTypeField.html#line.31"
 126                 + "\">AnnotationTypeField</a></pre>");
 127     }
 128 }