/* * 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 * @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", "-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", "-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", "-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", "-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", "-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", "--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", "--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", "-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", "--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", "-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 void testAllMode() { javadoc("-d", "out-all", "-use", "--show-module-contents=all", "-author", "-version", "-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 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); } void checkDescription(boolean found) { checkOutput("moduleA-summary.html", found, "\n" + "\n" + "\n" + "\n" + "
This is a test description for the moduleA module. Search " + "phrase search phrase.
"); checkOutput("moduleB-summary.html", found, "\n" + "\n" + "\n" + "\n" + "
This is a test description for the moduleB module. Search " + "word search_word with no description.
"); checkOutput("overview-summary.html", found, "\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "\n" + ""); checkOutput("overview-summary.html", false, "
Modules 
\n" + "
\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "\n" + ""); } void checkNoDescription(boolean found) { checkOutput("moduleA-summary.html", found, "
\n" + "
Modules 
\n" + ""); checkOutput("overview-summary.html", false, "
Modules 
\n" + "
\n" + "\n" + "
\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "\n" + ""); } void checkHtml5NoDescription(boolean found) { checkOutput("moduleA-summary.html", found, "
\n" + "
    \n" + "
  • \n" + "
      \n" + "
    • \n" + ""); checkOutput("moduleB-summary.html", found, "
      \n" + "
        \n" + "
      • \n" + "
          \n" + "
        • \n" + ""); } void checkModuleLink() { checkOutput("overview-summary.html", true, "
        • Module
        • "); checkOutput("moduleA-summary.html", true, "
        • Module
        • "); checkOutput("moduleB-summary.html", true, "
        • Module
        • "); checkOutput("testpkgmdlA/class-use/TestClassInModuleA.html", true, "
        • Module
        • "); checkOutput("testpkgmdlB/package-summary.html", true, "
        • Module
        • "); checkOutput("testpkgmdlB/TestClassInModuleB.html", true, "
        • Module
        • "); checkOutput("testpkgmdlB/class-use/TestClassInModuleB.html", true, "
        • Module
        • "); } void checkNoModuleLink() { checkOutput("testpkgnomodule/package-summary.html", true, "
            \n" + "
          • Package
          • "); checkOutput("testpkgnomodule/TestClassNoModule.html", true, "
              \n" + "
            • Package
            • "); checkOutput("testpkgnomodule/class-use/TestClassNoModule.html", true, "
                \n" + "
              • Package
              • "); } void checkModuleTags() { checkOutput("moduletags-summary.html", true, "Type Link: TestClassInModuleTags.", "Member Link: testMethod(String).", "Package Link: testpkgmdltags.", "
                Since:
                \n" + "
                JDK 9
                ", "
                See Also:
                \n" + "
                \"Test see tag\", \n" + "" + "TestClassInModuleTags
                ", "
                Regular Tag:
                \n" + "
                Just a regular simple tag.
                ", "
                Module Tag:
                \n" + "
                Just a simple module tag.
                ", "
                Version:
                \n" + "
                1.0
                ", "
                Author:
                \n" + "
                Bhavesh Patel
                "); checkOutput("testpkgmdltags/TestClassInModuleTags.html", false, "
                Module Tag:
                \n" + "
                Just a simple module tag.
                "); } void checkOverviewSummaryModules() { checkOutput("overview-summary.html", true, "
Modules 
\n" + "\n" + "\n" + "\n" + "\n" + ""); checkOutput("overview-summary.html", false, "
Modules 
ModuleDescription
\n" + "\n" + "\n" + "\n" + "\n" + ""); } void checkOverviewSummaryPackages() { checkOutput("overview-summary.html", false, "
Packages 
PackageDescription
\n" + "\n" + "\n" + "\n" + "\n" + "", "
Modules 
ModuleDescription
\n" + "
\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "\n" + ""); checkOutput("overview-summary.html", true, "
Packages 
\n" + "\n" + "\n" + "\n" + "\n" + "", "\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "
Packages 
PackageDescription
\n" + ""); } void checkHtml5OverviewSummaryModules() { checkOutput("overview-summary.html", true, "
Packages 
\n" + "\n" + "\n" + "\n" + "\n" + ""); checkOutput("overview-summary.html", false, "
Modules 
ModuleDescription
\n" + "\n" + "\n" + "\n" + "\n" + ""); } void checkHtml5OverviewSummaryPackages() { checkOutput("overview-summary.html", false, "
Packages 
PackageDescription
\n" + "\n" + "\n" + "\n" + "\n" + "", "
Modules 
ModuleDescription
\n" + "
\n" + "
\n" + "
\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "\n" + ""); checkOutput("overview-summary.html", true, "
Packages 
\n" + "\n" + "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "
\n" + "
\n" + "
The overview summary page header.
\n" + "
\n" + "
\n" + "
Packages 
PackageDescription
\n" + ""); } void checkModuleSummary() { checkOutput("moduleA-summary.html", true, "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "\n" + ""); checkOutput("moduleB-summary.html", true, "
  • Description | Modules | " + "Packages | " + "Services
  • ", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "\n" + "", "\n" + "\n" + "\n" + "\n" + ""); } void checkAggregatorModuleSummary() { checkOutput("moduleT-summary.html", true, "
    \n" + "

    Module moduleT

    \n" + "
    ", "
    This is a test description for the moduleT module. " + "Search phrase search phrase. " + "Make sure there are no exported packages.
    ", "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + ""); } void checkNegatedModuleSummary() { checkOutput("moduleA-summary.html", false, "\n" + "\n" + "\n" + ""); } void checkModuleClickThroughLinks() { checkOutput("module-overview-frame.html", true, "
  • moduleA
  • ", "
  • moduleB
  • "); checkOutput("script.js", true, "function updateModuleFrame(pFrame, cFrame)\n" + "{\n" + " top.packageFrame.location = pFrame;\n" + " top.classFrame.location = cFrame;\n" + "}"); } void checkModuleClickThrough(boolean found) { checkFiles(found, "moduleA-type-frame.html", "moduleB-type-frame.html"); } void checkModuleFilesAndLinks(boolean found) { checkFileAndOutput("testpkgmdlA/package-summary.html", found, "
  • Module
  • ", "
    Module " + "moduleA
    "); checkFileAndOutput("testpkgmdlA/TestClassInModuleA.html", found, "
  • Module
  • ", "
    Module " + "moduleA
    "); checkFileAndOutput("testpkgmdlB/AnnotationType.html", found, "
    Module " + "moduleB
    ", "
    " + "Package testpkgmdlB
    "); checkFiles(found, "moduleA-frame.html", "moduleA-summary.html", "module-overview-frame.html"); } void checkModulesInSearch(boolean found) { checkOutput("index-all.html", found, "
    \n" + "
    moduleA - module moduleA
    \n" + "
    \n" + "
    This is a test description for the moduleA module.
    \n" + "
    \n" + "
    moduleB - module moduleB
    \n" + "
    \n" + "
    This is a test description for the moduleB module.
    \n" + "
    \n" + "
    ", "
    \n" + "
    " + "search phrase - Search tag in moduleA
    \n" + "
    with description
    \n" + "
    " + "search_word - Search tag in moduleB
    \n" + "
     
    \n" + "
    "); } void checkModuleModeCommon() { checkOutput("overview-summary.html", true, "\n" + "", "\n" + "", "\n" + ""); checkOutput("moduleA-summary.html", true, "
  • Description | " + "Modules | Packages | Services
  • ", "\n" + "\n"); checkOutput("moduleB-summary.html", true, "\n" + ""); checkOutput("moduletags-summary.html", true, "
  • Description | Modules" + " | Packages | Services
  • ", "
    Packages 
    testpkgmdlA 
    transitivemoduleB\n" + "
    This is a test description for the moduleB module.
    \n" + "
    testpkgmdlB 
    TestClassInModuleBWith a test description for uses. 
    Opens 
    PackageDescription
    Uses 
    TypeDescription
    Provides 
    TypeDescription
    transitivemoduleA\n" + "
    This is a test description for the moduleA module.
    \n" + "
    transitivemoduleB\n" + "
    This is a test description for the moduleB module.
    \n" + "
    moduleA\n" + "
    This is a test description for the moduleA module.
    \n" + "
    moduleB\n" + "
    This is a test description for the moduleB module.
    \n" + "
    moduletags\n" + "
    This is a test description for the moduleA module.
    \n" + " Type Link: TestClassInModuleTags.
    \n" + " Member Link: testMethod(String).
    \n" + " Package Link: testpkgmdltags.
    \n" + "
    moduleBtestpkgmdlBTestClassInModuleBWith a test description for uses. 
    \n" + "", "\n" + "\n" + "", "
    Indirect Requires 
    transitivemoduleB\n" + "
    This is a test description for the moduleB module.
    \n" + "
    \n" + "", "\n" + "\n" + "", "
    Indirect Exports 
    transitive staticmoduleA\n" + "
    This is a test description for the moduleA module.
    \n" + "
    \n" + "\n" + "\n" + "\n" + "\n" + "", "
    Requires 
    ModifierModuleDescription
    \n" + "\n" + "\n" + "\n" + "\n" + "", "
    Indirect Requires 
    ModifierModuleDescription
    \n" + "\n" + "\n" + "\n" + "\n" + "\n", "\n" + "\n"); } void checkModuleModeApi(boolean found) { checkOutput("moduleA-summary.html", found, "\n" + ""); checkOutput("moduleB-summary.html", found, "
  • Description | Modules | " + "Packages | Services
  • ", "\n" + "", "
    Indirect Opens 
    FromPackages
    moduleBtestpkgmdlBtestpkgmdlA testpkgmdlB 
    \n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "
    Opens 
    PackageDescription
    testpkgmdlB 
    "); checkOutput("moduletags-summary.html", found, "testpkgmdltags\n" + " "); } void checkModuleModeAll(boolean found) { checkOutput("moduleA-summary.html", found, " \n" + "java.base\n" + " ", " \n" + "moduleC\n" + "\n" + "
    This is a test description for the moduleC module.
    \n" + "", "moduleC\n" + "testpkgmdlC", "testpkgmdlA\n" + "All Modules\n" + " ", "All Packages " + "Exports" + " " + "Concealed ", "concealedpkgmdlA\n" + "None\n" + " "); checkOutput("moduleB-summary.html", found, "
  • Description | " + "Modules | Packages | Services
  • ", "testpkgmdlB\n" + "All Modules\n" + " ", " \n" + "java.base\n" + " ", "TestClass2InModuleB\n" + " ", "TestInterface2InModuleB\n" + " 
    (Implementation(s): TestClass2InModuleB)", "TestInterfaceInModuleB\n" + " 
    (Implementation(s): TestClassInModuleB)", "All Packages " + "Exports " + "Opens "); checkOutput("moduleC-summary.html", found, "Exports \n" + "\n" + "Package\n" + "Module\n" + "Description\n" + ""); checkOutput("moduletags-summary.html", found, "testpkgmdltags\n" + "All Modules\n" + " "); } void checkModuleDeprecation(boolean found) { checkOutput("moduleA-summary.html", found, "
    Deprecated, for removal:" + " This API element is subject to removal in a future version.\n" + "
    This module is deprecated.
    \n" + "
    "); checkOutput("deprecated-list.html", found, "", "\n" + "moduleA\n" + "\n" + "
    This module is deprecated.
    \n" + "\n" + ""); checkOutput("moduleB-summary.html", !found, "
    Deprecated.\n" + "
    This module is deprecated using just the javadoc tag.
    "); checkOutput("moduletags-summary.html", found, "

    @Deprecated\n" + "

    ", "
    Deprecated.
    "); } void checkModuleAnnotation() { checkOutput("moduleB-summary.html", true, "

    @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" + "", "Concealed "); } }