test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java
author jjg
Thu, 28 Jun 2018 15:46:27 -0700
changeset 50895 83ed34655f59
parent 50293 edfb87b2520e
child 53097 2e82ca64b25d
permissions -rw-r--r--
8202959: Rearrange the top and bottom navigation bar in the javadoc generated pages Reviewed-by: darcy, jjg Contributed-by: bhavesh.x.patel@oracle.com, jonathan.gibbons@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     1
/*
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     4
 *
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     8
 *
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    13
 * accompanied this code).
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    14
 *
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    18
 *
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    21
 * questions.
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    22
 */
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    23
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    24
/*
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    25
 * @test
50293
edfb87b2520e 8196202: Javadoc should not generate frames by default
jjg
parents: 49569
diff changeset
    26
 * @bug 8195795 8201396 8196202
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    27
 * @summary test the use of module directories in output,
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    28
 *          and the --no-module-directories option
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    29
 * @modules jdk.javadoc/jdk.javadoc.internal.api
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    30
 *          jdk.javadoc/jdk.javadoc.internal.tool
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    31
 *          jdk.compiler/com.sun.tools.javac.api
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    32
 *          jdk.compiler/com.sun.tools.javac.main
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    33
 * @library ../lib /tools/lib
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    34
 * @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    35
 * @run main TestModuleDirs
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    36
 */
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    37
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    38
import java.io.IOException;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    39
import java.nio.file.Path;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    40
import java.nio.file.Paths;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    41
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    42
import toolbox.ModuleBuilder;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    43
import toolbox.ToolBox;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    44
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    45
public class TestModuleDirs extends JavadocTester {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    46
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    47
    public final ToolBox tb;
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    48
    public static void main(String... args) throws Exception {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    49
        TestModuleDirs tester = new TestModuleDirs();
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    50
        tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    51
    }
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    52
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    53
    public TestModuleDirs() {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    54
        tb = new ToolBox();
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    55
    }
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    56
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    57
    @Test
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    58
    public void testNoModules(Path base) throws IOException {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    59
        Path src = base.resolve("src");
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    60
        tb.writeJavaFiles(src, "package p; public class C { }");
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    61
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    62
        javadoc("-d", base.resolve("api").toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    63
                "-sourcepath", src.toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    64
                "-quiet",
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    65
                "p");
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    66
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    67
        checkExit(Exit.OK);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    68
        checkFiles(true, "p/package-summary.html");
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    69
    }
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    70
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    71
    @Test
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    72
    public void testNoModuleDirs(Path base) throws IOException {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    73
        Path src = base.resolve("src");
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    74
        new ModuleBuilder(tb, "ma")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    75
                .classes("package pa; public class A {}")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    76
                .exports("pa")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    77
                .write(src);
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    78
        new ModuleBuilder(tb, "mb")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    79
                .classes("package pb; public class B {}")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    80
                .exports("pb")
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    81
                .write(src);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    82
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    83
        javadoc("-d", base.resolve("api").toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    84
                "-quiet",
50293
edfb87b2520e 8196202: Javadoc should not generate frames by default
jjg
parents: 49569
diff changeset
    85
                "--frames",
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    86
                "--module-source-path", src.toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    87
                "--no-module-directories",
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    88
                "--module", "ma,mb");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    89
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    90
        checkExit(Exit.OK);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    91
        checkFiles(true,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    92
                "ma-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    93
                "ma-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    94
                "pa/package-summary.html");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    95
        checkFiles(false,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    96
                "ma/module-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    97
                "ma/module-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    98
                "ma/pa/package-summary.html");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    99
        checkOutput("ma-frame.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   100
                "<ul>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   101
                + "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All&nbsp;Classes</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   102
                + "<li><a href=\"overview-frame.html\" target=\"packageListFrame\">All&nbsp;Packages</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   103
                + "<li><a href=\"module-overview-frame.html\" target=\"packageListFrame\">All&nbsp;Modules</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   104
                + "</ul>\n");
50895
83ed34655f59 8202959: Rearrange the top and bottom navigation bar in the javadoc generated pages
jjg
parents: 50293
diff changeset
   105
        checkOutput("ma-summary.html", false,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   106
                "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   107
                + "<li><a href=\"allclasses-noframe.html\">All&nbsp;Classes</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   108
                + "</ul>\n");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   109
        checkOutput("pa/package-summary.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   110
                "<li><a href=\"../deprecated-list.html\">Deprecated</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   111
                + "<li><a href=\"../index-all.html\">Index</a></li>");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   112
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   113
    }
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   114
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   115
    @Test
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   116
    public void testModuleDirs(Path base) throws IOException {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   117
        Path src = base.resolve("src");
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   118
        new ModuleBuilder(tb, "ma")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   119
                .classes("package pa; public class A {}")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   120
                .exports("pa")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   121
                .write(src);
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   122
        new ModuleBuilder(tb, "mb")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   123
                .classes("package pb; public class B {}")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   124
                .exports("pb")
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   125
                .write(src);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   126
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   127
        javadoc("-d", base.resolve("api").toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   128
                "-quiet",
50293
edfb87b2520e 8196202: Javadoc should not generate frames by default
jjg
parents: 49569
diff changeset
   129
                "--frames",
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   130
                "--module-source-path", src.toString(),
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   131
                "--module", "ma,mb");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   132
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   133
        checkExit(Exit.OK);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   134
        checkFiles(false,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   135
                "ma-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   136
                "ma-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   137
                "pa/package-summary.html");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   138
        checkFiles(true,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   139
                "ma/module-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   140
                "ma/module-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   141
                "ma/pa/package-summary.html");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   142
        checkOutput("ma/module-frame.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   143
                "<ul>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   144
                + "<li><a href=\"../allclasses-frame.html\" target=\"packageFrame\">All&nbsp;Classes</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   145
                + "<li><a href=\"../overview-frame.html\" target=\"packageListFrame\">All&nbsp;Packages</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   146
                + "<li><a href=\"../module-overview-frame.html\" target=\"packageListFrame\">All&nbsp;Modules</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   147
                + "</ul>\n");
50895
83ed34655f59 8202959: Rearrange the top and bottom navigation bar in the javadoc generated pages
jjg
parents: 50293
diff changeset
   148
        checkOutput("ma/module-summary.html", false,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   149
                "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   150
                + "<li><a href=\"../allclasses-noframe.html\">All&nbsp;Classes</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   151
                + "</ul>\n");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   152
        checkOutput("ma/pa/package-summary.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   153
                "<li><a href=\"../../deprecated-list.html\">Deprecated</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   154
                + "<li><a href=\"../../index-all.html\">Index</a></li>");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   155
    }
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   156
}
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   157