test/com/sun/javadoc/testInterface/TestInterface.java

Wed, 01 Dec 2010 11:02:38 -0800

author
bpatel
date
Wed, 01 Dec 2010 11:02:38 -0800
changeset 766
90af8d87741f
parent 554
9d9f26857129
child 798
4868a36f6fd8
permissions
-rw-r--r--

6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2003, 2004, 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  */
    24 /*
    25  * @test
    26  * @bug      4682448 4947464 5029946
    27  * @summary  Verify that the public modifier does not show up in the
    28  *           documentation for public methods, as recommended by the JLS.
    29  *           If A implements I and B extends A, B should be in the list of
    30  *           implementing classes in the documentation for I.
    31  * @author   jamieh
    32  * @library  ../lib/
    33  * @build    JavadocTester
    34  * @build    TestInterface
    35  * @run main TestInterface
    36  */
    38 public class TestInterface extends JavadocTester {
    40     //Test information.
    41     private static final String BUG_ID = "4682448-4947464-5029946";
    43     //Javadoc arguments.
    44     private static final String[] ARGS = new String[] {
    45         "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
    46     };
    48     //Input for string search tests.
    49     private static final String[][] TEST = {
    50         {BUG_ID + FS + "pkg" + FS + "Interface.html",
    51             "<pre>int&nbsp;method()</pre>"},
    52         {BUG_ID + FS + "pkg" + FS + "Interface.html",
    53             "<pre>static final&nbsp;int field</pre>"},
    56         // Make sure known implementing class list is correct and omits type parameters.
    57         {BUG_ID + FS + "pkg" + FS + "Interface.html",
    58             "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
    59             "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child" +
    60             "</a>, <a href=\"../pkg/Parent.html\" title=\"class in pkg\">Parent" +
    61             "</a></dd>" + NL + "</dl>"},
    63          // Make sure "All Implemented Interfaces": has substituted type parameters
    64          {BUG_ID + FS + "pkg" + FS + "Child.html",
    65             "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
    66             "<dd><a href=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
    67             "Interface</a>&lt;T&gt;</dd>" + NL + "</dl>"
    68          },
    69          //Make sure Class Tree has substituted type parameters.
    70          {BUG_ID + FS + "pkg" + FS + "Child.html",
    71             "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL +
    72             "<li>" + NL + "<ul class=\"inheritance\">" + NL +
    73             "<li><a href=\"../pkg/Parent.html\" title=\"class in pkg\">" +
    74             "pkg.Parent</a>&lt;T&gt;</li>" + NL + "<li>" + NL +
    75             "<ul class=\"inheritance\">" + NL + "<li>pkg.Child&lt;T&gt;</li>" + NL +
    76             "</ul>" + NL + "</li>" + NL + "</ul>" + NL + "</li>" + NL + "</ul>"
    77          },
    78          //Make sure "Direct Know Subclasses" omits type parameters
    79         {BUG_ID + FS + "pkg" + FS + "Parent.html",
    80             "<dl>" + NL + "<dt>Direct Known Subclasses:</dt>" + NL +
    81             "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child" +
    82             "</a></dd>" + NL + "</dl>"
    83         },
    84         //Make sure "Specified By" has substituted type parameters.
    85         {BUG_ID + FS + "pkg" + FS + "Child.html",
    86             "<dt><strong>Specified by:</strong></dt>" + NL +
    87             "<dd><code><a href=\"../pkg/Interface.html#method()\">method</a>" +
    88             "</code>&nbsp;in interface&nbsp;<code>" +
    89             "<a href=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
    90             "Interface</a>&lt;<a href=\"../pkg/Child.html\" title=\"type parameter in Child\">" +
    91             "T</a>&gt;</code></dd>"
    92          },
    93         //Make sure "Overrides" has substituted type parameters.
    94         {BUG_ID + FS + "pkg" + FS + "Child.html",
    95             "<dt><strong>Overrides:</strong></dt>" + NL +
    96             "<dd><code><a href=\"../pkg/Parent.html#method()\">method</a>" +
    97             "</code>&nbsp;in class&nbsp;<code><a href=\"../pkg/Parent.html\" " +
    98             "title=\"class in pkg\">Parent</a>&lt;<a href=\"../pkg/Child.html\" " +
    99             "title=\"type parameter in Child\">T</a>&gt;</code></dd>"
   100          },
   101     };
   102     private static final String[][] NEGATED_TEST = {
   103         {BUG_ID + FS + "pkg" + FS + "Interface.html",
   104             "public int&nbsp;method()"},
   105         {BUG_ID + FS + "pkg" + FS + "Interface.html",
   106             "public static final&nbsp;int field"},
   107     };
   109     /**
   110      * The entry point of the test.
   111      * @param args the array of command line arguments.
   112      */
   113     public static void main(String[] args) {
   114         TestInterface tester = new TestInterface();
   115         run(tester, ARGS, TEST, NEGATED_TEST);
   116         tester.printSummary();
   117     }
   119     /**
   120      * {@inheritDoc}
   121      */
   122     public String getBugId() {
   123         return BUG_ID;
   124     }
   126     /**
   127      * {@inheritDoc}
   128      */
   129     public String getBugName() {
   130         return getClass().getName();
   131     }
   132 }

mercurial