langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
changeset 24399 af1a0220d0fa
parent 24072 e7549dcbc4af
child 30730 d3ce7619db2c
equal deleted inserted replaced
24398:601a611d0aee 24399:af1a0220d0fa
    25  * @test
    25  * @test
    26  * @bug 4638588 4635809 6256068 6270645 8025633 8026567
    26  * @bug 4638588 4635809 6256068 6270645 8025633 8026567
    27  * @summary Test to make sure that members are inherited properly in the Javadoc.
    27  * @summary Test to make sure that members are inherited properly in the Javadoc.
    28  *          Verify that inheritence labels are correct.
    28  *          Verify that inheritence labels are correct.
    29  * @author jamieh
    29  * @author jamieh
    30  * @library ../lib/
    30  * @library ../lib
    31  * @build JavadocTester
    31  * @build JavadocTester
    32  * @build TestMemberInheritence
       
    33  * @run main TestMemberInheritence
    32  * @run main TestMemberInheritence
    34  */
    33  */
    35 
    34 
    36 public class TestMemberInheritence extends JavadocTester {
    35 public class TestMemberInheritence extends JavadocTester {
    37 
    36 
    38     private static final String[][] TEST = {
    37     public static void main(String... args) throws Exception {
    39         //Public field should be inherited
    38         TestMemberInheritence tester = new TestMemberInheritence();
    40         { "pkg/SubClass.html",
    39         tester.runTests();
    41          "<a href=\"../pkg/BaseClass.html#pubField\">"},
    40     }
    42 
    41 
    43         //Public method should be inherited
    42     @Test
    44         { "pkg/SubClass.html",
    43     void test() {
    45          "<a href=\"../pkg/BaseClass.html#pubMethod--\">"},
    44         javadoc("-d", "out",
       
    45                 "-sourcepath", testSrc,
       
    46                 "pkg", "diamond", "inheritDist");
       
    47         checkExit(Exit.OK);
    46 
    48 
    47         //Public inner class should be inherited.
    49         checkOutput("pkg/SubClass.html", true,
    48         { "pkg/SubClass.html",
    50                 // Public field should be inherited
    49          "<a href=\"../pkg/BaseClass.pubInnerClass.html\" title=\"class in pkg\">"},
    51                 "<a href=\"../pkg/BaseClass.html#pubField\">",
       
    52                 // Public method should be inherited
       
    53                 "<a href=\"../pkg/BaseClass.html#pubMethod--\">",
       
    54                 // Public inner class should be inherited.
       
    55                 "<a href=\"../pkg/BaseClass.pubInnerClass.html\" title=\"class in pkg\">",
       
    56                 // Protected field should be inherited
       
    57                 "<a href=\"../pkg/BaseClass.html#proField\">",
       
    58                 // Protected method should be inherited
       
    59                 "<a href=\"../pkg/BaseClass.html#proMethod--\">",
       
    60                 // Protected inner class should be inherited.
       
    61                 "<a href=\"../pkg/BaseClass.proInnerClass.html\" title=\"class in pkg\">",
       
    62                 // New labels as of 1.5.0
       
    63                 "Nested classes/interfaces inherited from class&nbsp;pkg."
       
    64                 + "<a href=\"../pkg/BaseClass.html\" title=\"class in pkg\">BaseClass</a>",
       
    65                 "Nested classes/interfaces inherited from interface&nbsp;pkg."
       
    66                 + "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</a>");
    50 
    67 
    51         //Protected field should be inherited
    68         checkOutput("pkg/BaseClass.html", true,
    52         { "pkg/SubClass.html",
    69                 // Test overriding/implementing methods with generic parameters.
    53          "<a href=\"../pkg/BaseClass.html#proField\">"},
    70                 "<dl>\n"
       
    71                 + "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
       
    72                 + "<dd><code><a href=\"../pkg/BaseInterface.html#getAnnotation-java.lang.Class-\">"
       
    73                 + "getAnnotation</a></code>&nbsp;in interface&nbsp;<code>"
       
    74                 + "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">"
       
    75                 + "BaseInterface</a></code></dd>\n"
       
    76                 + "</dl>");
    54 
    77 
    55         //Protected method should be inherited
    78         checkOutput("diamond/Z.html", true,
    56         { "pkg/SubClass.html",
    79                 // Test diamond inheritence member summary (6256068)
    57          "<a href=\"../pkg/BaseClass.html#proMethod--\">"},
    80                 "<code><a href=\"../diamond/A.html#aMethod--\">aMethod</a></code>");
    58 
    81 
    59         //Protected inner class should be inherited.
    82         checkOutput("inheritDist/C.html", true,
    60         { "pkg/SubClass.html",
    83                 // Test that doc is inherited from closed parent (6270645)
    61          "<a href=\"../pkg/BaseClass.proInnerClass.html\" title=\"class in pkg\">"},
    84                 "<div class=\"block\">m1-B</div>");
    62 
    85 
    63         // New labels as of 1.5.0
    86         checkOutput("pkg/SubClass.html", false,
    64         { "pkg/SubClass.html",
    87                 "<a href=\"../pkg/BaseClass.html#staticMethod--\">staticMethod</a></code>");
    65          "Nested classes/interfaces inherited from class&nbsp;pkg." +
       
    66                  "<a href=\"../pkg/BaseClass.html\" title=\"class in pkg\">BaseClass</a>"},
       
    67         { "pkg/SubClass.html",
       
    68          "Nested classes/interfaces inherited from interface&nbsp;pkg." +
       
    69                  "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</a>"},
       
    70 
       
    71          // Test overriding/implementing methods with generic parameters.
       
    72                  { "pkg/BaseClass.html",
       
    73          "<dl>\n" +
       
    74          "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n" +
       
    75                           "<dd><code><a href=\"../pkg/BaseInterface.html#getAnnotation-java.lang.Class-\">" +
       
    76                           "getAnnotation</a></code>&nbsp;in interface&nbsp;<code>" +
       
    77                           "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">" +
       
    78                           "BaseInterface</a></code></dd>\n" +
       
    79                           "</dl>"},
       
    80 
       
    81          // Test diamond inheritence member summary (6256068)
       
    82                  { "diamond/Z.html",
       
    83                  "<code><a href=\"../diamond/A.html#aMethod--\">aMethod</a></code>"},
       
    84 
       
    85          // Test that doc is inherited from closed parent (6270645)
       
    86                  { "inheritDist/C.html",
       
    87                  "<div class=\"block\">m1-B</div>"},
       
    88 
       
    89     };
       
    90 
       
    91     private static final String[][] NEGATED_TEST = {
       
    92         { "pkg/SubClass.html",
       
    93         "<a href=\"../pkg/BaseClass.html#staticMethod--\">staticMethod</a></code>"},
       
    94     };
       
    95     private static final String[] ARGS =
       
    96         new String[] {
       
    97             "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "pkg", "diamond",
       
    98             "inheritDist"};
       
    99 
       
   100     /**
       
   101      * The entry point of the test.
       
   102      * @param args the array of command line arguments.
       
   103      */
       
   104     public static void main(String[] args) {
       
   105         TestMemberInheritence tester = new TestMemberInheritence();
       
   106         tester.run(ARGS, TEST, NEGATED_TEST);
       
   107         tester.printSummary();
       
   108     }
    88     }
   109 }
    89 }