TestUseOption.java revision 3300:d52219fa3026
1/* 2 * Copyright (c) 2002, 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 4496290 4985072 7006178 7068595 8016328 8050031 8048351 8081854 8071982 27 * @summary A simple test to ensure class-use files are correct. 28 * @author jamieh 29 * @library ../lib 30 * @modules jdk.javadoc/jdk.javadoc.internal.tool 31 * @build JavadocTester 32 * @run main TestUseOption 33 */ 34 35public class TestUseOption extends JavadocTester { 36 37 public static void main(String... args) throws Exception { 38 TestUseOption tester = new TestUseOption(); 39 tester.runTests(); 40 } 41 42 @Test 43 void test1() { 44 javadoc("-d", "out-1", 45 "-sourcepath", testSrc, 46 "-use", 47 "pkg1", "pkg2"); 48 checkExit(Exit.OK); 49 50 // Eight tests for class use. 51 for (int i = 1; i <= 8; i++) { 52 checkOutput("pkg1/class-use/C1.html", true, 53 "Test " + i + " passes"); 54 } 55 56 // Three more tests for package use. 57 for (int i = 1; i <= 3; i++) { 58 checkOutput("pkg1/package-use.html", true, 59 "Test " + i + " passes"); 60 } 61 62 checkOrder("pkg1/class-use/UsedClass.html", 63 "Field in C1.", 64 "Field in C2.", 65 "Field in C4.", 66 "Field in C5.", 67 "Field in C6.", 68 "Field in C7.", 69 "Field in C8.", 70 "Method in C1.", 71 "Method in C2.", 72 "Method in C4.", 73 "Method in C5.", 74 "Method in C6.", 75 "Method in C7.", 76 "Method in C8." 77 ); 78 79 checkOutput("pkg2/class-use/C3.html", true, 80 "<a href=\"../../index.html?pkg2/class-use/C3.html\" target=\"_top\">" 81 + "Frames</a></li>" 82 ); 83 checkOutput("pkg1/class-use/UsedClass.html", true, 84 "that return types with arguments of type" 85 ); 86 checkOutput("pkg1/class-use/UsedClass.html", true, 87 "<a href=\"../../pkg1/C1.html#methodInC1ReturningType--\">methodInC1ReturningType</a>" 88 ); 89 checkOutput("pkg1/class-use/UsedInterface.html", true, 90 "Classes in <a href=\"../../pkg1/package-summary.html\">pkg1</a> that implement " + 91 "<a href=\"../../pkg1/UsedInterface.html\" title=\"interface in pkg1\">UsedInterface</a>" 92 ); 93 checkOutput("pkg1/class-use/UsedInterfaceA.html", true, 94 "Classes in <a href=\"../../pkg1/package-summary.html\">pkg1</a> that implement " + 95 "<a href=\"../../pkg1/UsedInterfaceA.html\" title=\"interface in pkg1\">UsedInterfaceA</a>" 96 ); 97 checkOutput("pkg1/class-use/UsedClass.html", false, 98 "methodInC1Protected" 99 ); 100 checkOutput("pkg1/class-use/UsedInterface.html", true, 101 "<a href=\"../../pkg1/AnAbstract.html\" title=\"class in pkg1\">AnAbstract</a>" 102 ); 103 checkOutput("pkg1/class-use/UsedInterface.html", true, 104 "../../pkg1/C10.html#withReturningTypeParameters--" 105 ); 106 checkOutput("pkg1/class-use/UsedInterface.html", true, 107 "../../pkg1/C10.html#withTypeParametersOfType-java.lang.Class-" 108 ); 109 checkOutput("pkg1/class-use/UsedInterface.html", true, 110 "\"../../pkg1/package-summary.html\">pkg1</a> that return " + 111 "<a href=\"../../pkg1/UsedInterface.html\" title=\"interface in pkg1\"" 112 ); 113 checkOutput("pkg1/class-use/UsedInterface.html", true, 114 "<a href=\"../../pkg1/C10.html#addAll-pkg1.UsedInterface...-\">addAll</a>" 115 ); 116 checkOutput("pkg1/class-use/UsedInterface.html", true, 117 "<a href=\"../../pkg1/C10.html#create-pkg1.UsedInterfaceA-pkg1." + 118 "UsedInterface-java.lang.String-\">" 119 ); 120 checkOutput("pkg1/class-use/UsedInterface.html", true, 121 "<a href=\"../../pkg1/C10.html#withTypeParametersOfType-java.lang.Class-\">" + 122 "withTypeParametersOfType</a>" 123 ); 124 checkOutput("pkg1/class-use/UsedInterface.html", true, 125 "Subinterfaces of <a href=\"../../pkg1/UsedInterface.html\" title=\"interface in pkg1\">" 126 + "UsedInterface</a> in <a href=\"../../pkg1/package-summary.html\">pkg1", 127 "<td class=\"colFirst\"><code>interface </code></td>\n<td class=\"colLast\">" 128 + "<code><span class=\"memberNameLink\"><a href=\"../../pkg1/SubInterface.html\" " 129 + "title=\"interface in pkg1\">SubInterface</a><T></span></code> </td>" 130 ); 131 checkOutput("pkg1/class-use/UsedThrowable.html", true, 132 "Methods in <a href=\"../../pkg1/package-summary.html\">pkg1</a> that throw " 133 + "<a href=\"../../pkg1/UsedThrowable.html\" title=\"class in pkg1\">UsedThrowable</a>", 134 "<td class=\"colFirst\"><code>void</code></td>\n<td class=\"colLast\"><span class=" 135 + "\"typeNameLabel\">C1.</span><code><span class=\"memberNameLink\">" 136 + "<a href=\"../../pkg1/C1.html#methodInC1ThrowsThrowable--\">methodInC1ThrowsThrowable" 137 + "</a></span>()</code> </td>" 138 ); 139 } 140 141 @Test 142 void test2() { 143 javadoc("-d", "out-2", 144 "-sourcepath", testSrc, 145 "-use", 146 testSrc("C.java"), testSrc("UsedInC.java"), "pkg3"); 147 checkExit(Exit.OK); 148 149 checkOutput("class-use/UsedInC.html", true, 150 "Uses of <a href=\"../UsedInC.html\" title=\"class in <Unnamed>\">" 151 + "UsedInC</a> in <a href=\"../package-summary.html\"><Unnamed></a>" 152 ); 153 checkOutput("class-use/UsedInC.html", true, 154 "<li class=\"blockList\"><a name=\"unnamed.package\">" 155 ); 156 checkOutput("package-use.html", true, 157 "<td class=\"colOne\">" 158 + "<a href=\"class-use/UsedInC.html#unnamed.package\">UsedInC</a> </td>", 159 "<td class=\"colFirst\"><a href=\"#-Unnamed-\"><Unnamed></a></td>\n" 160 + "<td class=\"colLast\"> </td>" 161 ); 162 } 163 164 @Test 165 void test3() { 166 javadoc("-d", "out-3", 167 "-sourcepath", testSrc, 168 "-use", 169 "-package", "unique"); 170 checkExit(Exit.OK); 171 checkUnique("unique/class-use/UseMe.html", 172 "<a href=\"../../unique/C1.html#umethod1-unique.UseMe-unique.UseMe:A-\">", 173 "<a href=\"../../unique/C1.html#umethod2-unique.UseMe-unique.UseMe-\">", 174 "<a href=\"../../unique/C1.html#umethod3-unique.UseMe-unique.UseMe-\">", 175 "<a href=\"../../unique/C1.html#C1-unique.UseMe-unique.UseMe-\">"); 176 } 177} 178