test/langtools/jdk/javadoc/doclet/testJavaPackage/TestJavaPackage.java
author jjg
Thu, 21 Feb 2019 15:17:42 -0800
changeset 53881 db24a4cb8139
permissions -rw-r--r--
8216170: java.lang.IllegalArgumentException: directories not supported Reviewed-by: hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53881
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     1
/*
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     4
 *
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     8
 *
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    13
 * accompanied this code).
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    14
 *
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    18
 *
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    21
 * questions.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    22
 */
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    23
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    24
/*
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    25
 * @test
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    26
 * @bug     8216170
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    27
 * @summary java.lang.IllegalArgumentException: directories not supported
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    28
 * @library /tools/lib ../../lib
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.main
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    31
 *          jdk.javadoc/jdk.javadoc.internal.api
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    32
 *          jdk.javadoc/jdk.javadoc.internal.tool
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    33
 * @build toolbox.ToolBox javadoc.tester.*
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    34
 * @run main TestJavaPackage
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    35
 */
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    36
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    37
import java.io.IOException;
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    38
import java.nio.file.Path;
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    39
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    40
import toolbox.ModuleBuilder;
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    41
import toolbox.ToolBox;
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    42
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    43
import javadoc.tester.JavadocTester;
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    44
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    45
public class TestJavaPackage extends JavadocTester {
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    46
    public static void main(String... args) throws Exception {
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    47
        TestJavaPackage tester = new TestJavaPackage();
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    48
        tester.runTests();
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    49
    }
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    50
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    51
    private final ToolBox tb = new ToolBox();
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    52
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    53
    @Test
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    54
    public void testPackage() throws IOException {
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    55
        Path src = Path.of("src");
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    56
        tb.writeJavaFiles(src,
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    57
            "module com.example.java { exports com.example.java; }",
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    58
            "package com.example.java; public class C { }");
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    59
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    60
        // Disable the standard check that the output directory is empty.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    61
        // It is a significant part of the test case that the output directory
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    62
        // is set to the current directory, which (in this case) also contains
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    63
        // the src/ directory.
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    64
        setOutputDirectoryCheck(DirectoryCheck.NONE);
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    65
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    66
        javadoc("-d", ".",  // using "." is important for the test case
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    67
                "-sourcepath", src.toString(),
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    68
                "com.example.java");
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    69
        checkExit(Exit.OK);
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    70
        checkFiles(true,
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    71
            "com.example.java/com/example/java/C.html");
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    72
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    73
        // repeat the call, to verify the package name "com.example.java" is not
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    74
        // confused with the output directory for the "com.example.java" module,
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    75
        // created by the first call
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    76
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    77
        javadoc("-d", ".",  // using "." is important for the test case
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    78
                "-sourcepath", src.toString(),
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    79
                "com.example.java");
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    80
        checkExit(Exit.OK);
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    81
        checkFiles(true,
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    82
            "com.example.java/com/example/java/C.html");
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    83
    }
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    84
}
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    85
db24a4cb8139 8216170: java.lang.IllegalArgumentException: directories not supported
jjg
parents:
diff changeset
    86