Wed, 01 Dec 2010 11:02:38 -0800
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. |
duke@1 | 8 | * |
duke@1 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | * accompanied this code). |
duke@1 | 14 | * |
duke@1 | 15 | * You should have received a copy of the GNU General Public License version |
duke@1 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | /* |
duke@1 | 25 | * @test |
duke@1 | 26 | * @bug 4780441 4874845 4978816 |
duke@1 | 27 | * @summary Make sure that when the -private flag is not used, members |
duke@1 | 28 | * inherited from package private class are documented in the child. |
duke@1 | 29 | * |
duke@1 | 30 | * Make sure that when a method inherits documentation from a method |
duke@1 | 31 | * in a non-public class/interface, the non-public class/interface |
duke@1 | 32 | * is not mentioned anywhere (not even in the signature or tree). |
duke@1 | 33 | * |
duke@1 | 34 | * Make sure that when a private interface method with generic parameters |
duke@1 | 35 | * is implemented, the comments can be inherited properly. |
duke@1 | 36 | * @author jamieh |
duke@1 | 37 | * @library ../lib/ |
duke@1 | 38 | * @build JavadocTester |
duke@1 | 39 | * @build TestPrivateClasses |
duke@1 | 40 | * @run main TestPrivateClasses |
duke@1 | 41 | */ |
duke@1 | 42 | |
duke@1 | 43 | public class TestPrivateClasses extends JavadocTester { |
duke@1 | 44 | |
duke@1 | 45 | //Test information. |
duke@1 | 46 | private static final String BUG_ID = "4780441-4874845-4978816"; |
duke@1 | 47 | |
duke@1 | 48 | //Javadoc arguments. |
duke@1 | 49 | private static final String[] ARGS1 = new String[] { |
duke@1 | 50 | "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2" |
duke@1 | 51 | }; |
duke@1 | 52 | private static final String[] ARGS2 = new String[] { |
duke@1 | 53 | "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private", |
duke@1 | 54 | "-source", "1.5", "pkg", "pkg2" |
duke@1 | 55 | }; |
duke@1 | 56 | |
duke@1 | 57 | // Test output when -private flag is not used. |
duke@1 | 58 | private static final String[][] TEST1 = { |
duke@1 | 59 | // Field inheritence from non-public superclass. |
duke@1 | 60 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 61 | "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" + |
bpatel@766 | 62 | "fieldInheritedFromParent</a>" |
duke@1 | 63 | }, |
duke@1 | 64 | |
duke@1 | 65 | // Method inheritence from non-public superclass. |
duke@1 | 66 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 67 | "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" + |
bpatel@766 | 68 | "methodInheritedFromParent</a>" |
duke@1 | 69 | }, |
duke@1 | 70 | |
duke@1 | 71 | // Field inheritence from non-public superinterface. |
duke@1 | 72 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 73 | "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" + |
bpatel@766 | 74 | "fieldInheritedFromInterface</a>" |
duke@1 | 75 | }, |
duke@1 | 76 | |
duke@1 | 77 | // Method inheritence from non-public superinterface. |
duke@1 | 78 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 79 | "<a href=\"../pkg/PublicInterface.html#methodInterface(int)\">" + |
bpatel@766 | 80 | "methodInterface</a>" |
duke@1 | 81 | }, |
duke@1 | 82 | |
duke@1 | 83 | // private class does not show up in tree |
duke@1 | 84 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 85 | "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL + |
bpatel@766 | 86 | "<li>" + NL + "<ul class=\"inheritance\">" + NL + "<li>pkg.PublicChild</li>" + NL + |
bpatel@766 | 87 | "</ul>" + NL + "</li>" + NL + "</ul>" |
duke@1 | 88 | }, |
duke@1 | 89 | |
duke@1 | 90 | // Method is documented as though it is declared in the inheriting method. |
duke@1 | 91 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 92 | "<pre>public void methodInheritedFromParent(int p1)" |
duke@1 | 93 | }, |
duke@1 | 94 | |
duke@1 | 95 | //Make sure implemented interfaces from private superclass are inherited |
duke@1 | 96 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 97 | "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL + |
bpatel@766 | 98 | "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" + |
bpatel@766 | 99 | "PublicChild</a></dd>" + NL + "</dl>"}, |
duke@1 | 100 | |
duke@1 | 101 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 102 | "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL + |
bpatel@766 | 103 | "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 104 | "PublicInterface</a></dd>" + NL + "</dl>"}, |
duke@1 | 105 | |
duke@1 | 106 | //Generic interface method test. |
duke@1 | 107 | {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", |
duke@1 | 108 | "This comment should get copied to the implementing class"}, |
duke@1 | 109 | }; |
duke@1 | 110 | private static final String[][] NEGATED_TEST1 = { |
duke@1 | 111 | // Should not document that a method overrides method from private class. |
duke@1 | 112 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 113 | "<strong>Overrides:</strong>"}, |
duke@1 | 114 | // Should not document that a method specified by private interface. |
duke@1 | 115 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 116 | "<strong>Specified by:</strong>"}, |
duke@1 | 117 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 118 | "<strong>Specified by:</strong>"}, |
duke@1 | 119 | // Should not mention that any documentation was copied. |
duke@1 | 120 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 121 | "Description copied from"}, |
duke@1 | 122 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 123 | "Description copied from"}, |
duke@1 | 124 | // Don't extend private classes or interfaces |
duke@1 | 125 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 126 | "PrivateParent"}, |
duke@1 | 127 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 128 | "PrivateInterface"}, |
duke@1 | 129 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 130 | "PrivateInterface"}, |
duke@1 | 131 | {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 132 | "All Superinterfaces"}, |
duke@1 | 133 | // Make inherited constant are documented correctly. |
duke@1 | 134 | {BUG_ID + "-1" + FS + "constant-values.html", |
duke@1 | 135 | "PrivateInterface"}, |
duke@1 | 136 | |
duke@1 | 137 | //Do not inherit private interface method with generic parameters. |
duke@1 | 138 | //This method has been implemented. |
duke@1 | 139 | {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html", |
bpatel@766 | 140 | "<strong><a href=\"../pkg2/I.html#hello(T)\">hello</a></strong>"}, |
duke@1 | 141 | }; |
duke@1 | 142 | |
duke@1 | 143 | // Test output when -private flag is used. |
duke@1 | 144 | private static final String[][] TEST2 = { |
duke@1 | 145 | // Field inheritence from non-public superclass. |
duke@1 | 146 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 147 | "Fields inherited from class pkg." + |
bpatel@766 | 148 | "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 149 | "PrivateParent</a>" |
duke@1 | 150 | }, |
duke@1 | 151 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 152 | "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" + |
bpatel@766 | 153 | "fieldInheritedFromParent</a>" |
duke@1 | 154 | }, |
duke@1 | 155 | // Field inheritence from non-public superinterface. |
duke@1 | 156 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 157 | "Fields inherited from interface pkg." + |
bpatel@766 | 158 | "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 159 | "PrivateInterface</a>" |
duke@1 | 160 | }, |
duke@1 | 161 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 162 | "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" + |
bpatel@766 | 163 | "fieldInheritedFromInterface</a>" |
duke@1 | 164 | }, |
duke@1 | 165 | // Method inheritence from non-public superclass. |
duke@1 | 166 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 167 | "Methods inherited from class pkg." + |
bpatel@766 | 168 | "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 169 | "PrivateParent</a>" |
duke@1 | 170 | }, |
duke@1 | 171 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 172 | "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" + |
bpatel@766 | 173 | "methodInheritedFromParent</a>" |
duke@1 | 174 | }, |
duke@1 | 175 | // Should document that a method overrides method from private class. |
duke@1 | 176 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 177 | "<dt><strong>Overrides:</strong></dt>" + NL + |
bpatel@766 | 178 | "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" + |
bpatel@766 | 179 | "methodOverridenFromParent</a></code> in class <code>" + |
bpatel@766 | 180 | "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 181 | "PrivateParent</a></code></dd>"}, |
duke@1 | 182 | // Should document that a method is specified by private interface. |
duke@1 | 183 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 184 | "<dt><strong>Specified by:</strong></dt>" + NL + |
bpatel@766 | 185 | "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" + |
bpatel@766 | 186 | "methodInterface</a></code> in interface <code>" + |
bpatel@766 | 187 | "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 188 | "PrivateInterface</a></code></dd>"}, |
duke@1 | 189 | // Method inheritence from non-public superinterface. |
duke@1 | 190 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 191 | "Methods inherited from interface pkg." + |
bpatel@766 | 192 | "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 193 | "PrivateInterface</a>" |
duke@1 | 194 | }, |
duke@1 | 195 | {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html", |
bpatel@766 | 196 | "<a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" + |
bpatel@766 | 197 | "methodInterface</a>" |
duke@1 | 198 | }, |
duke@1 | 199 | // Should mention that any documentation was copied. |
duke@1 | 200 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 201 | "Description copied from"}, |
duke@1 | 202 | // Extend documented private classes or interfaces |
duke@1 | 203 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
duke@1 | 204 | "extends"}, |
duke@1 | 205 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 206 | "extends"}, |
duke@1 | 207 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
duke@1 | 208 | "All Superinterfaces"}, |
duke@1 | 209 | |
duke@1 | 210 | //Make sure implemented interfaces from private superclass are inherited |
duke@1 | 211 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html", |
bpatel@766 | 212 | "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL + |
bpatel@766 | 213 | "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" + |
bpatel@766 | 214 | "PrivateParent</a>, " + |
bpatel@766 | 215 | "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" + |
bpatel@766 | 216 | "</a></dd>" + NL + "</dl>"}, |
duke@1 | 217 | |
duke@1 | 218 | {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html", |
bpatel@766 | 219 | "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL + |
bpatel@766 | 220 | "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 221 | "PrivateInterface</a>, " + |
bpatel@766 | 222 | "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" + |
bpatel@766 | 223 | "PublicInterface</a></dd>" + NL + "</dl>"}, |
duke@1 | 224 | |
duke@1 | 225 | //Since private flag is used, we can document that private interface method |
duke@1 | 226 | //with generic parameters has been implemented. |
duke@1 | 227 | {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", |
bpatel@766 | 228 | "<strong>Description copied from interface: <code>" + |
bpatel@766 | 229 | "<a href=\"../pkg2/I.html#hello(T)\">I</a></code></strong>"}, |
duke@1 | 230 | |
duke@1 | 231 | {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html", |
bpatel@766 | 232 | "<dt><strong>Specified by:</strong></dt>" + NL + |
bpatel@766 | 233 | "<dd><code><a href=\"../pkg2/I.html#hello(T)\">hello</a></code>" + |
bpatel@766 | 234 | " in interface <code>" + |
bpatel@766 | 235 | "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" + |
bpatel@766 | 236 | "<java.lang.String></code></dd>"}, |
duke@1 | 237 | }; |
duke@1 | 238 | private static final String[][] NEGATED_TEST2 = NO_TEST; |
duke@1 | 239 | |
duke@1 | 240 | /** |
duke@1 | 241 | * The entry point of the test. |
duke@1 | 242 | * @param args the array of command line arguments. |
duke@1 | 243 | */ |
duke@1 | 244 | public static void main(String[] args) { |
duke@1 | 245 | TestPrivateClasses tester = new TestPrivateClasses(); |
duke@1 | 246 | run(tester, ARGS1, TEST1, NEGATED_TEST1); |
duke@1 | 247 | run(tester, ARGS2, TEST2, NEGATED_TEST2); |
duke@1 | 248 | tester.printSummary(); |
duke@1 | 249 | } |
duke@1 | 250 | |
duke@1 | 251 | /** |
duke@1 | 252 | * {@inheritDoc} |
duke@1 | 253 | */ |
duke@1 | 254 | public String getBugId() { |
duke@1 | 255 | return BUG_ID; |
duke@1 | 256 | } |
duke@1 | 257 | |
duke@1 | 258 | /** |
duke@1 | 259 | * {@inheritDoc} |
duke@1 | 260 | */ |
duke@1 | 261 | public String getBugName() { |
duke@1 | 262 | return getClass().getName(); |
duke@1 | 263 | } |
duke@1 | 264 | } |