/*
* Copyright (c) 2016, 2019, 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 8182765 8196200 8196201 8196202 8196202 8205593 8202462
8184205
* @summary Test modules support in javadoc.
* @author bpatel
* @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build javadoc.tester.*
* @run main TestModules
*/
import javadoc.tester.JavadocTester;
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 5.
*/
@Test
public void testHtml5() {
javadoc("-d", "out-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();
checkModuleFilesAndLinks(true);
checkModulesInSearch(true);
checkAllPkgsAllClasses(true);
}
/**
* Test generated module pages for HTML 5 with -nocomment option.
*/
@Test
public void testHtml5NoComment() {
javadoc("-d", "out-html5-nocomment",
"-nocomment",
"-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);
}
/**
* Test generated pages, in an unnamed module, for HTML 5.
*/
@Test
public void testHtml5UnnamedModule() {
javadoc("-d", "out-html5-nomodule",
"-use",
"-overview", testSrc("overview.html"),
"-sourcepath", testSrc,
"testpkgnomodule", "testpkgnomodule1");
checkExit(Exit.OK);
checkHtml5OverviewSummaryPackages();
checkModuleFilesAndLinks(false);
checkModulesInSearch(false);
}
/**
* Test generated module pages with javadoc tags.
*/
@Test
public 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
public 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
public 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
public void testModuleFilesAndLinks() {
javadoc("-d", "out-modulelinks",
"-Xdoclint:none",
"--module-source-path", testSrc,
"--module", "moduleA,moduleB",
"testpkgmdlA", "testpkgmdlB");
checkExit(Exit.OK);
checkModuleFilesAndLinks(true);
}
/**
* Test generated module pages for a deprecated module.
*/
@Test
public 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
public 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
public 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);
}
/**
* Test module summary pages in "all" mode.
*/
@Test
public 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);
}
/**
* Test generated module summary page of a module with no exported package.
*/
@Test
public 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
public 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
public void testSingleModuleSinglePkg() {
javadoc("-d", "out-singlemod",
"--module-source-path", testSrc,
"--module", "moduleC",
"testpkgmdlC");
checkExit(Exit.OK);
}
/**
* Test generated module pages for javadoc run for a single module having multiple packages.
*/
@Test
public void testSingleModuleMultiplePkg() {
javadoc("-d", "out-singlemodmultiplepkg",
"--show-module-contents=all",
"-Xdoclint:none",
"--module-source-path", testSrc,
"--module", "moduleB",
"testpkg2mdlB", "testpkgmdlB");
checkExit(Exit.OK);
}
/**
* Test -group option for modules. The overview-summary.html page should group the modules accordingly.
*/
@Test
public 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
public 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
public 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
public 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
public 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
public 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
public 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/module-summary.html", found,
"\n"
+ "\n"
+ "\n"
+ "\n"
+ "
This is a test description for the moduleA module with a Search "
+ "phrase search phrase.