test/langtools/jdk/javadoc/doclet/testPackagePage/TestPackagePage.java
author bpatel
Thu, 17 May 2018 12:59:53 -0700
changeset 50167 cc705c956798
parent 48654 36f58bd6269f
child 52616 1a395165c09b
permissions -rw-r--r--
8196201: Generate pages to list all classes and all packages in javadoc output Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47216
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    21
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
 * @test
50167
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    26
 * @bug 4492643 4689286 8196201
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary Test that a package page is properly generated when a .java file
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * passed to Javadoc.  Also test that the proper package links are generated
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * when single or multiple packages are documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
 * @author jamieh
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    31
 * @library ../lib
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    32
 * @modules jdk.javadoc/jdk.javadoc.internal.tool
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * @build JavadocTester
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * @run main TestPackagePage
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
public class TestPackagePage extends JavadocTester {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    39
    public static void main(String... args) throws Exception {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    40
        TestPackagePage tester = new TestPackagePage();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    41
        tester.runTests();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    42
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    43
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    44
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    45
    void testSinglePackage() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    46
        javadoc("-d", "out-1",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    47
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    48
                testSrc("com/pkg/C.java"));
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    49
        checkExit(Exit.OK);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    50
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    51
        checkOutput("com/pkg/package-summary.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    52
            "This is a package page.");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    53
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    54
        // With just one package, all general pages link to the single package page.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    55
        checkOutput("com/pkg/C.html", true,
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47216
diff changeset
    56
            "<a href=\"package-summary.html\">Package</a>");
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    57
        checkOutput("com/pkg/package-tree.html", true,
48654
36f58bd6269f 8195796: Reduce the size of relative URLs in generated docs
jjg
parents: 47216
diff changeset
    58
            "<li><a href=\"package-summary.html\">Package</a></li>");
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    59
        checkOutput("deprecated-list.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    60
            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    61
        checkOutput("index-all.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    62
            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    63
        checkOutput("help-doc.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    64
            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    65
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    66
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    private static final String[][] TEST1 = {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    70
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    71
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    72
    void testMultiplePackages() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    73
        javadoc("-d", "out-2",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    74
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    75
                "com.pkg", "pkg2");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    76
        checkExit(Exit.OK);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    78
        //With multiple packages, there is no package link in general pages.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    79
        checkOutput("deprecated-list.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    80
            "<li>Package</li>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    81
        checkOutput("index-all.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    82
            "<li>Package</li>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    83
        checkOutput("help-doc.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    84
            "<li>Package</li>");
50167
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    85
        checkOutput("allclasses-index.html", true,
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    86
                "<table class=\"typeSummary\">\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    87
                + "<caption><span>Class Summary</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    88
                + "<tr>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    89
                + "<th class=\"colFirst\" scope=\"col\">Class</th>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    90
                + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    91
                + "</tr>\n");
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    92
        checkOutput("allpackages-index.html", true,
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    93
                "<table class=\"packagesSummary\">\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    94
                + "<caption><span>Package Summary</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    95
                + "<tr>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    96
                + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    97
                + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    98
                + "</tr>\n");
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
    99
        checkOutput("type-search-index.js", true,
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
   100
                "{\"l\":\"All Classes\",\"url\":\"allclasses-index.html\"}");
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
   101
        checkOutput("package-search-index.js", true,
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
   102
                "{\"l\":\"All Packages\",\"url\":\"allpackages-index.html\"}");
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
   103
        checkOutput("index-all.html", true,
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
   104
                "<br><a href=\"allclasses-index.html\">All&nbsp;Classes</a>&nbsp;"
cc705c956798 8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents: 48654
diff changeset
   105
                + "<a href=\"allpackages-index.html\">All&nbsp;Packages</a>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
}