TestDocFileDir.java revision 2382:903e207a9fac
1/*
2 * Copyright (c) 2002, 2014, 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
24import java.io.File;
25
26/*
27 * @test
28 * @bug 4258405 4973606 8024096
29 * @summary This test verifies that the doc-file directory does not
30 *          get overwritten when the sourcepath is equal to the destination
31 *          directory.
32 *          Also test that -docfilessubdirs and -excludedocfilessubdir both work.
33 * @author jamieh
34 * @library ../lib/
35 * @build JavadocTester
36 * @build TestDocFileDir
37 * @run main TestDocFileDir
38 */
39
40public class TestDocFileDir extends JavadocTester {
41
42    private static final String[][] TEST1 = {
43        { "pkg/doc-files/testfile.txt",
44            "This doc file did not get trashed."}
45        };
46
47    private static final String[] FILE_TEST2 = {
48        "pkg/doc-files/subdir-used1/testfile.txt",
49        "pkg/doc-files/subdir-used2/testfile.txt"
50    };
51    private static final String[] FILE_NEGATED_TEST2 = {
52        "pkg/doc-files/subdir-excluded1/testfile.txt",
53        "pkg/doc-files/subdir-excluded2/testfile.txt"
54    };
55
56    private static final String[][] TEST0 = {
57        {"pkg/doc-files/testfile.txt",
58            "This doc file did not get trashed."}
59        };
60
61    //Output dir = Input Dir
62    private static final String[] ARGS1 =
63        new String[] {
64            "-d", OUTPUT_DIR + "-1",
65            "-sourcepath",
66            "blah" + File.pathSeparator + OUTPUT_DIR + "-1" +
67            File.pathSeparator + "blah", "pkg"};
68
69    //Exercising -docfilessubdirs and -excludedocfilessubdir
70    private static final String[] ARGS2 =
71        new String[] {
72            "-d", OUTPUT_DIR + "-2",
73            "-sourcepath", SRC_DIR,
74            "-docfilessubdirs",
75            "-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",
76            "pkg"};
77
78    //Output dir = "", Input dir = ""
79    private static final String[] ARGS0 =
80        new String[] {"pkg/C.java"};
81
82
83    /**
84     * The entry point of the test.
85     * @param args the array of command line arguments.
86     */
87    public static void main(String[] args) {
88        TestDocFileDir tester = new TestDocFileDir();
89        copyDir(SRC_DIR + "/pkg", ".");
90        tester.run(ARGS0, TEST0, NO_TEST);
91        copyDir(SRC_DIR + "/pkg", OUTPUT_DIR + "-1");
92        tester.run(ARGS1, TEST1, NO_TEST);
93        tester.run(ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2);
94        tester.printSummary();
95    }
96}
97