Path: blob/master/test/langtools/jdk/javadoc/doclet/testDocFileDir/TestDocFileDir.java
66646 views
/*1* Copyright (c) 2002, 2021, 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 4258405 4973606 802409626* @summary This test verifies that the doc-file directory does not27* get overwritten when the sourcepath is equal to the destination28* directory.29* Also test that -docfilessubdirs and -excludedocfilessubdir both work.30* @library /tools/lib ../../lib31* @modules jdk.javadoc/jdk.javadoc.internal.tool32* @build toolbox.ToolBox javadoc.tester.*33* @run main TestDocFileDir34*/3536import javadoc.tester.JavadocTester;37import toolbox.ToolBox;3839public class TestDocFileDir extends JavadocTester {4041public static void main(String... args) throws Exception {42TestDocFileDir tester = new TestDocFileDir();43tester.runTests();44}4546ToolBox tb = new ToolBox();4748// Output dir = "", Input dir = ""49@Test50public void test1() {51tb.copyDir(testSrc("pkg"), "pkg");52setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES);53javadoc("pkg/C.java");54checkExit(Exit.OK);55checkOutput("pkg/doc-files/testfile.txt", true,56"This doc file did not get trashed.");57}5859// Output dir = Input Dir60@Test61public void test2() {62String outdir = "out2";63tb.copyDir(testSrc("pkg"), outdir + "/pkg");64setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES);65javadoc("-d", outdir,66"-sourcepath", "blah" + PS + outdir + PS + "blah",67"pkg");68checkExit(Exit.OK);69checkOutput("pkg/doc-files/testfile.txt", true,70"This doc file did not get trashed.");71}7273// Exercising -docfilessubdirs and -excludedocfilessubdir74@Test75public void test3() {76String outdir = "out3";77setOutputDirectoryCheck(DirectoryCheck.NONE);78javadoc("-d", outdir,79"-sourcepath", testSrc,80"-docfilessubdirs",81"-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",82"pkg");83checkExit(Exit.OK);84checkFiles(true,85"pkg/doc-files/subdir-used1/testfile.txt",86"pkg/doc-files/subdir-used2/testfile.txt");87checkFiles(false,88"pkg/doc-files/subdir-excluded1/testfile.txt",89"pkg/doc-files/subdir-excluded2/testfile.txt");90}91}929394