test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java

Wed, 18 Sep 2013 22:47:06 -0700

author
bpatel
date
Wed, 18 Sep 2013 22:47:06 -0700
changeset 2036
8df12c315ea3
parent 1935
8c55df2442c1
child 2101
933ba3f81a87
permissions
-rw-r--r--

8024096: some javadoc tests may contain false positive results
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2009, 2013, 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.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 /*
    27  * @test
    28  * @bug 6786690 6820360
    29  * @summary This test verifies the nesting of definition list tags.
    30  * @author Bhavesh Patel
    31  * @library ../lib/
    32  * @build JavadocTester TestHtmlDefinitionListTag
    33  * @run main TestHtmlDefinitionListTag
    34  */
    36 public class TestHtmlDefinitionListTag extends JavadocTester {
    38     private static final String BUG_ID = "6786690-6820360";
    40     // Test common to all runs of javadoc. The class signature should print
    41     // properly enclosed definition list tags and the Annotation Type
    42     // Optional Element should print properly nested definition list tags
    43     // for default value.
    44     private static final String[][] TEST_ALL = {
    45         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<pre>public class " +
    46                  "<span class=\"strong\">C1</span>" + NL +
    47                  "extends java.lang.Object" + NL + "implements java.io.Serializable</pre>"},
    48         {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl>" + NL +
    49                  "<dt>Default:</dt>" + NL + "<dd>true</dd>" + NL +
    50                  "</dl>"}};
    52     // Test for normal run of javadoc in which various ClassDocs and
    53     // serialized form should have properly nested definition list tags
    54     // enclosing comments, tags and deprecated information.
    55     private static final String[][] TEST_CMNT_DEPR = {
    56         {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" + NL +
    57                  "<dt><span class=\"strong\">Since:</span></dt>" + NL +
    58                  "<dd>JDK1.0</dd>" + NL + "</dl>"},
    59         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
    60                  "<dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:</span></dt>" + NL +
    61                  "<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\"><code>" +
    62                  "C2</code></a>, " + NL + "<a href=\"../serialized-form.html#pkg1.C1\">" +
    63                  "Serialized Form</a></dd>" + NL + "</dl>"},
    64         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
    65                  "<dd>1.4</dd>" + NL +
    66                  "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd>" +
    67                  "<a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
    68                  "<code>setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
    69         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>"+ NL + "<dt><span class=\"strong\">Parameters:</span></dt>" + NL + "<dd><code>title" +
    70                  "</code> - the title</dd>" + NL + "<dd><code>test</code> - boolean value" +
    71                  "</dd>" + NL + "<dt><span class=\"strong\">Throws:</span></dt>" + NL +
    72                  "<dd><code>java.lang.IllegalArgumentException</code> - if the " +
    73                  "<code>owner</code>'s" + NL +
    74                  "     <code>GraphicsConfiguration</code> is not from a screen " +
    75                  "device</dd>" + NL + "<dd><code>HeadlessException</code></dd>" + NL + "</dl>"},
    76         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:</span></dt>" + NL + "<dd><code>undecorated" +
    77                  "</code> - <code>true</code> if no decorations are" + NL +
    78                  "         to be enabled;" + NL + "         <code>false</code> " +
    79                  "if decorations are to be enabled.</dd>" + NL + "<dt><span class=\"strong\">Since:" +
    80                  "</span></dt>" + NL + "<dd>1.4</dd>" + NL +
    81                  "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd>" +
    82                  "<a href=\"../pkg1/C1.html#readObject()\"><code>readObject()" +
    83                  "</code></a></dd>" + NL + "</dl>"},
    84         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span></dt>" + NL +
    85                  "<dd><code>java.io.IOException</code></dd>" + NL + "<dt><span class=\"strong\">See Also:" +
    86                  "</span></dt>" + NL + "<dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
    87                  "<code>setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
    88         {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:" +
    89                  "</span></dt>" + NL + "<dd><code>set</code> - boolean</dd>" + NL + "<dt><span class=\"strong\">" +
    90                  "Since:</span></dt>" + NL + "<dd>1.4</dd>" + NL + "</dl>"},
    91         {BUG_ID + FS + "serialized-form.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span>" +
    92                  "</dt>" + NL + "<dd><code>" +
    93                  "java.io.IOException</code></dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
    94                  "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
    95                  "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
    96         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
    97                  "&nbsp;<span class=\"italic\">As of JDK version 1.5, replaced by" + NL +
    98                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
    99                  "<code>setUndecorated(boolean)</code></a>.</span></div>" + NL +
   100                  "<div class=\"block\">This field indicates whether the C1 is " +
   101                  "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
   102                  "<dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
   103                  "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   104                  "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
   105         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
   106                  "&nbsp;<span class=\"italic\">As of JDK version 1.5, replaced by" + NL +
   107                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   108                  "<code>setUndecorated(boolean)</code></a>.</span></div>" + NL +
   109                  "<div class=\"block\">Reads the object stream.</div>" + NL +
   110                  "<dl>" + NL + "<dt><span class=\"strong\">Throws:" +
   111                  "</span></dt>" + NL + "<dd><code><code>" +
   112                  "IOException</code></code></dd>" + NL +
   113                  "<dd><code>java.io.IOException</code></dd>" + NL + "</dl>"},
   114         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
   115                  "&nbsp;</div>" + NL +
   116                  "<div class=\"block\">The name for this class.</div>"}};
   118     // Test with -nodeprecated option. The ClassDocs should have properly nested
   119     // definition list tags enclosing comments and tags. The ClassDocs should not
   120     // display definition list for deprecated information. The serialized form
   121     // should display properly nested definition list tags for comments, tags
   122     // and deprecated information.
   123     private static final String[][] TEST_NODEPR = {
   124         {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" + NL +
   125                  "<dt><span class=\"strong\">Since:</span></dt>" + NL +
   126                  "<dd>JDK1.0</dd>" + NL + "</dl>"},
   127         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Since:</span>" +
   128                  "</dt>" + NL + "<dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:" +
   129                  "</span></dt>" + NL + "<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
   130                  "<code>C2</code></a>, " + NL + "<a href=\"../serialized-form.html#pkg1.C1\">" +
   131                  "Serialized Form</a></dd>" + NL + "</dl>"},
   132         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:" +
   133                  "</span></dt>" + NL + "<dd><code>title</code> - the title</dd>" + NL + "<dd><code>" +
   134                  "test</code> - boolean value</dd>" + NL + "<dt><span class=\"strong\">Throws:" +
   135                  "</span></dt>" + NL + "<dd><code>java.lang.IllegalArgumentException" +
   136                  "</code> - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
   137                  "</code> is not from a screen device</dd>" + NL + "<dd><code>" +
   138                  "HeadlessException</code></dd>" + NL + "</dl>"},
   139         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Parameters:" +
   140                  "</span></dt>" + NL + "<dd><code>undecorated</code> - <code>true</code>" +
   141                  " if no decorations are" + NL + "         to be enabled;" + NL +
   142                  "         <code>false</code> if decorations are to be enabled." +
   143                  "</dd>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL + "<dd>1.4</dd>" + NL +
   144                  "<dt><span class=\"strong\">See Also:</span></dt>" + NL + "<dd><a href=\"../pkg1/C1.html#readObject()\">" +
   145                  "<code>readObject()</code></a></dd>" + NL + "</dl>"},
   146         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span>" +
   147                  "</dt>" + NL + "<dd><code>java.io.IOException</code></dd>" + NL + "<dt>" +
   148                  "<span class=\"strong\">See Also:</span></dt>" + NL + "<dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
   149                  "<code>setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
   150         {BUG_ID + FS + "serialized-form.html", "<dl>" + NL + "<dt><span class=\"strong\">Throws:</span>" +
   151                  "</dt>" + NL + "<dd><code>" +
   152                  "java.io.IOException</code></dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
   153                  "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   154                  "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
   155         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
   156                  "&nbsp;<span class=\"italic\">As of JDK version 1.5, replaced by" + NL +
   157                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   158                  "<code>setUndecorated(boolean)</code></a>.</span></div>" + NL +
   159                  "<div class=\"block\">This field indicates whether the C1 is " +
   160                  "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl>" + NL + "<dt><span class=\"strong\">Since:</span></dt>" + NL +
   161                  "<dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
   162                  "</dt>" + NL + "<dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   163                  "<code>C1.setUndecorated(boolean)</code></a></dd>" + NL + "</dl>"},
   164         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
   165                  "&nbsp;<span class=\"italic\">As of JDK version 1.5, replaced by" + NL +
   166                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   167                  "<code>setUndecorated(boolean)</code></a>.</span></div>" + NL +
   168                  "<div class=\"block\">Reads the object stream.</div>" + NL +
   169                  "<dl>" + NL + "<dt><span class=\"strong\">Throws:" +
   170                  "</span></dt>" + NL + "<dd><code><code>" +
   171                  "IOException</code></code></dd>" + NL +
   172                  "<dd><code>java.io.IOException</code></dd>" + NL + "</dl>"},
   173         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
   174                  "&nbsp;</div>" + NL + "<div class=\"block\">" +
   175                  "The name for this class.</div>"}};
   177     // Test with -nocomment and -nodeprecated options. The ClassDocs whould
   178     // not display definition lists for any member details.
   179     private static final String[][] TEST_NOCMNT_NODEPR = {
   180         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<pre>public&nbsp;void&nbsp;readObject()" + NL +
   181                  "                throws java.io.IOException</pre>" + NL + "</li>"},
   182         {BUG_ID + FS + "pkg1" + FS + "C2.html", "<pre>public&nbsp;C2()</pre>" + NL +
   183                  "</li>"},
   184         {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<pre>public " +
   185                  "static final&nbsp;<a href=\"../pkg1/C1.ModalExclusionType.html\" " +
   186                  "title=\"enum in pkg1\">C1.ModalExclusionType</a> " +
   187                  "APPLICATION_EXCLUDE</pre>" + NL + "</li>"},
   188         {BUG_ID + FS + "serialized-form.html", "<pre>boolean " +
   189                  "undecorated</pre>" + NL + "<div class=\"block\"><span class=\"strong\">" +
   190                  "Deprecated.</span>&nbsp;<span class=\"italic\">As of JDK version 1.5, replaced by" + NL +
   191                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\"><code>" +
   192                  "setUndecorated(boolean)</code></a>.</span></div>" + NL + "</li>"},
   193         {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">" +
   194                  "Deprecated.</span>&nbsp;<span class=\"italic\">As of JDK version" +
   195                  " 1.5, replaced by" + NL +
   196                  " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
   197                  "<code>setUndecorated(boolean)</code></a>.</span></div>" + NL + "</li>"}};
   199     // Test for valid HTML generation which should not comprise of empty
   200     // definition list tags.
   201     private static final String[][] NEGATED_TEST = {
   202         {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl></dl>"},
   203         {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" + NL + "</dl>"},
   204         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl></dl>"},
   205         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "</dl>"},
   206         {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<dl></dl>"},
   207         {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<dl>" + NL + "</dl>"},
   208         {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl></dl>"},
   209         {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl>" + NL + "</dl>"},
   210         {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<dl></dl>"},
   211         {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<dl>" + NL + "</dl>"},
   212         {BUG_ID + FS + "pkg1" + FS + "C3.html", "<dl></dl>"},
   213         {BUG_ID + FS + "pkg1" + FS + "C3.html", "<dl>" + NL + "</dl>"},
   214         {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl></dl>"},
   215         {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl>" + NL + "</dl>"},
   216         {BUG_ID + FS + "pkg1" + FS + "C5.html", "<dl></dl>"},
   217         {BUG_ID + FS + "pkg1" + FS + "C5.html", "<dl>" + NL + "</dl>"},
   218         {BUG_ID + FS + "overview-tree.html", "<dl></dl>"},
   219         {BUG_ID + FS + "overview-tree.html", "<dl>" + NL + "</dl>"},
   220         {BUG_ID + FS + "serialized-form.html", "<dl></dl>"},
   221         {BUG_ID + FS + "serialized-form.html", "<dl>" + NL + "</dl>"}};
   223     private static final String[] ARGS1 =
   224         new String[] {
   225             "-Xdoclint:none", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
   227     private static final String[] ARGS2 =
   228         new String[] {
   229             "-Xdoclint:none", "-d", BUG_ID, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
   231     private static final String[] ARGS3 =
   232         new String[] {
   233             "-Xdoclint:none", "-d", BUG_ID, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
   235     private static final String[] ARGS4 =
   236         new String[] {
   237             "-Xdoclint:none", "-d", BUG_ID, "-nocomment", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
   239     /**
   240      * The entry point of the test.
   241      * @param args the array of command line arguments.
   242      */
   243     public static void main(String[] args) {
   244         TestHtmlDefinitionListTag tester = new TestHtmlDefinitionListTag();
   245         tester.exactNewlineMatch = false;
   246         run(tester, ARGS1, TEST_ALL, NEGATED_TEST);
   247         run(tester, ARGS1, TEST_CMNT_DEPR, NEGATED_TEST);
   248         run(tester, ARGS2, TEST_ALL, NEGATED_TEST);
   249         run(tester, ARGS2, NO_TEST, TEST_CMNT_DEPR);
   250         run(tester, ARGS3, TEST_ALL, NEGATED_TEST);
   251         run(tester, ARGS3, TEST_NODEPR, TEST_NOCMNT_NODEPR);
   252         run(tester, ARGS4, TEST_ALL, NEGATED_TEST);
   253         run(tester, ARGS4, TEST_NOCMNT_NODEPR, TEST_CMNT_DEPR);
   254         tester.printSummary();
   255     }
   257     /**
   258      * {@inheritDoc}
   259      */
   260     public String getBugId() {
   261         return BUG_ID;
   262     }
   264     /**
   265      * {@inheritDoc}
   266      */
   267     public String getBugName() {
   268         return getClass().getName();
   269     }
   270 }

mercurial