TestOptions.java revision 3300:d52219fa3026
1/*
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.
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      4749567 8071982
27 * @summary  Test the output for -header, -footer, -nooverview, -nodeprecatedlist, -nonavbar, -notree, -stylesheetfile options.
28 * @author   Bhavesh Patel
29 * @library  ../lib
30 * @modules jdk.javadoc/jdk.javadoc.internal.tool
31 * @build    JavadocTester
32 * @run main TestOptions
33 */
34
35import java.io.File;
36
37public class TestOptions extends JavadocTester {
38
39    public static void main(String... args) throws Exception {
40        TestOptions tester = new TestOptions();
41        tester.runTests();
42    }
43
44    @Test
45    void testHeaderFooter() {
46        javadoc("-d", "out-1",
47                "-header", "Test header",
48                "-footer", "Test footer",
49                "-sourcepath", testSrc,
50                "pkg");
51        checkExit(Exit.OK);
52
53        checkOutput("pkg/package-summary.html", true,
54                "<div class=\"aboutLanguage\">Test header</div>",
55                "<div class=\"aboutLanguage\">Test footer</div>");
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    }
216}
217