langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
changeset 24399 af1a0220d0fa
parent 24072 e7549dcbc4af
child 30730 d3ce7619db2c
equal deleted inserted replaced
24398:601a611d0aee 24399:af1a0220d0fa
    26  * @bug 4492643 4689286
    26  * @bug 4492643 4689286
    27  * @summary Test that a package page is properly generated when a .java file
    27  * @summary Test that a package page is properly generated when a .java file
    28  * passed to Javadoc.  Also test that the proper package links are generated
    28  * passed to Javadoc.  Also test that the proper package links are generated
    29  * when single or multiple packages are documented.
    29  * when single or multiple packages are documented.
    30  * @author jamieh
    30  * @author jamieh
    31  * @library ../lib/
    31  * @library ../lib
    32  * @build JavadocTester
    32  * @build JavadocTester
    33  * @build TestPackagePage
       
    34  * @run main TestPackagePage
    33  * @run main TestPackagePage
    35  */
    34  */
    36 
    35 
    37 public class TestPackagePage extends JavadocTester {
    36 public class TestPackagePage extends JavadocTester {
    38 
    37 
       
    38     public static void main(String... args) throws Exception {
       
    39         TestPackagePage tester = new TestPackagePage();
       
    40         tester.runTests();
       
    41     }
       
    42 
       
    43     @Test
       
    44     void testSinglePackage() {
       
    45         javadoc("-d", "out-1",
       
    46                 "-sourcepath", testSrc,
       
    47                 testSrc("com/pkg/C.java"));
       
    48         checkExit(Exit.OK);
       
    49 
       
    50         checkOutput("com/pkg/package-summary.html", true,
       
    51             "This is a package page.");
       
    52 
       
    53         // With just one package, all general pages link to the single package page.
       
    54         checkOutput("com/pkg/C.html", true,
       
    55             "<a href=\"../../com/pkg/package-summary.html\">Package</a>");
       
    56         checkOutput("com/pkg/package-tree.html", true,
       
    57             "<li><a href=\"../../com/pkg/package-summary.html\">Package</a></li>");
       
    58         checkOutput("deprecated-list.html", true,
       
    59             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>");
       
    60         checkOutput("index-all.html", true,
       
    61             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>");
       
    62         checkOutput("help-doc.html", true,
       
    63             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>");
       
    64     }
       
    65 
    39     private static final String[][] TEST1 = {
    66     private static final String[][] TEST1 = {
    40         { "com/pkg/package-summary.html",
       
    41             "This is a package page."
       
    42         },
       
    43         //With just one package, all general pages link to the single package page.
       
    44         { "com/pkg/C.html",
       
    45             "<a href=\"../../com/pkg/package-summary.html\">Package</a>"
       
    46         },
       
    47         { "com/pkg/package-tree.html",
       
    48             "<li><a href=\"../../com/pkg/package-summary.html\">Package</a></li>"
       
    49         },
       
    50         { "deprecated-list.html",
       
    51             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
       
    52         },
       
    53         { "index-all.html",
       
    54             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
       
    55         },
       
    56         { "help-doc.html",
       
    57             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
       
    58         },
       
    59     };
    67     };
    60 
    68 
    61     private static final String[][] TEST2 = {
    69 
       
    70     @Test
       
    71     void testMultiplePackages() {
       
    72         javadoc("-d", "out-2",
       
    73                 "-sourcepath", testSrc,
       
    74                 "com.pkg", "pkg2");
       
    75         checkExit(Exit.OK);
       
    76 
    62         //With multiple packages, there is no package link in general pages.
    77         //With multiple packages, there is no package link in general pages.
    63         { "deprecated-list.html",
    78         checkOutput("deprecated-list.html", true,
    64             "<li>Package</li>"
    79             "<li>Package</li>");
    65         },
    80         checkOutput("index-all.html", true,
    66         { "index-all.html",
    81             "<li>Package</li>");
    67             "<li>Package</li>"
    82         checkOutput("help-doc.html", true,
    68         },
    83             "<li>Package</li>");
    69         { "help-doc.html",
       
    70             "<li>Package</li>"
       
    71         },
       
    72     };
       
    73 
       
    74     private static final String[] ARGS1 =
       
    75         new String[] {
       
    76             "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR,
       
    77             SRC_DIR + "/com/pkg/C.java"
       
    78         };
       
    79 
       
    80     private static final String[] ARGS2 =
       
    81         new String[] {
       
    82             "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR,
       
    83             "com.pkg", "pkg2"
       
    84         };
       
    85 
       
    86     /**
       
    87      * The entry point of the test.
       
    88      * @param args the array of command line arguments.
       
    89      */
       
    90     public static void main(String[] args) {
       
    91         TestPackagePage tester = new TestPackagePage();
       
    92         tester.run(ARGS1, TEST1, NO_TEST);
       
    93         tester.run(ARGS2, TEST2, NO_TEST);
       
    94         tester.printSummary();
       
    95     }
    84     }
    96 }
    85 }