test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 766
90af8d87741f
child 1858
27bd6a2302f6
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

     1 /*
     2  * Copyright (c) 2003, 2010, 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      4780441 4874845 4978816
    27  * @summary  Make sure that when the -private flag is not used, members
    28  *           inherited from package private class are documented in the child.
    29  *
    30  *           Make sure that when a method inherits documentation from a method
    31  *           in a non-public class/interface, the non-public class/interface
    32  *           is not mentioned anywhere (not even in the signature or tree).
    33  *
    34  *           Make sure that when a private interface method with generic parameters
    35  *           is implemented, the comments can be inherited properly.
    36  * @author   jamieh
    37  * @library  ../lib/
    38  * @build    JavadocTester
    39  * @build    TestPrivateClasses
    40  * @run main TestPrivateClasses
    41  */
    43 public class TestPrivateClasses extends JavadocTester {
    45     //Test information.
    46     private static final String BUG_ID = "4780441-4874845-4978816";
    48     //Javadoc arguments.
    49     private static final String[] ARGS1 = new String[] {
    50         "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2"
    51     };
    52     private static final String[] ARGS2 = new String[] {
    53         "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private",
    54             "-source", "1.5", "pkg", "pkg2"
    55     };
    57     // Test output when -private flag is not used.
    58     private static final String[][] TEST1 = {
    59         // Field inheritence from non-public superclass.
    60         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
    61             "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
    62                 "fieldInheritedFromParent</a>"
    63         },
    65         // Method inheritence from non-public superclass.
    66         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
    67             "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" +
    68                 "methodInheritedFromParent</a>"
    69         },
    71         // Field inheritence from non-public superinterface.
    72         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
    73             "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
    74                 "fieldInheritedFromInterface</a>"
    75         },
    77         // Method inheritence from non-public superinterface.
    78         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
    79             "<a href=\"../pkg/PublicInterface.html#methodInterface(int)\">" +
    80                 "methodInterface</a>"
    81         },
    83         // private class does not show up in tree
    84         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
    85             "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL +
    86             "<li>" + NL + "<ul class=\"inheritance\">" + NL + "<li>pkg.PublicChild</li>" + NL +
    87             "</ul>" + NL + "</li>" + NL + "</ul>"
    88         },
    90         // Method is documented as though it is declared in the inheriting method.
    91         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
    92             "<pre>public&nbsp;void&nbsp;methodInheritedFromParent(int&nbsp;p1)"
    93         },
    95         //Make sure implemented interfaces from private superclass are inherited
    96         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
    97             "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
    98             "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" +
    99             "PublicChild</a></dd>" + NL + "</dl>"},
   101         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
   102             "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
   103             "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
   104             "PublicInterface</a></dd>" + NL + "</dl>"},
   106         //Generic interface method test.
   107         {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
   108             "This comment should get copied to the implementing class"},
   109     };
   110     private static final String[][] NEGATED_TEST1 = {
   111        // Should not document that a method overrides method from private class.
   112       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
   113         "<strong>Overrides:</strong>"},
   114       // Should not document that a method specified by private interface.
   115       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
   116         "<strong>Specified by:</strong>"},
   117       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
   118         "<strong>Specified by:</strong>"},
   119       // Should not mention that any documentation was copied.
   120       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
   121         "Description copied from"},
   122       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
   123         "Description copied from"},
   124       // Don't extend private classes or interfaces
   125       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
   126         "PrivateParent"},
   127       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
   128         "PrivateInterface"},
   129       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
   130         "PrivateInterface"},
   131       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
   132         "All Superinterfaces"},
   133       // Make inherited constant are documented correctly.
   134       {BUG_ID + "-1" + FS + "constant-values.html",
   135         "PrivateInterface"},
   137         //Do not inherit private interface method with generic parameters.
   138         //This method has been implemented.
   139         {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
   140             "<strong><a href=\"../pkg2/I.html#hello(T)\">hello</a></strong>"},
   141     };
   143     // Test output when -private flag is used.
   144     private static final String[][] TEST2 = {
   145         // Field inheritence from non-public superclass.
   146         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   147             "Fields inherited from class&nbsp;pkg." +
   148             "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
   149             "PrivateParent</a>"
   150         },
   151         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   152             "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
   153                 "fieldInheritedFromParent</a>"
   154         },
   155         // Field inheritence from non-public superinterface.
   156         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
   157             "Fields inherited from interface&nbsp;pkg." +
   158             "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
   159             "PrivateInterface</a>"
   160         },
   161         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
   162             "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
   163                 "fieldInheritedFromInterface</a>"
   164         },
   165         // Method inheritence from non-public superclass.
   166         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   167             "Methods inherited from class&nbsp;pkg." +
   168             "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
   169             "PrivateParent</a>"
   170         },
   171         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   172             "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" +
   173                 "methodInheritedFromParent</a>"
   174         },
   175         // Should document that a method overrides method from private class.
   176        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   177             "<dt><strong>Overrides:</strong></dt>" + NL +
   178             "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
   179             "methodOverridenFromParent</a></code>&nbsp;in class&nbsp;<code>" +
   180             "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
   181             "PrivateParent</a></code></dd>"},
   182        // Should document that a method is specified by private interface.
   183        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   184             "<dt><strong>Specified by:</strong></dt>" + NL +
   185             "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
   186             "methodInterface</a></code>&nbsp;in interface&nbsp;<code>" +
   187             "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
   188             "PrivateInterface</a></code></dd>"},
   189        // Method inheritence from non-public superinterface.
   190        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
   191             "Methods inherited from interface&nbsp;pkg." +
   192             "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
   193             "PrivateInterface</a>"
   194         },
   195         {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html",
   196             "<a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
   197                 "methodInterface</a>"
   198         },
   199       // Should mention that any documentation was copied.
   200       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   201         "Description copied from"},
   202       // Extend documented private classes or interfaces
   203       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   204         "extends"},
   205       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
   206         "extends"},
   207       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
   208         "All Superinterfaces"},
   210       //Make sure implemented interfaces from private superclass are inherited
   211       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
   212         "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
   213         "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
   214         "PrivateParent</a>, " +
   215         "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" +
   216         "</a></dd>" + NL + "</dl>"},
   218       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
   219         "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
   220         "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
   221         "PrivateInterface</a>, " +
   222         "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
   223         "PublicInterface</a></dd>" + NL + "</dl>"},
   225       //Since private flag is used, we can document that private interface method
   226       //with generic parameters has been implemented.
   227       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
   228             "<strong>Description copied from interface:&nbsp;<code>" +
   229             "<a href=\"../pkg2/I.html#hello(T)\">I</a></code></strong>"},
   231       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
   232             "<dt><strong>Specified by:</strong></dt>" + NL +
   233             "<dd><code><a href=\"../pkg2/I.html#hello(T)\">hello</a></code>" +
   234             "&nbsp;in interface&nbsp;<code>" +
   235             "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" +
   236             "&lt;java.lang.String&gt;</code></dd>"},
   237     };
   238     private static final String[][] NEGATED_TEST2 = NO_TEST;
   240     /**
   241      * The entry point of the test.
   242      * @param args the array of command line arguments.
   243      */
   244     public static void main(String[] args) {
   245         TestPrivateClasses tester = new TestPrivateClasses();
   246         run(tester, ARGS1, TEST1, NEGATED_TEST1);
   247         run(tester, ARGS2, TEST2, NEGATED_TEST2);
   248         tester.printSummary();
   249     }
   251     /**
   252      * {@inheritDoc}
   253      */
   254     public String getBugId() {
   255         return BUG_ID;
   256     }
   258     /**
   259      * {@inheritDoc}
   260      */
   261     public String getBugName() {
   262         return getClass().getName();
   263     }
   264 }

mercurial