Path: blob/master/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java
40971 views
/*1* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 8157349 8185985 8194953 821473826* @summary test copy of doc-files, and its contents for HTML meta content.27* @library ../../lib28* @modules jdk.javadoc/jdk.javadoc.internal.tool29* @build javadoc.tester.*30* @run main TestCopyFiles31*/3233import javadoc.tester.JavadocTester;3435public class TestCopyFiles extends JavadocTester {3637public static void main(String... args) throws Exception {38TestCopyFiles tester = new TestCopyFiles();39tester.runTests();40}4142@Test43public void testDocFilesInModulePackages() {44javadoc("-d", "modules-out",45"-top", "phi-TOP-phi",46"-bottom", "phi-BOTTOM-phi",47"-header", "phi-HEADER-phi",48"-footer", "phi-FOOTER-phi",49"-windowtitle", "phi-WINDOW-TITLE-phi",50"--module-source-path", testSrc("modules"),51"--module", "acme.mdle");52checkExit(Exit.OK);53checkOrder("acme.mdle/p/doc-files/inpackage.html",54"""55"Hello World" (phi-WINDOW-TITLE-phi)""",56"phi-TOP-phi",57// check top navbar58"phi-HEADER-phi",59"""60<a href="../../module-summary.html">Module</a>""",61"""62<a href="../package-summary.html">Package</a>""",63"""64<a href="../../../overview-tree.html">Tree</a>""",65"""66<a href="../../../deprecated-list.html">Deprecated</a>""",67"""68<a href="../../../index-all.html">Index</a>""",69"""70In a named module acme.module and named package <a href="../package-summary.html"><code>p</code></a>.""",71"<dt>Since:</",72"forever",73// check footer74"phi-BOTTOM-phi"75);76}7778@Test79public void testDocFilesInMultiModulePackagesWithRecursiveCopy() {80javadoc("-d", "multi-modules-out-recursive",81"-docfilessubdirs",82"-top", "phi-TOP-phi",83"-bottom", "phi-BOTTOM-phi",84"-header", "phi-HEADER-phi",85"-footer", "phi-FOOTER-phi",86"-windowtitle", "phi-WINDOW-TITLE-phi",87"--module-source-path", testSrc("modules"),88"--module", "acme.mdle,acme2.mdle");89checkExit(Exit.OK);90checkOrder("acme.mdle/p/doc-files/inpackage.html",91"""92"Hello World" (phi-WINDOW-TITLE-phi)""",93"phi-TOP-phi",94// check top navbar95"phi-HEADER-phi",96"""97<a href="../../module-summary.html">Module</a>""",98"""99<a href="../package-summary.html">Package</a>""",100"""101<a href="../../../overview-tree.html">Tree</a>""",102"""103<a href="../../../deprecated-list.html">Deprecated</a>""",104"""105<a href="../../../index-all.html">Index</a>""",106"""107In a named module acme.module and named package <a href="../package-summary.html"><code>p</code></a>.""",108"<dt>Since:</",109"forever",110// check footer111"phi-BOTTOM-phi"112);113114// check the bottom most doc file115checkOrder("acme2.mdle/p2/doc-files/sub-dir/sub-dir-1/SubSubReadme.html",116"SubSubReadme (phi-WINDOW-TITLE-phi)",117"phi-TOP-phi",118// check top navbar119"phi-HEADER-phi",120"""121<a href="../../../../module-summary.html">Module</a>""",122"""123<a href="../../../package-summary.html">Package</a>""",124"""125<a href="../../../../../overview-tree.html">Tree</a>""",126"""127<a href="../../../../../deprecated-list.html">Deprecated</a>""",128"""129<a href="../../../../../index-all.html">Index</a>""",130"SubSubReadme.html at third level of doc-file directory.",131// check footer132"phi-BOTTOM-phi"133);134}135136@Test137public void testDocFilesInModulePackagesWithRecursiveCopy() {138javadoc("-d", "modules-out-recursive",139"-docfilessubdirs",140"--module-source-path", testSrc("modules"),141"--module", "acme.mdle");142checkExit(Exit.OK);143checkOutput("acme.mdle/p/doc-files/inpackage.html", true,144"""145In a named module acme.module and named package <a href="../package-summary.html"><code>p</code></a>."""146);147}148149@Test150public void testDocFilesInModulePackagesWithRecursiveCopyWithExclusion() {151javadoc("-d", "modules-out-recursive-with-exclusion",152"-docfilessubdirs",153"-excludedocfilessubdir", "sub-dir",154"--module-source-path", testSrc("modules"),155"--module", "acme.mdle");156checkExit(Exit.OK);157checkOutput("acme.mdle/p/doc-files/inpackage.html", true,158"""159In a named module acme.module and named package <a href="../package-summary.html"><code>p</code></a>."""160);161}162163@Test164public void testDocFilesInPackages() {165javadoc("-d", "packages-out",166"-sourcepath", testSrc("packages"),167"p1");168checkExit(Exit.OK);169checkOutput("p1/doc-files/inpackage.html", true,170"A named package in an unnamed module"171);172}173174@Test175public void testDocFilesInPackagesWithRecursiveCopy() {176javadoc("-d", "packages-out-recursive",177"-docfilessubdirs",178"-sourcepath", testSrc("packages"),179"p1");180checkExit(Exit.OK);181182checkOutput("p1/doc-files/inpackage.html", true,183"A named package in an unnamed module"184);185186checkOutput("p1/doc-files/sub-dir/SubReadme.html", true,187"<title>SubReadme</title>",188"SubReadme.html at second level of doc-file directory."189);190}191192@Test193public void testDocFilesInPackagesWithRecursiveCopyWithExclusion() {194javadoc("-d", "packages-out-recursive-with-exclusion",195"-docfilessubdirs",196"-excludedocfilessubdir", "sub-dir",197"-sourcepath", testSrc("packages"),198"p1");199checkExit(Exit.OK);200201checkOutput("p1/doc-files/inpackage.html", true,202"A named package in an unnamed module"203);204}205206@Test207public void testDocFilesInUnnamedPackages() {208javadoc("-d", "unnamed-out",209"-windowtitle", "phi-WINDOW-TITLE-phi",210"-sourcepath", testSrc("unnamed"),211testSrc("unnamed/Foo.java")212);213checkExit(Exit.OK);214checkOutput("doc-files/inpackage.html", true,215"""216<title>(phi-WINDOW-TITLE-phi)</title>217""",218"In an unnamed package"219);220}221222@Test223public void testDocFilesInUnnamedPackagesWithRecursiveCopy() {224javadoc("-d", "unnamed-out-recursive",225"-docfilessubdirs",226"-windowtitle", "phi-WINDOW-TITLE-phi",227"-sourcepath", testSrc("unnamed"),228testSrc("unnamed/Foo.java")229);230checkExit(Exit.OK);231checkOutput("doc-files/inpackage.html", true,232"""233<title>(phi-WINDOW-TITLE-phi)</title>234""",235"In an unnamed package"236);237checkOutput("doc-files/doc-file/SubReadme.html", true,238"""239<title>Beep Beep (phi-WINDOW-TITLE-phi)</title>240""",241"SubReadme.html at second level of doc-file directory for unnamed package."242);243}244245@Test246public void testDocFilesInPackagesSource7() {247javadoc("-d", "packages-out-src7",248"-source", "7",249"-sourcepath", testSrc("packages"),250"p1");251checkExit(Exit.OK);252checkOutput("p1/doc-files/inpackage.html", true,253"A named package in an unnamed module"254);255}256257@Test258public void testDocFilesInPackagesSource7UsingClassPath() {259javadoc("-d", "packages-out-src7-cp",260"-source", "7",261"-classpath", testSrc("packages"),262"p1");263checkExit(Exit.OK);264checkOutput("p1/doc-files/inpackage.html", true,265"A named package in an unnamed module"266);267}268269@Test270public void testCopyThrough() {271javadoc("-d", "copy",272"-sourcepath", testSrc("packages"),273"p2");274checkExit(Exit.OK);275checkOutput("p2/doc-files/case2.html", true,276"<!-- Generated by javadoc",277"""278<style type="text/css">279body {280font-family: Helvetica, Arial, sans-serif;281font-size: 14px;282}283</style>""");284checkOutput("p2/doc-files/case3.html", true,285"<!-- Generated by javadoc",286"""287<style>288h1 {color:red;}289p {color:blue;}290</style>""");291checkOutput("p2/doc-files/case4.html", true,292"<!-- Generated by javadoc",293"""294<link rel="stylesheet" type="text/css" href="theme.css">""");295}296}297298299