test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java
author jjg
Tue, 10 Apr 2018 15:05:10 -0700
changeset 49569 d4d2f634b72f
parent 48759 ffa68af7da87
child 50293 edfb87b2520e
permissions -rw-r--r--
8201396: fix broken links generated by javadoc doclet Reviewed-by: ksrini
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
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    26
 * @bug 8195795 8201396
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",
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    85
                "--module-source-path", src.toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    86
                "--no-module-directories",
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    87
                "--module", "ma,mb");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    88
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    89
        checkExit(Exit.OK);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    90
        checkFiles(true,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    91
                "ma-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    92
                "ma-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    93
                "pa/package-summary.html");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
    94
        checkFiles(false,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    95
                "ma/module-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    96
                "ma/module-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    97
                "ma/pa/package-summary.html");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    98
        checkOutput("ma-frame.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
    99
                "<ul>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   100
                + "<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
   101
                + "<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
   102
                + "<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
   103
                + "</ul>\n");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   104
        checkOutput("ma-summary.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   105
                "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   106
                + "<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
   107
                + "</ul>\n");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   108
        checkOutput("pa/package-summary.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   109
                "<li><a href=\"../deprecated-list.html\">Deprecated</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   110
                + "<li><a href=\"../index-all.html\">Index</a></li>");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   111
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   112
    }
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
    @Test
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   115
    public void testModuleDirs(Path base) throws IOException {
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   116
        Path src = base.resolve("src");
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   117
        new ModuleBuilder(tb, "ma")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   118
                .classes("package pa; public class A {}")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   119
                .exports("pa")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   120
                .write(src);
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   121
        new ModuleBuilder(tb, "mb")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   122
                .classes("package pb; public class B {}")
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   123
                .exports("pb")
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   124
                .write(src);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   125
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   126
        javadoc("-d", base.resolve("api").toString(),
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   127
                "-quiet",
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   128
                "--module-source-path", src.toString(),
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   129
                "--module", "ma,mb");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   130
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   131
        checkExit(Exit.OK);
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   132
        checkFiles(false,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   133
                "ma-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   134
                "ma-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   135
                "pa/package-summary.html");
48759
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   136
        checkFiles(true,
49569
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   137
                "ma/module-frame.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   138
                "ma/module-summary.html",
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   139
                "ma/pa/package-summary.html");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   140
        checkOutput("ma/module-frame.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   141
                "<ul>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   142
                + "<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
   143
                + "<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
   144
                + "<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
   145
                + "</ul>\n");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   146
        checkOutput("ma/module-summary.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   147
                "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   148
                + "<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
   149
                + "</ul>\n");
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   150
        checkOutput("ma/pa/package-summary.html", true,
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   151
                "<li><a href=\"../../deprecated-list.html\">Deprecated</a></li>\n"
d4d2f634b72f 8201396: fix broken links generated by javadoc doclet
jjg
parents: 48759
diff changeset
   152
                + "<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
   153
    }
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   154
}
ffa68af7da87 8195795: Organize output files by module/package, not just package
jjg
parents:
diff changeset
   155