/* * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 4904075 4774450 5015144 8043698 8196201 8203791 8184205 8260223 * 8256208 * @summary Reference unnamed package as "Unnamed", not empty string. * Generate a package summary for the unnamed package. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool * @build javadoc.tester.* * @run main TestUnnamedPackage */ import javadoc.tester.JavadocTester; public class TestUnnamedPackage extends JavadocTester { public static void main(String... args) throws Exception { TestUnnamedPackage tester = new TestUnnamedPackage(); tester.runTests(); } @Test public void test() { javadoc("-d", "out", "-sourcepath", testSrc("src1"), testSrc("src1/C.java")); checkExit(Exit.OK); checkOutput("index.html", true, """ """); checkOutput("package-summary.html", true, """

Unnamed Package

""", "This is a package comment for the unnamed package.", "This is a class in the unnamed package."); checkOutput("package-summary.html", true, "Unnamed Package"); checkOutput("package-tree.html", true, """

Hierarchy For Unnamed Package

"""); checkOutput("index-all.html", true, """ title="class in Unnamed Package\""""); checkOutput("C.html", true, ""); checkOutput("allclasses-index.html", true, """
Classes
Class
Description
This is a class in the unnamed package.
"""); checkOutput("allpackages-index.html", true, """
Package Summary
Package
Description
This is a package comment for the unnamed package.
"""); checkOutput("type-search-index.js", true, """ {"l":"All Classes and Interfaces","u":"allclasses-index.html"}"""); checkOutput("package-search-index.js", true, """ {"l":"All Packages","u":"allpackages-index.html"}"""); checkOutput("index-all.html", true, """
All Classes and Interfaces|All&n\ bsp;Packages"""); checkOutput("type-search-index.js", true, """ {"l":"All Classes and Interfaces","u":"allclasses-index.html"}""", """ {"p":"","l":"C"}"""); checkOutput("member-search-index.js", true, """ {"p":"","c":"C","l":"C()","u":"%3Cinit%3E()"}"""); checkOutput("package-search-index.js", true, """ {"l":"All Packages","u":"allpackages-index.html"}"""); checkOutput("package-search-index.js", false, "Unnamed"); checkOutput(Output.OUT, false, "BadSource"); } @Test public void testUse() { javadoc("-d", "out-use", "-use", testSrc("src2/A.java"), testSrc("src2/B.java")); checkExit(Exit.OK); checkOutput("package-use.html", true, """ Classes in Unnamed Package used by Unnamed Package"""); checkOutput("class-use/A.html", true, """

Uses of A in Unnamed Package

""", """ Fields in Unnamed Package declared as A""", """ Methods in Unnamed Package that return A""", """ Constructors in Unnamed Package with param\ eters of type A"""); } @Test public void testMixed() { javadoc("-d", "out-mixed", "-sourcepath", testSrc("src1"), testSrc("src1/C.java"), "pkg"); checkExit(Exit.OK); checkOutput("index.html", true, """
This is a package comment for the unnamed package.
\ pkg
This is a package comment for package pkg.
"""); } }