1 /* |
|
2 * Copyright (c) 2017, 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 8157000 |
|
27 * @summary test the behavior of --override-methods option |
|
28 * @library ../lib |
|
29 * @modules jdk.javadoc/jdk.javadoc.internal.tool |
|
30 * @build JavadocTester |
|
31 * @run main TestOverrideMethods |
|
32 */ |
|
33 |
|
34 public class TestOverrideMethods extends JavadocTester { |
|
35 public static void main(String... args) throws Exception { |
|
36 TestOverrideMethods tester = new TestOverrideMethods(); |
|
37 tester.runTests(); |
|
38 } |
|
39 |
|
40 @Test |
|
41 void testInvalidOption() { |
|
42 // Make sure an invalid argument fails |
|
43 javadoc("-d", "out-bad-option", |
|
44 "-sourcepath", testSrc, |
|
45 "-javafx", |
|
46 "--override-methods=nonsense", |
|
47 "pkg5"); |
|
48 |
|
49 checkExit(Exit.CMDERR); |
|
50 } |
|
51 |
|
52 @Test |
|
53 void testDetail() { |
|
54 // Make sure the option works |
|
55 javadoc("-d", "out-detail", |
|
56 "-sourcepath", testSrc, |
|
57 "-javafx", |
|
58 "--override-methods=detail", |
|
59 "pkg5"); |
|
60 |
|
61 checkExit(Exit.OK); |
|
62 } |
|
63 |
|
64 @Test |
|
65 void testSummary() { |
|
66 javadoc("-d", "out-summary", |
|
67 "-sourcepath", testSrc, |
|
68 "-javafx", |
|
69 "--override-methods=summary", |
|
70 "pkg5"); |
|
71 |
|
72 checkExit(Exit.OK); |
|
73 |
|
74 checkOutput("pkg5/Classes.C.html", true, |
|
75 // Check properties |
|
76 "<h3>Properties declared in class pkg5.<a href=\"../pkg5/Classes.P.html\" " |
|
77 + "title=\"class in pkg5\">Classes.P</a></h3>\n" |
|
78 + "<code><a href=\"../pkg5/Classes.P.html#rateProperty\">rate</a>", |
|
79 |
|
80 // Check nested classes |
|
81 "<h3>Nested classes/interfaces declared in class pkg5." |
|
82 + "<a href=\"../pkg5/Classes.P.html\" title=\"class in pkg5\">Classes.P</a></h3>\n" |
|
83 + "<code><a href=\"../pkg5/Classes.P.PN.html\" title=\"class in pkg5\">" |
|
84 + "Classes.P.PN</a><<a href=\"../pkg5/Classes.P.PN.html\" " |
|
85 + "title=\"type parameter in Classes.P.PN\">K</a>," |
|
86 + "<a href=\"../pkg5/Classes.P.PN.html\" title=\"type parameter in Classes.P.PN\">" |
|
87 + "V</a>></code></li>\n", |
|
88 |
|
89 // Check fields |
|
90 "<h3>Fields declared in class pkg5.<a href=\"../pkg5/Classes.P.html\" " |
|
91 + "title=\"class in pkg5\">Classes.P</a></h3>\n" |
|
92 + "<code><a href=\"../pkg5/Classes.P.html#field0\">field0</a></code></li>\n", |
|
93 |
|
94 // Check method summary |
|
95 "<td class=\"colFirst\"><code>void</code></td>\n" |
|
96 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">" |
|
97 + "<a href=\"../pkg5/Classes.C.html#m1--\">m1</a></span>()</code></th>\n" |
|
98 + "<td class=\"colLast\">\n" |
|
99 + "<div class=\"block\">A modified method</div>\n", |
|
100 |
|
101 "<td class=\"colFirst\"><code>void</code></td>\n" |
|
102 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">" |
|
103 + "<a href=\"../pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-\">m4" |
|
104 + "</a></span>​(java.lang.String k,\n" |
|
105 + " java.lang.String v)</code></th>\n", |
|
106 |
|
107 // Check footnotes |
|
108 "<h3>Methods declared in class pkg5.<a href=\"../pkg5/Classes.GP.html\" " |
|
109 + "title=\"class in pkg5\">Classes.GP</a></h3>\n" |
|
110 + "<code><a href=\"../pkg5/Classes.GP.html#m0--\">m0</a>", |
|
111 |
|
112 // Check method details for override |
|
113 "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n" |
|
114 + "<dd><code><a href=\"../pkg5/Classes.GP.html#m7--\">m7</a>" |
|
115 + "</code> in class <code><a href=\"../pkg5/Classes.GP.html\" " |
|
116 + "title=\"class in pkg5\">Classes.GP</a></code></dd>\n" |
|
117 ); |
|
118 |
|
119 // Check footnotes 2 |
|
120 checkOrder("pkg5/Classes.C.html", |
|
121 "Methods declared in class pkg5.", |
|
122 "<code><a href=\"../pkg5/Classes.P.html#getRate--\">getRate</a>, ", |
|
123 "<a href=\"../pkg5/Classes.P.html#m2--\">m2</a>, ", |
|
124 "<a href=\"../pkg5/Classes.P.html#m3--\">m3</a>, ", |
|
125 "<a href=\"../pkg5/Classes.P.html#m4-K-V-\">m4</a>, ", |
|
126 "<a href=\"../pkg5/Classes.P.html#rateProperty--\">rateProperty</a>, ", |
|
127 "<a href=\"../pkg5/Classes.P.html#setRate-double-\">setRate</a>" |
|
128 ); |
|
129 |
|
130 // Check @link |
|
131 checkOrder("pkg5/Classes.C.html", |
|
132 "A test of links to the methods in this class. <p>\n", |
|
133 "<a href=\"../pkg5/Classes.GP.html#m0--\"><code>Classes.GP.m0()</code></a>", |
|
134 "<a href=\"../pkg5/Classes.C.html#m1--\"><code>m1()</code></a>", |
|
135 "<a href=\"../pkg5/Classes.P.html#m2--\"><code>Classes.P.m2()</code></a>", |
|
136 "<a href=\"../pkg5/Classes.P.html#m3--\"><code>Classes.P.m3()</code></a>", |
|
137 "<code>m4(java.lang.String,java.lang.String)</code></a>", |
|
138 "<a href=\"../pkg5/Classes.P.html#m5--\"><code>Classes.P.m5()</code></a>", |
|
139 "<a href=\"../pkg5/Classes.C.html#m6--\"><code>m6()</code></a>", |
|
140 "<a href=\"../pkg5/Classes.C.html#m7--\"><code>m7()</code></a>", |
|
141 "End of links" |
|
142 ); |
|
143 |
|
144 // Check @see |
|
145 checkOrder("pkg5/Classes.C.html", |
|
146 "See Also:", |
|
147 "<a href=\"../pkg5/Classes.GP.html#m0--\"><code>Classes.GP.m0()</code>", |
|
148 "<a href=\"../pkg5/Classes.C.html#m1--\"><code>m1()</code></a>", |
|
149 "<a href=\"../pkg5/Classes.P.html#m2--\"><code>Classes.P.m2()</code></a>", |
|
150 "<a href=\"../pkg5/Classes.P.html#m3--\"><code>Classes.P.m3()</code></a>", |
|
151 "<a href=\"../pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-\">" |
|
152 + "<code>m4(String k, String v)</code>", |
|
153 "<a href=\"../pkg5/Classes.P.html#m5--\"><code>Classes.P.m5()</code></a>", |
|
154 "<a href=\"../pkg5/Classes.C.html#m6--\"><code>m6()</code></a>", |
|
155 "<a href=\"../pkg5/Classes.C.html#m7--\"><code>m7()</code></a>" |
|
156 ); |
|
157 |
|
158 checkOutput("pkg5/Interfaces.D.html", true, |
|
159 // Check properties |
|
160 "<h3>Properties declared in interface pkg5.<a href=\"../pkg5/Interfaces.A.html\" " |
|
161 + "title=\"interface in pkg5\">Interfaces.A</a>", |
|
162 |
|
163 // Check nested classes |
|
164 "<h3>Nested classes/interfaces declared in interface pkg5." |
|
165 + "<a href=\"../pkg5/Interfaces.A.html\" title=\"interface in pkg5\">" |
|
166 + "Interfaces.A</a></h3>\n" |
|
167 + "<code><a href=\"../pkg5/Interfaces.A.AA.html\" " |
|
168 + "title=\"interface in pkg5\">Interfaces.A.AA</a>", |
|
169 |
|
170 // Check fields |
|
171 "<h3>Fields declared in interface pkg5.<a href=\"../pkg5/Interfaces.A.html\" " |
|
172 + "title=\"interface in pkg5\">Interfaces.A</a></h3>\n" |
|
173 + "<code><a href=\"../pkg5/Interfaces.A.html#f\">f</a>", |
|
174 |
|
175 // Check method summary |
|
176 "<td class=\"colFirst\"><code>void</code></td>\n" |
|
177 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">" |
|
178 + "<a href=\"../pkg5/Interfaces.D.html#m--\">m</a></span>()</code></th>\n" |
|
179 + "<td class=\"colLast\">\n" |
|
180 + "<div class=\"block\">m in D</div>\n", |
|
181 |
|
182 "<td class=\"colFirst\"><code>void</code></td>\n" |
|
183 + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">" |
|
184 + "<a href=\"../pkg5/Interfaces.D.html#n--\">n</a></span>()</code></th>\n" |
|
185 + "<td class=\"colLast\">\n" |
|
186 + "<div class=\"block\">n in D</div>\n", |
|
187 |
|
188 // Check footnote |
|
189 "<h3>Methods declared in interface pkg5.<a href=\"../pkg5/Interfaces.A.html\" " |
|
190 + "title=\"interface in pkg5\">Interfaces.A</a></h3>\n" |
|
191 + "<code><a href=\"../pkg5/Interfaces.A.html#getRate--\">getRate</a>, " |
|
192 + "<a href=\"../pkg5/Interfaces.A.html#rateProperty--\">rateProperty</a>, " |
|
193 + "<a href=\"../pkg5/Interfaces.A.html#setRate-double-\">setRate</a>", |
|
194 |
|
195 "<h3>Methods declared in interface pkg5.<a href=\"../pkg5/Interfaces.B.html\" " |
|
196 + "title=\"interface in pkg5\">Interfaces.B</a></h3>\n" |
|
197 + "<code><a href=\"../pkg5/Interfaces.B.html#m1--\">m1</a>, " |
|
198 + "<a href=\"../pkg5/Interfaces.B.html#m3--\">m3</a>", |
|
199 |
|
200 "<h3>Methods declared in interface pkg5.<a href=\"../pkg5/Interfaces.C.html\" " |
|
201 + "title=\"interface in pkg5\">Interfaces.C</a></h3>\n" |
|
202 + "<code><a href=\"../pkg5/Interfaces.C.html#o--\">o</a>" |
|
203 ); |
|
204 |
|
205 checkOrder("pkg5/Interfaces.D.html", |
|
206 "Start of links <p>", |
|
207 "<a href=\"../pkg5/Interfaces.A.html#m0--\"><code>Interfaces.A.m0()</code></a>", |
|
208 "<a href=\"../pkg5/Interfaces.A.html#m1--\"><code>Interfaces.A.m1()</code></a>", |
|
209 "<a href=\"../pkg5/Interfaces.A.html#m2--\"><code>Interfaces.A.m2()</code></a>", |
|
210 "<a href=\"../pkg5/Interfaces.A.html#m3--\"><code>Interfaces.A.m3()</code></a>", |
|
211 "<a href=\"../pkg5/Interfaces.D.html#m--\"><code>m()</code></a>", |
|
212 "<a href=\"../pkg5/Interfaces.D.html#n--\"><code>n()</code></a>", |
|
213 "<a href=\"../pkg5/Interfaces.C.html#o--\"><code>Interfaces.C.o()</code></a>", |
|
214 "End of links"); |
|
215 |
|
216 checkOrder("pkg5/Interfaces.D.html", |
|
217 "See Also:", |
|
218 "<a href=\"../pkg5/Interfaces.A.html#m0--\"><code>Interfaces.A.m0()</code></a>", |
|
219 "<a href=\"../pkg5/Interfaces.A.html#m1--\"><code>Interfaces.A.m1()</code></a>", |
|
220 "<a href=\"../pkg5/Interfaces.A.html#m2--\"><code>Interfaces.A.m2()</code></a>", |
|
221 "<a href=\"../pkg5/Interfaces.A.html#m3--\"><code>Interfaces.A.m3()</code></a>", |
|
222 "<a href=\"../pkg5/Interfaces.D.html#m--\"><code>m()</code></a>", |
|
223 "<a href=\"../pkg5/Interfaces.D.html#n--\"><code>n()</code></a>", |
|
224 "<a href=\"../pkg5/Interfaces.C.html#o--\"><code>Interfaces.C.o()</code></a>"); |
|
225 |
|
226 // Test synthetic values and valuesof of an enum. |
|
227 checkOrder("index-all.html", |
|
228 "<h2 class=\"title\">M</h2>", |
|
229 "<a href=\"pkg5/Interfaces.C.html#m--\">m()", |
|
230 "<a href=\"pkg5/Interfaces.D.html#m--\">m()</a>", |
|
231 "<a href=\"pkg5/Classes.GP.html#m0--\">m0()", |
|
232 "<a href=\"pkg5/Interfaces.A.html#m0--\">m0()</a>", |
|
233 "<a href=\"pkg5/Classes.C.html#m1--\">m1()</a>", |
|
234 "<a href=\"pkg5/Classes.P.html#m1--\">m1()</a>", |
|
235 "<a href=\"pkg5/Interfaces.A.html#m1--\">m1()</a>", |
|
236 "<a href=\"pkg5/Interfaces.B.html#m1--\">m1()</a>", |
|
237 "<a href=\"pkg5/Classes.P.html#m2--\">m2()</a>", |
|
238 "<a href=\"pkg5/Interfaces.A.html#m2--\">m2()</a>", |
|
239 "<a href=\"pkg5/Classes.P.html#m3--\">m3()</a>", |
|
240 "<a href=\"pkg5/Interfaces.A.html#m3--\">m3()</a>", |
|
241 "<a href=\"pkg5/Interfaces.B.html#m3--\">m3()</a>", |
|
242 "<a href=\"pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-\">m4(String, String)</a>", |
|
243 "<a href=\"pkg5/Classes.P.html#m4-K-V-\">m4(K, V)</a>", |
|
244 "<a href=\"pkg5/Classes.P.html#m5--\">m5()</a>", |
|
245 "<a href=\"pkg5/Classes.C.html#m6--\">m6()</a>", |
|
246 "<a href=\"pkg5/Classes.P.html#m6--\">m6()</a>", |
|
247 "<a href=\"pkg5/Classes.C.html#m7--\">m7()</a>", |
|
248 "<a href=\"pkg5/Classes.GP.html#m7--\">m7()</a>", |
|
249 "Returns the enum constant of this type with the specified name.", |
|
250 "Returns an array containing the constants of this enum type, in\n" + |
|
251 "the order they are declared." |
|
252 ); |
|
253 } |
|
254 } |
|