langtools/test/jdk/javadoc/doclet/testModules/TestModuleServicesLink.java
changeset 46082 c65be9fae87b
child 46107 d2346d1007f5
equal deleted inserted replaced
46081:7c6d73d10b6b 46082:c65be9fae87b
       
     1 /*
       
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug 8185151
       
    27  * @summary test that navigation summary links are not linked when there are no dependencies
       
    28  * @modules jdk.javadoc/jdk.javadoc.internal.api
       
    29  *          jdk.javadoc/jdk.javadoc.internal.tool
       
    30  * @library ../lib /tools/lib
       
    31  * @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester
       
    32  * @run main TestModuleServicesLink
       
    33  */
       
    34 
       
    35 import java.nio.file.Path;
       
    36 import java.nio.file.Paths;
       
    37 
       
    38 import toolbox.*;
       
    39 
       
    40 public class TestModuleServicesLink extends JavadocTester {
       
    41 
       
    42     public final ToolBox tb;
       
    43     public static void main(String... args) throws Exception {
       
    44         TestModuleServicesLink  tester = new TestModuleServicesLink ();
       
    45         tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
       
    46     }
       
    47 
       
    48     public TestModuleServicesLink () {
       
    49         tb = new ToolBox();
       
    50     }
       
    51 
       
    52     @Test
       
    53     public void checkNavbarWithServices1(Path base) throws Exception {
       
    54         ModuleBuilder mb = new ModuleBuilder(tb, "m")
       
    55                 .comment("module m.\n@uses p1.A")
       
    56                 .uses("p1.A")
       
    57                 .uses("p1.B")
       
    58                 .exports("p1")
       
    59                 .classes("package p1; public class A {}")
       
    60                 .classes("package p1; public class B {}");
       
    61         mb.write(base);
       
    62 
       
    63         javadoc("-d", base.toString() + "/out",
       
    64                 "-quiet",
       
    65                 "--module-source-path", base.toString(),
       
    66                 "--module", "m");
       
    67         checkExit(Exit.OK);
       
    68 
       
    69         checkOutput("m-summary.html", true,
       
    70                 "<a href=\"#module.description\">Description</a>&nbsp;|"
       
    71                 + "&nbsp;Modules&nbsp;|"
       
    72                 + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
       
    73                 + "&nbsp;<a href=\"#services.summary\">Services</a>");
       
    74 
       
    75     }
       
    76 
       
    77     @Test
       
    78     public void checkNavbarWithServices2(Path base) throws Exception {
       
    79         ModuleBuilder mb = new ModuleBuilder(tb, "m")
       
    80                         .comment("module m.\n@provides p1.A")
       
    81                         .provides("p1.A", "p1.B")
       
    82                         .exports("p1")
       
    83                         .classes("package p1; public interface A {}")
       
    84                         .classes("package p1; public class B implements A {}");
       
    85         mb.write(base);
       
    86 
       
    87         javadoc("-d", base.toString() + "/out",
       
    88                 "-quiet",
       
    89                 "--module-source-path", base.toString(),
       
    90                 "--module", "m");
       
    91         checkExit(Exit.OK);
       
    92 
       
    93         checkOutput("m-summary.html", true,
       
    94                 "<a href=\"#module.description\">Description</a>&nbsp;|"
       
    95                 + "&nbsp;Modules&nbsp;|"
       
    96                 + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
       
    97                 + "&nbsp;<a href=\"#services.summary\">Services</a>");
       
    98 
       
    99     }
       
   100 
       
   101     @Test
       
   102     public void checkNavbarWithoutServices(Path base) throws Exception {
       
   103         ModuleBuilder mb = new ModuleBuilder(tb, "m")
       
   104                 .exports("p1")
       
   105                 .classes("package p1; public class A {}")
       
   106                 .classes("package p1; public class B {}");
       
   107         mb.write(base);
       
   108 
       
   109         javadoc("-d", base.toString() + "/out",
       
   110                 "-quiet",
       
   111                 "--module-source-path", base.toString(),
       
   112                 "--module", "m");
       
   113         checkExit(Exit.OK);
       
   114 
       
   115         checkOutput("m-summary.html", true,
       
   116                 "Description&nbsp;|&nbsp;Modules&nbsp;|"
       
   117                 + "&nbsp;<a href=\"#packages.summary\">Packages</a>&nbsp;|"
       
   118                 + "&nbsp;Services");
       
   119     }
       
   120 
       
   121 }