/* * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363 * 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 * 8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464 8164407 8192007 * @summary Test modules support in javadoc. * @author bpatel * @library ../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool * @build JavadocTester * @run main TestModules */ public class TestModules extends JavadocTester { public static void main(String... args) throws Exception { TestModules tester = new TestModules(); tester.runTests(); } /** * Test generated module pages for HTML 4. */ @Test void testHtml4() { javadoc("-d", "out", "-use", "-Xdoclint:none", "-overview", testSrc("overview.html"), "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB"); checkExit(Exit.OK); checkDescription(true); checkNoDescription(false); checkOverviewSummaryModules(); checkModuleLink(); checkModuleClickThroughLinks(); checkModuleClickThrough(true); checkModuleFilesAndLinks(true); checkModulesInSearch(true); checkOverviewFrame(true); } /** * Test generated module pages for HTML 5. */ @Test void testHtml5() { javadoc("-d", "out-html5", "-html5", "-use", "-Xdoclint:none", "-overview", testSrc("overview.html"), "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB"); checkExit(Exit.OK); checkHtml5Description(true); checkHtml5NoDescription(false); checkHtml5OverviewSummaryModules(); checkModuleLink(); checkModuleClickThroughLinks(); checkModuleClickThrough(true); checkModuleFilesAndLinks(true); checkModulesInSearch(true); checkOverviewFrame(true); } /** * Test generated module pages for HTML 4 with -nocomment option. */ @Test void testHtml4NoComment() { javadoc("-d", "out-nocomment", "-nocomment", "-use", "-Xdoclint:none", "-overview", testSrc("overview.html"), "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB"); checkExit(Exit.OK); checkDescription(false); checkNoDescription(true); checkModuleLink(); checkModuleFilesAndLinks(true); checkOverviewFrame(true); } /** * Test generated module pages for HTML 5 with -nocomment option. */ @Test void testHtml5NoComment() { javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use", "-Xdoclint:none", "-overview", testSrc("overview.html"), "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB"); checkExit(Exit.OK); checkHtml5Description(false); checkHtml5NoDescription(true); checkModuleLink(); checkModuleFilesAndLinks(true); checkOverviewFrame(true); } /** * Test generated pages, in an unnamed module, for HTML 4. */ @Test void testHtml4UnnamedModule() { javadoc("-d", "out-nomodule", "-use", "-overview", testSrc("overview.html"), "-sourcepath", testSrc, "testpkgnomodule", "testpkgnomodule1"); checkExit(Exit.OK); checkOverviewSummaryPackages(); checkModuleClickThrough(false); checkModuleFilesAndLinks(false); checkModulesInSearch(false); checkOverviewFrame(false); } /** * Test generated pages, in an unnamed module, for HTML 5. */ @Test void testHtml5UnnamedModule() { javadoc("-d", "out-html5-nomodule", "-html5", "-use", "-overview", testSrc("overview.html"), "-sourcepath", testSrc, "testpkgnomodule", "testpkgnomodule1"); checkExit(Exit.OK); checkHtml5OverviewSummaryPackages(); checkModuleFilesAndLinks(false); checkModulesInSearch(false); checkOverviewFrame(false); } /** * Test generated module pages with javadoc tags. */ @Test void testJDTagsInModules() { javadoc("-d", "out-mdltags", "-author", "-version", "-Xdoclint:none", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", "--module-source-path", testSrc, "--module", "moduletags,moduleB", "testpkgmdltags", "testpkgmdlB"); checkExit(Exit.OK); checkModuleTags(); } /** * Test generated module summary page. */ @Test void testModuleSummary() { javadoc("-d", "out-moduleSummary", "-use", "-Xdoclint:none", "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB", "moduleB/testpkg2mdlB"); checkExit(Exit.OK); checkModuleSummary(); checkNegatedModuleSummary(); } /** * Test generated module summary page of an aggregating module. */ @Test void testAggregatorModuleSummary() { javadoc("-d", "out-aggregatorModuleSummary", "-use", "--module-source-path", testSrc, "--expand-requires", "transitive", "--module", "moduleT"); checkExit(Exit.OK); checkAggregatorModuleSummary(); } /** * Test generated module pages and pages with link to modules. */ @Test void testModuleFilesAndLinks() { javadoc("-d", "out-modulelinks", "-Xdoclint:none", "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB"); checkExit(Exit.OK); checkModuleFilesAndLinks(true); checkOverviewFrame(true); } /** * Test generated module pages for a deprecated module. */ @Test void testModuleDeprecation() { javadoc("-d", "out-moduledepr", "-Xdoclint:none", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", "--module-source-path", testSrc, "--module", "moduleA,moduleB,moduletags", "testpkgmdlA", "testpkgmdlB", "testpkgmdltags"); checkExit(Exit.OK); checkModuleDeprecation(true); } /** * Test annotations on modules. */ @Test void testModuleAnnotation() { javadoc("-d", "out-moduleanno", "-Xdoclint:none", "--module-source-path", testSrc, "--module", "moduleA,moduleB", "testpkgmdlA", "testpkgmdlB"); checkExit(Exit.OK); checkModuleAnnotation(); } /** * Test module summary pages in "api" mode. */ @Test void testApiMode() { javadoc("-d", "out-api", "-use", "--show-module-contents=api", "-author", "-version", "-Xdoclint:none", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", "--module-source-path", testSrc, "--module", "moduleA,moduleB,moduleC,moduletags", "testpkgmdlA", "moduleA/concealedpkgmdlA", "testpkgmdlB", "testpkg2mdlB", "testpkgmdlC", "testpkgmdltags"); checkExit(Exit.OK); checkModuleModeCommon(); checkModuleModeApi(true); checkModuleModeAll(false); checkModuleFrameFiles(true); checkAllModulesLink(true); } /** * Test module summary pages in "all" mode. */ @Test void testAllMode() { javadoc("-d", "out-all", "-use", "--show-module-contents=all", "-author", "-version", "-Xdoclint:none", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", "--module-source-path", testSrc, "--module", "moduleA,moduleB,moduleC,moduletags", "testpkgmdlA", "moduleA/concealedpkgmdlA", "testpkgmdlB", "testpkg2mdlB", "testpkgmdlC", "testpkgmdltags"); checkExit(Exit.OK); checkModuleModeCommon(); checkModuleModeApi(false); checkModuleModeAll(true); checkModuleFrameFiles(true); checkAllModulesLink(true); } /** * Test generated module summary page of a module with no exported package. */ @Test void testModuleSummaryNoExportedPkgAll() { javadoc("-d", "out-ModuleSummaryNoExportedPkgAll", "-use", "--show-module-contents=all", "-sourcepath", testSrc + "/moduleNoExport", "--module", "moduleNoExport", "testpkgmdlNoExport"); checkExit(Exit.OK); checkModuleSummaryNoExported(true); } /** * Test generated module summary page of a module with no exported package. */ @Test void testModuleSummaryNoExportedPkgApi() { javadoc("-d", "out-ModuleSummaryNoExportedPkgApi", "-use", "-sourcepath", testSrc + "/moduleNoExport", "--module", "moduleNoExport", "testpkgmdlNoExport"); checkExit(Exit.OK); checkModuleSummaryNoExported(false); } /** * Test generated module pages for javadoc run for a single module having a single package. */ @Test void testSingleModuleSinglePkg() { javadoc("-d", "out-singlemod", "--module-source-path", testSrc, "--module", "moduleC", "testpkgmdlC"); checkExit(Exit.OK); checkModuleFrameFiles(false); } /** * Test generated module pages for javadoc run for a single module having multiple packages. */ @Test void testSingleModuleMultiplePkg() { javadoc("-d", "out-singlemodmultiplepkg", "--show-module-contents=all", "-Xdoclint:none", "--module-source-path", testSrc, "--module", "moduleB", "testpkg2mdlB", "testpkgmdlB"); checkExit(Exit.OK); checkAllModulesLink(false); } /** * Test -group option for modules. The overview-summary.html page should group the modules accordingly. */ @Test void testGroupOption() { javadoc("-d", "out-group", "--show-module-contents=all", "-Xdoclint:none", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", "--module-source-path", testSrc, "-group", "Module Group A", "moduleA*", "-group", "Module Group B & C", "moduleB*:moduleC*", "-group", "Java SE Modules", "java*", "--module", "moduleA,moduleB,moduleC,moduletags", "moduleA/concealedpkgmdlA", "testpkgmdlA", "testpkg2mdlB", "testpkgmdlB", "testpkgmdlC", "testpkgmdltags"); checkExit(Exit.OK); checkGroupOption(); } /** * Test -group option for modules and the ordering of module groups. * The overview-summary.html page should group the modules accordingly and display the group tabs in * the order it was provided on the command-line. */ @Test void testGroupOptionOrdering() { javadoc("-d", "out-groupOrder", "--show-module-contents=all", "-Xdoclint:none", "-tag", "regular:a:Regular Tag:", "-tag", "moduletag:s:Module Tag:", "--module-source-path", testSrc, "-group", "B Group", "moduleB*", "-group", "C Group", "moduleC*", "-group", "A Group", "moduleA*", "-group", "Java SE Modules", "java*", "--module", "moduleA,moduleB,moduleC,moduletags", "moduleA/concealedpkgmdlA", "testpkgmdlA", "testpkg2mdlB", "testpkgmdlB", "testpkgmdlC", "testpkgmdltags"); checkExit(Exit.OK); checkGroupOptionOrdering(); } /** * Test -group option for unnamed modules. The overview-summary.html page should group the packages accordingly. */ @Test void testUnnamedModuleGroupOption() { javadoc("-d", "out-groupnomodule", "-use", "-Xdoclint:none", "-overview", testSrc("overview.html"), "-sourcepath", testSrc, "-group", "Package Group 0", "testpkgnomodule", "-group", "Package Group 1", "testpkgnomodule1", "testpkgnomodule", "testpkgnomodule1"); checkExit(Exit.OK); checkUnnamedModuleGroupOption(); } /** * Test -group option for unnamed modules and the ordering of package groups. * The overview-summary.html page should group the packages accordingly and display the group tabs in * the order it was provided on the command-line. */ @Test void testGroupOptionPackageOrdering() { javadoc("-d", "out-groupPkgOrder", "-use", "-Xdoclint:none", "-overview", testSrc("overview.html"), "-sourcepath", testSrc, "-group", "Z Group", "testpkgnomodule", "-group", "A Group", "testpkgnomodule1", "testpkgnomodule", "testpkgnomodule1"); checkExit(Exit.OK); checkGroupOptionPackageOrdering(); } /** * Test -group option for a single module. */ @Test void testGroupOptionSingleModule() { javadoc("-d", "out-groupsinglemodule", "-use", "-Xdoclint:none", "--module-source-path", testSrc, "-group", "Module Group B", "moduleB*", "--module", "moduleB", "testpkg2mdlB", "testpkgmdlB"); checkExit(Exit.OK); checkGroupOptionSingleModule(); } /** * Test -group option for a single module. */ @Test void testModuleName() { javadoc("-d", "out-modulename", "-use", "-Xdoclint:none", "--module-source-path", testSrc, "--module", "moduleB,test.moduleFullName", "testpkg2mdlB", "testpkgmdlB", "testpkgmdlfullname"); checkExit(Exit.OK); checkModuleName(true); } /** * Test -linkoffline option. */ @Test void testLinkOffline() { String url = "https://docs.oracle.com/javase/9/docs/api/"; javadoc("-d", "out-linkoffline", "-use", "--show-module-contents=all", "-Xdoclint:none", "--module-source-path", testSrc, "--module", "moduleA,moduleB", "-linkoffline", url, testSrc + "/jdk", "testpkgmdlA", "testpkgmdlB", "testpkg3mdlB"); checkExit(Exit.OK); checkLinkOffline(); } void checkDescription(boolean found) { checkOutput("moduleA-summary.html", found, "\n" + "\n" + "\n" + "\n" + "
Module | \n" + "Description | \n" + "
---|
Package | \n" + "Description | \n" + "
---|
Module | \n" + "Description | \n" + "
---|
Package | \n" + "Description | \n" + "
---|
Module | \n" + "Description | \n" + "
---|
Package | \n" + "Description | \n" + "
---|
Module | \n" + "Description | \n" + "
---|
Package | \n" + "Description | \n" + "
---|
testpkgmdlA | \n" + "\n" + " | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transitive | \n" + "moduleB | \n" + "\n"
+ " This is a test description for the moduleB module. \n"
+ " | \n"
+ "|||||||||||||||||||||||||||||||||||||||||||||||||||
testpkgmdlB | \n" + "\n" + " | ||||||||||||||||||||||||||||||||||||||||||||||||||||
TestClassInModuleB | \n" + "\n"
+ " With a test description for uses. \n | \n"
+ "||||||||||||||||||||||||||||||||||||||||||||||||||||
Package | \n" + "Description | \n" + "||||||||||||||||||||||||||||||||||||||||||||||||||||
Type | \n" + "Description | \n" + "||||||||||||||||||||||||||||||||||||||||||||||||||||
Type | \n" + "Description | \n" + "||||||||||||||||||||||||||||||||||||||||||||||||||||
transitive | \n" + "moduleA | \n" + "\n"
+ " This is a test description for the moduleA module with a Search "
+ "phrase search phrase. \n"
+ " | \n"
+ "|||||||||||||||||||||||||||||||||||||||||||||||||||
transitive | \n" + "moduleB | \n" + "\n"
+ " This is a test description for the moduleB module. \n"
+ " | \n"
+ "moduleA | \n" + "\n"
+ " This is a test description for the moduleA module with a Search "
+ "phrase search phrase. \n"
+ " | ",
"moduleB | \n" + "\n"
+ " This is a test description for the moduleB module. \n"
+ " | ",
"moduletags | \n" + "\n"
+ " This is a test description for the moduletags module. \n"
+ "\n" + " Type Link: TestClassInModuleTags .\n" + " Member Link: testMethod(String) .\n" + " Package Link: testpkgmdltags . | ");
checkOutput("moduleA-summary.html", true,
"moduleB | \n" + "testpkgmdlB | \n"); checkOutput("moduleB-summary.html", true, "TestClassInModuleB | \n" + "\n"
+ " With a test description for uses. \n | \n");
checkOutput("moduletags-summary.html", true,
"
transitive | \n" + "moduleB | \n" + "\n"
+ " This is a test description for the moduleB module. \n"
+ " | ",
"
---|
transitive static | \n" + "moduleA | \n" + "\n"
+ " This is a test description for the moduleA module with a Search "
+ "phrase search phrase. \n"
+ " | ",
"
---|
Modifier | \n" + "Module | \n" + "Description | ", "
---|
Modifier | \n" + "Module | \n" + "Description | ", "
---|
From | \n" + "Packages | \n" + "moduleB | \n" + "testpkgmdlB | \n"); } void checkModuleModeApi(boolean found) { checkOutput("moduleA-summary.html", found, "testpkgmdlA | \n" + ""); checkOutput("moduleB-summary.html", found, " | testpkgmdlB | \n" + "", " |
---|
Package | \n" + "Description | \n" + "
---|---|
testpkgmdlB | \n" + "\n" + " |
@Deprecated\n" + "
", "@AnnotationType(optional=\"Module Annotation\",\n" + " required=2016)\n" + "
"); checkOutput("moduleB-summary.html", false, "@AnnotationTypeUndocumented"); } void checkOverviewFrame(boolean found) { checkOutput("index.html", !found, ""); checkOutput("index.html", found, ""); } void checkModuleSummaryNoExported(boolean found) { checkOutput("moduleNoExport-summary.html", found, "\n" + "\n" + "\n" + "", "