test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,118 @@
     1.4 +/*
     1.5 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +import java.io.File;
    1.28 +
    1.29 +/*
    1.30 + * @test
    1.31 + * @bug 4258405 4973606 8024096
    1.32 + * @summary This test verifies that the doc-file directory does not
    1.33 + *          get overwritten when the sourcepath is equal to the destination
    1.34 + *          directory.
    1.35 + *          Also test that -docfilessubdirs and -excludedocfilessubdir both work.
    1.36 + * @author jamieh
    1.37 + * @library ../lib/
    1.38 + * @build JavadocTester
    1.39 + * @build TestDocFileDir
    1.40 + * @run main TestDocFileDir
    1.41 + */
    1.42 +
    1.43 +public class TestDocFileDir extends JavadocTester {
    1.44 +
    1.45 +    private static final String BUG_ID = "4258405-4973606";
    1.46 +
    1.47 +    private static final String[][] TEST1 = {
    1.48 +        {BUG_ID + "-1" + FS + "pkg" + FS + "doc-files" + FS + "testfile.txt",
    1.49 +            "This doc file did not get trashed."}
    1.50 +        };
    1.51 +    private static final String[][] NEGATED_TEST1 = NO_TEST;
    1.52 +
    1.53 +    private static final String[] FILE_TEST2 = {
    1.54 +        BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used1" +
    1.55 +            FS + "testfile.txt",
    1.56 +        BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-used2" +
    1.57 +            FS + "testfile.txt"
    1.58 +    };
    1.59 +    private static final String[] FILE_NEGATED_TEST2 = {
    1.60 +        BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded1" +
    1.61 +            FS + "testfile.txt",
    1.62 +        BUG_ID + "-2" + FS + "pkg" + FS + "doc-files" + FS + "subdir-excluded2" +
    1.63 +            FS + "testfile.txt"
    1.64 +    };
    1.65 +
    1.66 +    private static final String[][] TEST0 = {
    1.67 +        {"pkg" + FS + "doc-files" + FS + "testfile.txt",
    1.68 +            "This doc file did not get trashed."}
    1.69 +        };
    1.70 +    private static final String[][] NEGATED_TEST0 = {};
    1.71 +
    1.72 +    //Output dir = Input Dir
    1.73 +    private static final String[] ARGS1 =
    1.74 +        new String[] {
    1.75 +            "-d", BUG_ID + "-1",
    1.76 +            "-sourcepath",
    1.77 +                "blah" + File.pathSeparator + BUG_ID + "-1" + File.pathSeparator + "blah",
    1.78 +            "pkg"};
    1.79 +
    1.80 +    //Exercising -docfilessubdirs and -excludedocfilessubdir
    1.81 +    private static final String[] ARGS2 =
    1.82 +        new String[] {
    1.83 +            "-d", BUG_ID + "-2",
    1.84 +            "-sourcepath", SRC_DIR,
    1.85 +            "-docfilessubdirs",
    1.86 +            "-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",
    1.87 +            "pkg"};
    1.88 +
    1.89 +    //Output dir = "", Input dir = ""
    1.90 +    private static final String[] ARGS0 =
    1.91 +        new String[] {"pkg" + FS + "C.java"};
    1.92 +
    1.93 +
    1.94 +    /**
    1.95 +     * The entry point of the test.
    1.96 +     * @param args the array of command line arguments.
    1.97 +     */
    1.98 +    public static void main(String[] args) {
    1.99 +        TestDocFileDir tester = new TestDocFileDir();
   1.100 +        copyDir(SRC_DIR + FS + "pkg", ".");
   1.101 +        run(tester, ARGS0, TEST0, NEGATED_TEST0);
   1.102 +        copyDir(SRC_DIR + FS + "pkg", BUG_ID + "-1");
   1.103 +        run(tester, ARGS1, TEST1, NEGATED_TEST1);
   1.104 +        run(tester, ARGS2, NO_TEST, NO_TEST, FILE_TEST2, FILE_NEGATED_TEST2);
   1.105 +        tester.printSummary();
   1.106 +    }
   1.107 +
   1.108 +    /**
   1.109 +     * {@inheritDoc}
   1.110 +     */
   1.111 +    public String getBugId() {
   1.112 +        return BUG_ID;
   1.113 +    }
   1.114 +
   1.115 +    /**
   1.116 +     * {@inheritDoc}
   1.117 +     */
   1.118 +    public String getBugName() {
   1.119 +        return getClass().getName();
   1.120 +    }
   1.121 +}

mercurial