test/langtools/jdk/javadoc/doclet/testSystemPropertyTaglet/TestSystemPropertyTaglet.java
changeset 52487 5d1d07b72f15
child 52648 12956ca371c2
equal deleted inserted replaced
52486:6f5948597697 52487:5d1d07b72f15
       
     1 /*
       
     2  * Copyright (c) 2018, 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 5076751
       
    27  * @summary System properties documentation needed in javadocs
       
    28  * @library /tools/lib ../lib
       
    29  * @modules jdk.javadoc/jdk.javadoc.internal.tool
       
    30  * @build JavadocTester toolbox.ToolBox builder.ClassBuilder
       
    31  * @run main TestSystemPropertyTaglet
       
    32  */
       
    33 
       
    34 
       
    35 import java.nio.file.Path;
       
    36 import java.nio.file.Paths;
       
    37 
       
    38 import builder.ClassBuilder;
       
    39 import builder.ClassBuilder.MethodBuilder;
       
    40 import toolbox.ToolBox;
       
    41 
       
    42 public class TestSystemPropertyTaglet extends JavadocTester {
       
    43 
       
    44     final ToolBox tb;
       
    45 
       
    46     public static void main(String... args) throws Exception {
       
    47         TestSystemPropertyTaglet tester = new TestSystemPropertyTaglet();
       
    48         tester.runTests(m -> new Object[]{Paths.get(m.getName())});
       
    49     }
       
    50 
       
    51     TestSystemPropertyTaglet() {
       
    52         tb = new ToolBox();
       
    53     }
       
    54 
       
    55     @Test
       
    56     void test(Path base) throws Exception {
       
    57         Path srcDir = base.resolve("src");
       
    58         createTestClass(srcDir);
       
    59 
       
    60         Path outDir = base.resolve("out");
       
    61         javadoc("-d", outDir.toString(),
       
    62                 "-sourcepath", srcDir.toString(),
       
    63                 "pkg");
       
    64 
       
    65         checkExit(Exit.OK);
       
    66 
       
    67         checkOrder("pkg/A.html",
       
    68                 "<h2 title=\"Class A\" class=\"title\">Class A</h2>",
       
    69                 "test with <code><a id=\"user.name\" class=\"searchTagResult\">user.name</a></code>",
       
    70                 "<h3>Method Detail</h3>",
       
    71                 "test with <code><a id=\"java.version\" class=\"searchTagResult\">java.version</a></code>");
       
    72 
       
    73         checkOrder("index-all.html",
       
    74                 "<h2 class=\"title\">J</h2>",
       
    75                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/A.html#java.version\">java.version</a>"
       
    76                 + "</span> - Search tag in pkg.A</dt>\n<dd>System Property</dd>",
       
    77                 "<h2 class=\"title\">U</h2>",
       
    78                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/A.html#user.name\">user.name</a></span>"
       
    79                 + " - Search tag in pkg.A</dt>\n<dd>System Property</dd>");
       
    80 
       
    81         checkOutput("tag-search-index.js", true,
       
    82                 "{\"l\":\"java.version\",\"h\":\"pkg.A\",\"d\":\"System Property\","
       
    83                 + "\"u\":\"pkg/A.html#java.version\"}");
       
    84 
       
    85         checkOutput("tag-search-index.js", true,
       
    86                 "{\"l\":\"user.name\",\"h\":\"pkg.A\",\"d\":\"System Property\","
       
    87                 + "\"u\":\"pkg/A.html#user.name\"}");
       
    88     }
       
    89 
       
    90     void createTestClass(Path srcDir) throws Exception {
       
    91         MethodBuilder method = MethodBuilder
       
    92                 .parse("public void func(A a) {}")
       
    93                 .setComments("test with {@systemProperty java.version}");
       
    94 
       
    95         new ClassBuilder(tb, "pkg.A")
       
    96                 .setComments("test with {@systemProperty user.name}")
       
    97                 .setModifiers("public", "class")
       
    98                 .addMembers(method)
       
    99                 .write(srcDir);
       
   100     }
       
   101 }