TestHelpOption.java revision 3300:d52219fa3026
1/*
2 * Copyright (c) 2003, 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      4934778 4777599 6553182 8146427 8146475
27 * @summary  Make sure that -help, -helpfile and -nohelp options work correctly.
28 * @author   jamieh
29 * @library ../lib
30 * @modules jdk.javadoc/jdk.javadoc.internal.tool
31 * @build    JavadocTester TestHelpOption
32 * @run main TestHelpOption
33 */
34
35public class TestHelpOption extends JavadocTester {
36
37    public static void main(String... args) throws Exception {
38        TestHelpOption tester = new TestHelpOption();
39        tester.runTests();
40    }
41
42    @Test
43    void testWithOption() {
44        javadoc("-d", "out1",
45                "-sourcepath", testSrc,
46                "-help",
47                testSrc("Sample.java"));
48        checkExit(Exit.OK);
49
50        checkOutput(true);
51    }
52
53    @Test
54    void testWithoutOption() {
55        javadoc("-d", "out2",
56                "-sourcepath", testSrc,
57                testSrc("Sample.java"));
58        checkExit(Exit.OK);
59    }
60
61    @Test
62    void testNohelpOption() {
63        javadoc("-d", "out3",
64                "-sourcepath", testSrc,
65                "-nohelp",
66                testSrc("Sample.java"));
67        checkOutput("Sample.html", false, "<li><a href=\"../help-doc.html\">Help</a></li>");
68        checkExit(Exit.OK);
69    }
70
71    @Test
72    void testHelpfileOption() {
73        javadoc("-d", "out4",
74                "-sourcepath", testSrc,
75                "-helpfile", testSrc("test-help.html"),
76                testSrc("Sample.java"));
77        checkExit(Exit.OK);
78        checkOutput("Sample.html", true,
79                "<li><a href=\"test-help.html\">Help</a></li>");
80        checkOutput("test-help.html", true,
81                "Help, help.");
82    }
83
84    @Test
85    void testHelpfileReuseOption() {
86        javadoc("-d", "out5",
87                "-sourcepath", testSrc,
88                "-helpfile", testSrc("test-help.html"),
89                "-helpfile", testSrc("test-help.html"),
90                testSrc("Sample.java"));
91        checkExit(Exit.FAILED);
92    }
93
94    @Test
95    void testHelpfileNohelpConflict() {
96        javadoc("-d", "out6",
97                "-sourcepath", testSrc,
98                "-helpfile", testSrc("test-help.html"),
99                "-nohelp",
100                testSrc("Sample.java"));
101        checkExit(Exit.FAILED);
102    }
103
104    private void checkOutput(boolean withOption) {
105        checkOutput(Output.OUT, withOption,
106                "-d ",
107                "-use ",
108                "-version ",
109                "-author ",
110                "-docfilessubdirs ",
111                "-splitindex ",
112                "-windowtitle ",
113                "-doctitle ",
114                "-header ",
115                "-footer ",
116                "-bottom ",
117                "-link ",
118                "-linkoffline ",
119                "-excludedocfilessubdir ",
120                "-group ",
121                "-nocomment ",
122                "-nodeprecated ",
123                "-noqualifier ",
124                "-nosince ",
125                "-notimestamp ",
126                "-nodeprecatedlist ",
127                "-notree ",
128                "-noindex ",
129                "-nohelp ",
130                "-nonavbar ",
131                "-serialwarn ",
132                "-tag ",
133                "-taglet ",
134                "-tagletpath ",
135                "-charset ",
136                "-helpfile ",
137                "-linksource ",
138                "-sourcetab ",
139                "-keywords ",
140                "-stylesheetfile ",
141                "-docencoding ",
142                "-html4 ",
143                "-html5 ",
144                "-top ",
145                "-author ",
146                "-noqualifier ",
147                "-nosince ",
148                "-notimestamp ",
149                "-sourcetab ");
150
151        checkOutput("Sample.html", !withOption,
152                "<li><a href=\"help-doc.html\">Help</a></li>");
153    }
154}
155