test/langtools/jdk/javadoc/tool/AddOpensTest.java
changeset 48515 0da9fb7d7d04
equal deleted inserted replaced
48514:9608f7f41c4e 48515:0da9fb7d7d04
       
     1 /*
       
     2  * Copyright (c) 2018, 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 8181878
       
    27  * @summary javadoc should support/ignore --add-opens
       
    28  * @modules jdk.compiler/com.sun.tools.javac.api
       
    29  * @modules jdk.compiler/com.sun.tools.javac.main
       
    30  * @modules jdk.javadoc/jdk.javadoc.internal.api
       
    31  * @modules jdk.javadoc/jdk.javadoc.internal.tool
       
    32  * @library /tools/lib
       
    33  * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox
       
    34  * @run main AddOpensTest
       
    35  */
       
    36 
       
    37 import java.io.IOException;
       
    38 import java.nio.charset.StandardCharsets;
       
    39 import java.nio.file.Path;
       
    40 import java.nio.file.Paths;
       
    41 
       
    42 import toolbox.JavadocTask;
       
    43 import toolbox.Task;
       
    44 import toolbox.TestRunner;
       
    45 import toolbox.ToolBox;
       
    46 
       
    47 public class AddOpensTest extends TestRunner {
       
    48     public static void main(String... args) throws Exception {
       
    49         AddOpensTest t = new AddOpensTest();
       
    50         t.runTests();
       
    51     }
       
    52 
       
    53     private final ToolBox tb = new ToolBox();
       
    54     private final Path src = Paths.get("src");
       
    55     private final Path api = Paths.get("api");
       
    56 
       
    57     AddOpensTest() throws Exception {
       
    58         super(System.err);
       
    59         init();
       
    60     }
       
    61 
       
    62     void init() throws IOException {
       
    63         tb.writeJavaFiles(src, "public class C { }");
       
    64     }
       
    65 
       
    66     @Test
       
    67     public void testEncoding() {
       
    68         Task.Result result = new JavadocTask(tb, Task.Mode.EXEC)
       
    69                 .options("-d", api.toString(),
       
    70                         "--add-opens", "some.module")
       
    71                 .files(src.resolve("C.java"))
       
    72                 .run(Task.Expect.SUCCESS)
       
    73                 .writeAll();
       
    74     }
       
    75 }
       
    76