TestAnchorNames.java revision 2100:933ba3f81a87
1/* 2 * Copyright (c) 2013, 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 8025633 27 * @summary Test for valid name attribute in HTML anchors. 28 * @author Bhavesh Patel 29 * @library ../lib/ 30 * @build JavadocTester TestAnchorNames 31 * @run main TestAnchorNames 32 */ 33 34public class TestAnchorNames extends JavadocTester { 35 36 private static final String BUG_ID = "8025633"; 37 38 //Input for string search tests. 39 private static final String[][] TEST = { 40 41 //Test some section markers and links to these markers 42 43 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 44 "<a name=\"skip.navbar.top\">" 45 }, 46 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 47 "<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">" 48 }, 49 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 50 "<a name=\"nested.class.summary\">" 51 }, 52 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 53 "<a href=\"#nested.class.summary\">" 54 }, 55 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 56 "<a name=\"method.summary\">" 57 }, 58 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 59 "<a href=\"#method.summary\">" 60 }, 61 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 62 "<a name=\"field.detail\">" 63 }, 64 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 65 "<a href=\"#field.detail\">" 66 }, 67 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 68 "<a name=\"constructor.detail\">" 69 }, 70 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 71 "<a href=\"#constructor.detail\">" 72 }, 73 74 //Test some members and link to these members 75 76 //The marker for this appears in the serialized-form.html which we will 77 //test below 78 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 79 "<a href=\"../serialized-form.html#pkg1.RegClass\">" 80 }, 81 //Test some fields 82 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 83 "<a name=\"Z:Z_\">" 84 }, 85 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 86 "<a href=\"../pkg1/RegClass.html#Z:Z_\">" 87 }, 88 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 89 "<a name=\"Z:Z_:D\">" 90 }, 91 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 92 "<a href=\"../pkg1/RegClass.html#Z:Z_:D\">" 93 }, 94 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 95 "<a name=\"Z:Z:D_\">" 96 }, 97 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 98 "<a href=\"../pkg1/RegClass.html#Z:Z:D_\">" 99 }, 100 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 101 "<a name=\"Z:Z:Dfield\">" 102 }, 103 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 104 "<a href=\"../pkg1/RegClass.html#Z:Z:Dfield\">" 105 }, 106 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 107 "<a name=\"fieldInCla:D:D\">" 108 }, 109 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 110 "<a href=\"../pkg1/RegClass.html#fieldInCla:D:D\">" 111 }, 112 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 113 "<a name=\"S_:D:D:D:D:DINT\">" 114 }, 115 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 116 "<a href=\"../pkg1/RegClass.html#S_:D:D:D:D:DINT\">" 117 }, 118 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 119 "<a name=\"method:D:D\">" 120 }, 121 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 122 "<a href=\"../pkg1/RegClass.html#method:D:D\">" 123 }, 124 {BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html", 125 "<a name=\"Z:Z_field_In_Class\">" 126 }, 127 {BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html", 128 "<a href=\"../pkg1/DeprMemClass.html#Z:Z_field_In_Class\">" 129 }, 130 //Test constructor 131 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 132 "<a name=\"RegClass-java.lang.String-int-\">" 133 }, 134 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 135 "<a href=\"../pkg1/RegClass.html#RegClass-java.lang.String-int-\">" 136 }, 137 //Test some methods 138 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 139 "<a name=\"Z:Z_methodInClass-java.lang.String-\">" 140 }, 141 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 142 "<a href=\"../pkg1/RegClass.html#Z:Z_methodInClass-java.lang.String-\">" 143 }, 144 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 145 "<a name=\"method--\">" 146 }, 147 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 148 "<a href=\"../pkg1/RegClass.html#method--\">" 149 }, 150 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 151 "<a name=\"foo-java.util.Map-\">" 152 }, 153 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 154 "<a href=\"../pkg1/RegClass.html#foo-java.util.Map-\">" 155 }, 156 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 157 "<a name=\"methodInCla:Ds-java.lang.String:A-\">" 158 }, 159 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 160 "<a href=\"../pkg1/RegClass.html#methodInCla:Ds-java.lang.String:A-\">" 161 }, 162 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 163 "<a name=\"Z:Z_methodInClas:D-java.lang.String-int-\">" 164 }, 165 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 166 "<a href=\"../pkg1/RegClass.html#Z:Z_methodInClas:D-java.lang.String-int-\">" 167 }, 168 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 169 "<a name=\"methodD-pkg1.RegClass.:DA-\">" 170 }, 171 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 172 "<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.:DA-\">" 173 }, 174 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 175 "<a name=\"methodD-pkg1.RegClass.D:A-\">" 176 }, 177 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 178 "<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.D:A-\">" 179 }, 180 {BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html", 181 "<a name=\"Z:Z:Dmethod_In_Class--\">" 182 }, 183 {BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html", 184 "<a href=\"../pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">" 185 }, 186 187 //Test enum 188 189 {BUG_ID + FS + "pkg1" + FS + "RegClass.Te$t_Enum.html", 190 "<a name=\"Z:Z:DFLD2\">" 191 }, 192 {BUG_ID + FS + "pkg1" + FS + "RegClass.Te$t_Enum.html", 193 "<a href=\"../pkg1/RegClass.Te$t_Enum.html#Z:Z:DFLD2\">" 194 }, 195 196 //Test nested class 197 198 {BUG_ID + FS + "pkg1" + FS + "RegClass._NestedClas$.html", 199 "<a name=\"RegClass._NestedClas:D--\">" 200 }, 201 {BUG_ID + FS + "pkg1" + FS + "RegClass._NestedClas$.html", 202 "<a href=\"../pkg1/RegClass._NestedClas$.html#RegClass._NestedClas:D--\">" 203 }, 204 205 //Test class use page 206 207 {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "DeprMemClass.html", 208 "<a href=\"../../pkg1/RegClass.html#d____mc\">" 209 }, 210 211 //Test deprecated list page 212 213 {BUG_ID + FS + "deprecated-list.html", 214 "<a href=\"pkg1/DeprMemClass.html#Z:Z_field_In_Class\">" 215 }, 216 {BUG_ID + FS + "deprecated-list.html", 217 "<a href=\"pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">" 218 }, 219 220 //Test constant values page 221 222 {BUG_ID + FS + "constant-values.html", 223 "<a href=\"pkg1/RegClass.html#S_:D:D:D:D:DINT\">" 224 }, 225 226 //Test serialized form page 227 228 //This is the marker for the link that appears in the pkg1.RegClass.html page 229 {BUG_ID + FS + "serialized-form.html", 230 "<a name=\"pkg1.RegClass\">" 231 }, 232 233 //Test member name index page 234 235 {BUG_ID + FS + "index-all.html", 236 "<a name=\"I:Z:Z:D\">" 237 }, 238 {BUG_ID + FS + "index-all.html", 239 "<a href=\"#I:Z:Z:D\">$" 240 }, 241 {BUG_ID + FS + "index-all.html", 242 "<a href=\"#I:Z:Z_\">_" 243 } 244 }; 245 246 private static final String[][] NEGATED_TEST = { 247 //The marker name conversion should only affect HTML anchors. It should not 248 //affect the lables. 249 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 250 " Z:Z_" 251 }, 252 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 253 " Z:Z:Dfield" 254 }, 255 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 256 " Z:Z_field_In_Class" 257 }, 258 {BUG_ID + FS + "pkg1" + FS + "RegClass.html", 259 " S_:D:D:D:D:DINT" 260 }, 261 }; 262 263 private static final String[] ARGS = new String[] { 264 "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1" 265 }; 266 267 /** 268 * The entry point of the test. 269 * @param args the array of command line arguments. 270 */ 271 public static void main(String[] args) throws Exception { 272 TestAnchorNames tester = new TestAnchorNames(); 273 run(tester, ARGS, TEST, NEGATED_TEST); 274 tester.printSummary(); 275 } 276 277 /** 278 * {@inheritDoc} 279 */ 280 public String getBugId() { 281 return BUG_ID; 282 } 283 284 /** 285 * {@inheritDoc} 286 */ 287 public String getBugName() { 288 return getClass().getName(); 289 } 290} 291