Path: blob/master/test/langtools/jdk/javadoc/tool/removeOldDoclet/RemoveOldDoclet.java
40974 views
/*1* Copyright (c) 2019, 2021, 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 821558426* @summary Remove support for the "old" doclet API in com/sun/javadoc27* @library /tools/lib ../../lib28* @modules jdk.javadoc/jdk.javadoc.internal.tool29* @build javadoc.tester.* toolbox.ToolBox builder.ClassBuilder30* @run main RemoveOldDoclet31*/323334import java.nio.file.Path;35import java.nio.file.Paths;3637import builder.ClassBuilder;38import toolbox.ToolBox;3940import javadoc.tester.JavadocTester;4142public class RemoveOldDoclet extends JavadocTester {4344final ToolBox tb;45static final String Doclet_CLASS_NAME = TestDoclet.class.getName();4647public static void main(String... args) throws Exception {48RemoveOldDoclet tester = new RemoveOldDoclet();49tester.runTests(m -> new Object[]{Paths.get(m.getName())});50}5152RemoveOldDoclet() {53tb = new ToolBox();54}5556@Test57public void testInvalidDoclet(Path base) throws Exception {58Path srcDir = base.resolve("src");59Path outDir = base.resolve("out");6061new ClassBuilder(tb, "pkg.A")62.setModifiers("public", "class")63.write(srcDir);6465javadoc("-d", outDir.toString(),66"-doclet", Doclet_CLASS_NAME,67"-docletpath", System.getProperty("test.classes", "."),68"-sourcepath", srcDir.toString(),69"pkg");7071checkExit(Exit.ERROR);72checkOutput(Output.OUT, true, String.format("""73error: Class %s is not a valid doclet.74Note: As of JDK 13, the com.sun.javadoc API is no longer supported.""",75Doclet_CLASS_NAME));76}7778static class TestDoclet {79public static boolean start() {80System.out.println("OLD_DOCLET_MARKER");81return true;82}83}84}858687