Path: blob/master/test/langtools/jdk/javadoc/doclet/testAuthor/TestAuthor.java
40971 views
/*1* Copyright (c) 2018, 2020, 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 8202947 823980426* @summary test the at-author tag, and corresponding option27* @library /tools/lib ../../lib28* @modules jdk.javadoc/jdk.javadoc.internal.tool29* @build toolbox.ToolBox javadoc.tester.*30* @run main TestAuthor31*/3233import java.nio.file.Files;34import java.nio.file.Path;35import java.nio.file.Paths;3637import javadoc.tester.JavadocTester;38import toolbox.ToolBox;3940public class TestAuthor extends JavadocTester {4142public static void main(String... args) throws Exception {43TestAuthor tester = new TestAuthor();44tester.runTests();45}4647ToolBox tb = new ToolBox();48Path src;4950TestAuthor() throws Exception {51src = Files.createDirectories(Paths.get("src"));52tb.writeJavaFiles(src,53"""54package pkg;55/** Introduction.\s56* @author anonymous57*/58public class Test { }59""");60}6162@Test63public void testAuthor() {64javadoc("-d", "out-author",65"-sourcepath", src.toString(),66"-author",67"pkg");68checkExit(Exit.OK);6970checkAuthor(true);71}7273@Test74public void testNoAuthor() {75javadoc("-d", "out-noauthor",76"-sourcepath", src.toString(),77"pkg");78checkExit(Exit.OK);7980checkAuthor(false);81}8283void checkAuthor(boolean on) {84checkOutput("pkg/Test.html", on,85"""86<dl class="notes">87<dt>Author:</dt>88<dd>anonymous</dd>89</dl>""");90}91}929394