TestHelpOption.java revision 3294:9adfb22ff08f
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 checkExit(Exit.OK); 68 } 69 70 @Test 71 void testHelpfileOption() { 72 javadoc("-d", "out4", 73 "-sourcepath", testSrc, 74 "-helpfile", testSrc("test-help.html"), 75 testSrc("Sample.java")); 76 checkExit(Exit.OK); 77 checkOutput("Sample.html", true, 78 "<li><a href=\"test-help.html\">Help</a></li>"); 79 } 80 81 @Test 82 void testHelpfileReuseOption() { 83 javadoc("-d", "out5", 84 "-sourcepath", testSrc, 85 "-helpfile", testSrc("test-help.html"), 86 "-helpfile", testSrc("test-help.html"), 87 testSrc("Sample.java")); 88 checkExit(Exit.FAILED); 89 } 90 91 @Test 92 void testHelpfileNohelpConflict() { 93 javadoc("-d", "out6", 94 "-sourcepath", testSrc, 95 "-helpfile", testSrc("test-help.html"), 96 "-nohelp", 97 testSrc("Sample.java")); 98 checkExit(Exit.FAILED); 99 } 100 101 private void checkOutput(boolean withOption) { 102 checkOutput(Output.OUT, withOption, 103 "-d ", 104 "-use ", 105 "-version ", 106 "-author ", 107 "-docfilessubdirs ", 108 "-splitindex ", 109 "-windowtitle ", 110 "-doctitle ", 111 "-header ", 112 "-footer ", 113 "-bottom ", 114 "-link ", 115 "-linkoffline ", 116 "-excludedocfilessubdir ", 117 "-group ", 118 "-nocomment ", 119 "-nodeprecated ", 120 "-noqualifier ", 121 "-nosince ", 122 "-notimestamp ", 123 "-nodeprecatedlist ", 124 "-notree ", 125 "-noindex ", 126 "-nohelp ", 127 "-nonavbar ", 128 "-serialwarn ", 129 "-tag ", 130 "-taglet ", 131 "-tagletpath ", 132 "-charset ", 133 "-helpfile ", 134 "-linksource ", 135 "-sourcetab ", 136 "-keywords ", 137 "-stylesheetfile ", 138 "-docencoding "); 139 140 checkOutput("Sample.html", !withOption, 141 "<li><a href=\"help-doc.html\">Help</a></li>"); 142 } 143} 144