Path: blob/master/test/langtools/jdk/javadoc/doclet/testBadPackageFileInJar/TestBadPackageFileInJar.java
40971 views
/*1* Copyright (c) 2002, 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 4691095 630639426* @summary Make sure that Javadoc emits a useful warning27* when a bad package.html exists in a JAR archive.28* @library /tools/lib ../../lib29* @modules jdk.javadoc/jdk.javadoc.internal.tool30* @build javadoc.tester.* toolbox.ToolBox toolbox.JarTask31* @run main TestBadPackageFileInJar32*/3334import toolbox.JarTask;35import toolbox.Task.Result;36import toolbox.ToolBox;3738import java.io.IOException;39import java.nio.file.Path;40import java.nio.file.Paths;4142import javadoc.tester.JavadocTester;4344public class TestBadPackageFileInJar extends JavadocTester {4546final ToolBox tb = new ToolBox();4748public static void main(String... args) throws Exception {49TestBadPackageFileInJar tester = new TestBadPackageFileInJar();50tester.runTests();51}5253@Test54public void test() throws IOException {55// create the file56Path pkgDir = Paths.get("pkg");57tb.createDirectories(pkgDir);58Path pkgfilePath = pkgDir.resolve("package.html");59tb.writeFile(pkgfilePath, "<html>\n\n</html>");6061// create the jar file62Path jarFile = Paths.get("badPackageFileInJar.jar");63JarTask jar = new JarTask(tb, "badPackageFileInJar.jar");64jar.files(pkgDir.toString()).run();6566// clean up to prevent accidental pick up67tb.cleanDirectory(pkgDir);68tb.deleteFiles(pkgDir.toString());6970javadoc("-d", "out",71"-sourcepath", testSrc,72"-classpath", jarFile.toString(),73"pkg");74checkExit(Exit.OK);7576checkOutput(Output.OUT, true,77"badPackageFileInJar.jar(/pkg/package.html):1: warning: no comment");78}79}808182