1/* 2 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/* 25 * @test 26 * @bug 4258405 4973606 8024096 27 * @summary This test verifies that the doc-file directory does not 28 * get overwritten when the sourcepath is equal to the destination 29 * directory. 30 * Also test that -docfilessubdirs and -excludedocfilessubdir both work. 31 * @author jamieh 32 * @library ../lib 33 * @modules jdk.javadoc/jdk.javadoc.internal.tool 34 * @build JavadocTester 35 * @run main TestDocFileDir 36 */ 37 38public class TestDocFileDir extends JavadocTester { 39 40 public static void main(String... args) throws Exception { 41 TestDocFileDir tester = new TestDocFileDir(); 42 tester.runTests(); 43 } 44 45 // Output dir = "", Input dir = "" 46 @Test 47 void test1() { 48 copyDir(testSrc("pkg"), "."); 49 setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); 50 javadoc("pkg/C.java"); 51 checkExit(Exit.OK); 52 checkOutput("pkg/doc-files/testfile.txt", true, 53 "This doc file did not get trashed."); 54 } 55 56 // Output dir = Input Dir 57 @Test 58 void test2() { 59 String outdir = "out2"; 60 copyDir(testSrc("pkg"), outdir); 61 setOutputDirectoryCheck(DirectoryCheck.NO_HTML_FILES); 62 javadoc("-d", outdir, 63 "-sourcepath", "blah" + PS + outdir + PS + "blah", 64 "pkg"); 65 checkExit(Exit.OK); 66 checkOutput("pkg/doc-files/testfile.txt", true, 67 "This doc file did not get trashed."); 68 } 69 70 // Exercising -docfilessubdirs and -excludedocfilessubdir 71 @Test 72 void test3() { 73 String outdir = "out3"; 74 setOutputDirectoryCheck(DirectoryCheck.NONE); 75 javadoc("-d", outdir, 76 "-sourcepath", testSrc, 77 "-docfilessubdirs", 78 "-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2", 79 "pkg"); 80 checkExit(Exit.OK); 81 checkFiles(true, 82 "pkg/doc-files/subdir-used1/testfile.txt", 83 "pkg/doc-files/subdir-used2/testfile.txt"); 84 checkFiles(false, 85 "pkg/doc-files/subdir-excluded1/testfile.txt", 86 "pkg/doc-files/subdir-excluded2/testfile.txt"); 87 } 88} 89