Path: blob/master/test/langtools/jdk/javadoc/tool/EncodingTest.java
40957 views
/*1* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 818864926* @summary ensure javadoc -encoding is not ignored27* @modules jdk.compiler/com.sun.tools.javac.api28* @modules jdk.compiler/com.sun.tools.javac.main29* @modules jdk.javadoc/jdk.javadoc.internal.api30* @modules jdk.javadoc/jdk.javadoc.internal.tool31* @library /tools/lib32* @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox33* @run main EncodingTest34*/3536import java.io.IOException;37import java.nio.charset.StandardCharsets;38import java.nio.file.Files;39import java.nio.file.Path;40import java.nio.file.Paths;4142import toolbox.JavadocTask;43import toolbox.Task;44import toolbox.TestRunner;45import toolbox.ToolBox;4647public class EncodingTest extends TestRunner {48public static void main(String... args) throws Exception {49EncodingTest t = new EncodingTest();50t.runTests();51}5253private final ToolBox tb = new ToolBox();54private final Path src = Paths.get("src");55private final Path api = Paths.get("api");5657EncodingTest() throws Exception {58super(System.err);59init();60}6162void init() throws IOException {63Files.createDirectories(src);64Files.write(src.resolve("C.java"),65"/** \u03b1\u03b2\u03b3 */ public class C { }".getBytes(StandardCharsets.UTF_8));66}6768@Test69public void testEncoding() {70Task.Result result = new JavadocTask(tb, Task.Mode.EXEC)71.outdir(api)72.options("-J-Dfile.encoding=ASCII",73"-encoding", "UTF-8",74"-docencoding", "UTF-8")75.files(src.resolve("C.java"))76.run(Task.Expect.SUCCESS)77.writeAll();78}79}80818283