langtools/test/jdk/javadoc/doclet/testOptions/TestOptions.java
changeset 36705 890c250d8da8
parent 35426 374342e56a56
child 36709 f9f252088afa
equal deleted inserted replaced
36503:4a95f4b1bd8b 36705:890c250d8da8
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug      4749567
    26  * @bug      4749567 8071982
    27  * @summary  Test the output for -header and -footer options.
    27  * @summary  Test the output for -header, -footer, -nooverview, -nodeprecatedlist, -nonavbar, -notree, -stylesheetfile options.
    28  * @author   Bhavesh Patel
    28  * @author   Bhavesh Patel
    29  * @library  ../lib
    29  * @library  ../lib
    30  * @modules jdk.javadoc
    30  * @modules jdk.javadoc
    31  * @build    JavadocTester
    31  * @build    JavadocTester
    32  * @run main TestOptions
    32  * @run main TestOptions
    33  */
    33  */
    34 
    34 
       
    35 import java.io.File;
       
    36 
    35 public class TestOptions extends JavadocTester {
    37 public class TestOptions extends JavadocTester {
    36 
    38 
    37     public static void main(String... args) throws Exception {
    39     public static void main(String... args) throws Exception {
    38         TestOptions tester = new TestOptions();
    40         TestOptions tester = new TestOptions();
    39         tester.runTests();
    41         tester.runTests();
    40     }
    42     }
    41 
    43 
    42     @Test
    44     @Test
    43     void test() {
    45     void testHeaderFooter() {
    44         javadoc("-d", "out",
    46         javadoc("-d", "out-1",
    45                 "-header", "Test header",
    47                 "-header", "Test header",
    46                 "-footer", "Test footer",
    48                 "-footer", "Test footer",
    47                 "-sourcepath", testSrc,
    49                 "-sourcepath", testSrc,
    48                 "pkg");
    50                 "pkg");
    49         checkExit(Exit.OK);
    51         checkExit(Exit.OK);
    50 
    52 
    51         checkOutput("pkg/package-summary.html", true,
    53         checkOutput("pkg/package-summary.html", true,
    52                 "<div class=\"aboutLanguage\">Test header</div>",
    54                 "<div class=\"aboutLanguage\">Test header</div>",
    53                 "<div class=\"aboutLanguage\">Test footer</div>");
    55                 "<div class=\"aboutLanguage\">Test footer</div>");
    54     }
    56     }
       
    57 
       
    58     @Test
       
    59     void testNoOverview() {
       
    60         javadoc("-d", "out-4",
       
    61                 "-nooverview",
       
    62                 "-sourcepath", testSrc,
       
    63                 "pkg", "deprecated");
       
    64 
       
    65         checkExit(Exit.OK);
       
    66 
       
    67         checkFiles(false, "overview-summary.html");
       
    68     }
       
    69 
       
    70     @Test
       
    71     void testNoDeprecatedList() {
       
    72         javadoc("-d", "out-5",
       
    73                 "-nodeprecatedlist",
       
    74                 "-sourcepath", testSrc,
       
    75                 "deprecated");
       
    76         checkExit(Exit.OK);
       
    77 
       
    78         checkFiles(false, "deprecated-list.html");
       
    79     }
       
    80 
       
    81     @Test
       
    82     void testNoNavbar() {
       
    83         javadoc("-d", "out-6",
       
    84                 "-nonavbar",
       
    85                 "-bottom", "Bottom text",
       
    86                 "-sourcepath", testSrc,
       
    87                 "pkg");
       
    88         checkExit(Exit.OK);
       
    89 
       
    90         checkOutput("pkg/Foo.html", false, "navbar");
       
    91         checkOutput("pkg/Foo.html", true, "Bottom text");
       
    92     }
       
    93 
       
    94     @Test
       
    95     void testNoTree() {
       
    96         javadoc("-d", "out-7",
       
    97                 "-notree",
       
    98                 "-sourcepath", testSrc,
       
    99                 "pkg");
       
   100         checkExit(Exit.OK);
       
   101 
       
   102         checkFiles(false, "overview-tree.html");
       
   103         checkFiles(false, "pkg/package-tree.html");
       
   104         checkOutput("pkg/Foo.html", false, "<li><a href=\"package-tree.html\">Tree</a></li>");
       
   105     }
       
   106 
       
   107     @Test
       
   108     void testStylesheetFile() {
       
   109         javadoc("-d", "out-8",
       
   110                 "-stylesheetfile", new File(testSrc, "custom-stylesheet.css").getAbsolutePath(),
       
   111                 "-sourcepath", testSrc,
       
   112                 "pkg");
       
   113         checkExit(Exit.OK);
       
   114 
       
   115         checkOutput("custom-stylesheet.css", true, "Custom javadoc style sheet");
       
   116         checkOutput("pkg/Foo.html", true, "<link rel=\"stylesheet\" type=\"text/css\" "
       
   117                 + "href=\"../custom-stylesheet.css\" title=\"Style\">");
       
   118     }
       
   119 
       
   120     @Test
       
   121     void testLinkSource() {
       
   122         javadoc("-d", "out-9",
       
   123                 "-linksource",
       
   124                 "-javafx",
       
   125                 "-sourcepath", testSrc,
       
   126                 "-package",
       
   127                 "linksource");
       
   128         checkExit(Exit.OK);
       
   129 
       
   130         checkOutput("linksource/AnnotationTypeField.html", true,
       
   131                 "<pre>@Documented\npublic @interface <a href="
       
   132                 + "\"../src-html/linksource/AnnotationTypeField.html#line.31\">"
       
   133                 + "AnnotationTypeField</a></pre>",
       
   134                 "<h4>DEFAULT_NAME</h4>\n<pre>static final&nbsp;java.lang.String&nbsp;"
       
   135                 + "<a href=\"../src-html/linksource/AnnotationTypeField.html#line.32\">"
       
   136                 + "DEFAULT_NAME</a></pre>",
       
   137                 "<h4>name</h4>\n<pre>java.lang.String&nbsp;<a href="
       
   138                 + "\"../src-html/linksource/AnnotationTypeField.html#line.34\">name</a></pre>");
       
   139 
       
   140         checkOutput("src-html/linksource/AnnotationTypeField.html", true,
       
   141                 "<title>Source code</title>",
       
   142                 "<span class=\"sourceLineNo\">031</span><a name=\"line.31\">"
       
   143                 + "@Documented public @interface AnnotationTypeField {</a>");
       
   144 
       
   145         checkOutput("linksource/Properties.html", true,
       
   146                 "<pre>public class <a href=\"../src-html/linksource/Properties.html#line.29\">"
       
   147                 + "Properties</a>",
       
   148                 "<pre>public&nbsp;java.lang.Object <a href="
       
   149                 + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a></pre>",
       
   150                 "<pre>public&nbsp;java.lang.Object&nbsp;<a href="
       
   151                 + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a>()</pre>");
       
   152 
       
   153         checkOutput("src-html/linksource/Properties.html", true,
       
   154                 "<title>Source code</title>",
       
   155                 "<span class=\"sourceLineNo\">031</span><a name=\"line.31\">    "
       
   156                 + "public Object someProperty() {</a>");
       
   157 
       
   158         checkOutput("linksource/SomeClass.html", true,
       
   159                 "<pre>public class <a href=\"../src-html/linksource/SomeClass.html#line.29\">"
       
   160                 + "SomeClass</a>\nextends java.lang.Object</pre>",
       
   161                 "<pre>public&nbsp;int <a href=\"../src-html/linksource/SomeClass.html#line.31\">"
       
   162                 + "field</a></pre>",
       
   163                 "<pre>public&nbsp;<a href=\"../src-html/linksource/SomeClass.html#line.33\">"
       
   164                 + "SomeClass</a>()</pre>",
       
   165                 "<pre>public&nbsp;int&nbsp;<a href=\"../src-html/linksource/SomeClass.html#line.36\">"
       
   166                 + "method</a>()</pre>");
       
   167 
       
   168         checkOutput("src-html/linksource/SomeClass.html", true,
       
   169                 "<title>Source code</title>",
       
   170                 "<span class=\"sourceLineNo\">029</span><a name=\"line.29\">"
       
   171                 + "public class SomeClass {</a>",
       
   172                 "<span class=\"sourceLineNo\">031</span><a name=\"line.31\">    "
       
   173                 + "public int field;</a>",
       
   174                 "<span class=\"sourceLineNo\">033</span><a name=\"line.33\">    "
       
   175                 + "public SomeClass() {</a>",
       
   176                 "<span class=\"sourceLineNo\">036</span><a name=\"line.36\">    "
       
   177                 + "public int method() {</a>");
       
   178 
       
   179         checkOutput("linksource/SomeEnum.html", true,
       
   180                 "<pre>public static final&nbsp;<a href=\"../linksource/SomeEnum.html\" "
       
   181                 + "title=\"enum in linksource\">SomeEnum</a> <a href="
       
   182                 + "\"../src-html/linksource/SomeEnum.html#line.29\">VALUE1</a></pre>",
       
   183                 "<pre>public static final&nbsp;<a href=\"../linksource/SomeEnum.html\" "
       
   184                 + "title=\"enum in linksource\">SomeEnum</a> <a href="
       
   185                 + "\"../src-html/linksource/SomeEnum.html#line.30\">VALUE2</a></pre>");
       
   186 
       
   187         checkOutput("src-html/linksource/SomeEnum.html", true,
       
   188                 "<span class=\"sourceLineNo\">029</span><a name=\"line.29\">    VALUE1,</a>",
       
   189                 "<span class=\"sourceLineNo\">030</span><a name=\"line.30\">    VALUE2</a>");
       
   190     }
       
   191 
       
   192     @Test
       
   193     void testNoQualifier() {
       
   194         javadoc("-d", "out-10",
       
   195                 "-noqualifier", "pkg",
       
   196                 "-sourcepath", testSrc,
       
   197                 "pkg", "deprecated");
       
   198         checkExit(Exit.OK);
       
   199 
       
   200         checkOutput("pkg/Foo.html", true,
       
   201                 "<li>Foo</li>");
       
   202         checkOutput("deprecated/Foo.html", true,
       
   203                 "<li>deprecated.Foo</li>");
       
   204 
       
   205         javadoc("-d", "out-10a",
       
   206                 "-noqualifier", "all",
       
   207                 "-sourcepath", testSrc,
       
   208                 "pkg", "deprecated");
       
   209         checkExit(Exit.OK);
       
   210 
       
   211         checkOutput("pkg/Foo.html", true,
       
   212                 "<li>Foo</li>");
       
   213         checkOutput("deprecated/Foo.html", true,
       
   214                 "<li>Foo</li>");
       
   215     }
    55 }
   216 }
    56