1 /*
   2  * Copyright 2003-2004 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  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  */
  37 
  38 public class TestInterface extends JavadocTester {
  39 
  40     //Test information.
  41     private static final String BUG_ID = "4682448-4947464-5029946";
  42 
  43     //Javadoc arguments.
  44     private static final String[] ARGS = new String[] {
  45         "-source", "1.5", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
  46     };
  47 
  48     //Input for string search tests.
  49     private static final String[][] TEST = {
  50         {BUG_ID + FS + "pkg" + FS + "Interface.html",
  51             "int <STRONG>method</STRONG>()"},
  52         {BUG_ID + FS + "pkg" + FS + "Interface.html",
  53             "static final int <STRONG>field</STRONG>"},
  54 
  55 
  56         // Make sure known implementing class list is correct and omits type parameters.
  57         {BUG_ID + FS + "pkg" + FS + "Interface.html",
  58             "<DT><STRONG>All Known Implementing Classes:</STRONG></DT> " +
  59             "<DD><A HREF=\"../pkg/Child.html\" " +
  60             "title=\"class in pkg\">Child</A>, " +
  61             "<A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">" +
  62             "Parent</A></DD>"},
  63 
  64          // Make sure "All Implemented Interfaces": has substituted type parameters
  65          {BUG_ID + FS + "pkg" + FS + "Child.html",
  66             "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD>" +
  67             "<A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
  68             "Interface</A>&lt;T&gt;"
  69          },
  70          //Make sure Class Tree has substituted type parameters.
  71          {BUG_ID + FS + "pkg" + FS + "Child.html",
  72             "<PRE>" + NL +
  73             "java.lang.Object" + NL +
  74             "  <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">pkg.Parent</A>&lt;T&gt;" + NL +
  75             "      <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><STRONG>pkg.Child&lt;T&gt;</STRONG>" + NL +
  76             "</PRE>"
  77          },
  78          //Make sure "Direct Know Subclasses" omits type parameters
  79         {BUG_ID + FS + "pkg" + FS + "Parent.html",
  80             "<STRONG>Direct Known Subclasses:</STRONG></DT> <DD><A HREF=\"../pkg/Child.html\" title=\"class in pkg\">Child</A>"
  81         },
  82         //Make sure "Specified By" has substituted type parameters.
  83         {BUG_ID + FS + "pkg" + FS + "Child.html",
  84             "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg/Interface.html#method()\">method</A></CODE> in interface <CODE><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
  85          },
  86         //Make sure "Overrides" has substituted type parameters.
  87         {BUG_ID + FS + "pkg" + FS + "Child.html",
  88             "<STRONG>Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg/Parent.html#method()\">method</A></CODE> in class <CODE><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">Parent</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
  89          },
  90     };
  91     private static final String[][] NEGATED_TEST = {
  92         {BUG_ID + FS + "pkg" + FS + "Interface.html",
  93             "public int <STRONG>method</STRONG>()"},
  94         {BUG_ID + FS + "pkg" + FS + "Interface.html",
  95             "public static final int <STRONG>field</STRONG>"},
  96     };
  97 
  98     /**
  99      * The entry point of the test.
 100      * @param args the array of command line arguments.
 101      */
 102     public static void main(String[] args) {
 103         TestInterface tester = new TestInterface();
 104         run(tester, ARGS, TEST, NEGATED_TEST);
 105         tester.printSummary();
 106     }
 107 
 108     /**
 109      * {@inheritDoc}
 110      */
 111     public String getBugId() {
 112         return BUG_ID;
 113     }
 114 
 115     /**
 116      * {@inheritDoc}
 117      */
 118     public String getBugName() {
 119         return getClass().getName();
 120     }
 121 }