Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/com/sun/javadoc/testAnchorNames/TestAnchorNames.java
86410 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 8025633 802552426* @summary Test for valid name attribute in HTML anchors.27* @author Bhavesh Patel28* @library ../lib/29* @build JavadocTester TestAnchorNames30* @run main TestAnchorNames31*/3233public class TestAnchorNames extends JavadocTester {3435private static final String BUG_ID = "8025633";3637//Input for string search tests.38private static final String[][] TEST = {3940//Test some section markers and links to these markers4142{BUG_ID + FS + "pkg1" + FS + "RegClass.html",43"<a name=\"skip.navbar.top\">"44},45{BUG_ID + FS + "pkg1" + FS + "RegClass.html",46"<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">"47},48{BUG_ID + FS + "pkg1" + FS + "RegClass.html",49"<a name=\"nested.class.summary\">"50},51{BUG_ID + FS + "pkg1" + FS + "RegClass.html",52"<a href=\"#nested.class.summary\">"53},54{BUG_ID + FS + "pkg1" + FS + "RegClass.html",55"<a name=\"method.summary\">"56},57{BUG_ID + FS + "pkg1" + FS + "RegClass.html",58"<a href=\"#method.summary\">"59},60{BUG_ID + FS + "pkg1" + FS + "RegClass.html",61"<a name=\"field.detail\">"62},63{BUG_ID + FS + "pkg1" + FS + "RegClass.html",64"<a href=\"#field.detail\">"65},66{BUG_ID + FS + "pkg1" + FS + "RegClass.html",67"<a name=\"constructor.detail\">"68},69{BUG_ID + FS + "pkg1" + FS + "RegClass.html",70"<a href=\"#constructor.detail\">"71},7273//Test some members and link to these members7475//The marker for this appears in the serialized-form.html which we will76//test below77{BUG_ID + FS + "pkg1" + FS + "RegClass.html",78"<a href=\"../serialized-form.html#pkg1.RegClass\">"79},80//Test some fields81{BUG_ID + FS + "pkg1" + FS + "RegClass.html",82"<a name=\"Z:Z_\">"83},84{BUG_ID + FS + "pkg1" + FS + "RegClass.html",85"<a href=\"../pkg1/RegClass.html#Z:Z_\">"86},87{BUG_ID + FS + "pkg1" + FS + "RegClass.html",88"<a name=\"Z:Z_:D\">"89},90{BUG_ID + FS + "pkg1" + FS + "RegClass.html",91"<a href=\"../pkg1/RegClass.html#Z:Z_:D\">"92},93{BUG_ID + FS + "pkg1" + FS + "RegClass.html",94"<a name=\"Z:Z:D_\">"95},96{BUG_ID + FS + "pkg1" + FS + "RegClass.html",97"<a href=\"../pkg1/RegClass.html#Z:Z:D_\">"98},99{BUG_ID + FS + "pkg1" + FS + "RegClass.html",100"<a name=\"Z:Z:Dfield\">"101},102{BUG_ID + FS + "pkg1" + FS + "RegClass.html",103"<a href=\"../pkg1/RegClass.html#Z:Z:Dfield\">"104},105{BUG_ID + FS + "pkg1" + FS + "RegClass.html",106"<a name=\"fieldInCla:D:D\">"107},108{BUG_ID + FS + "pkg1" + FS + "RegClass.html",109"<a href=\"../pkg1/RegClass.html#fieldInCla:D:D\">"110},111{BUG_ID + FS + "pkg1" + FS + "RegClass.html",112"<a name=\"S_:D:D:D:D:DINT\">"113},114{BUG_ID + FS + "pkg1" + FS + "RegClass.html",115"<a href=\"../pkg1/RegClass.html#S_:D:D:D:D:DINT\">"116},117{BUG_ID + FS + "pkg1" + FS + "RegClass.html",118"<a name=\"method:D:D\">"119},120{BUG_ID + FS + "pkg1" + FS + "RegClass.html",121"<a href=\"../pkg1/RegClass.html#method:D:D\">"122},123{BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html",124"<a name=\"Z:Z_field_In_Class\">"125},126{BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html",127"<a href=\"../pkg1/DeprMemClass.html#Z:Z_field_In_Class\">"128},129//Test constructor130{BUG_ID + FS + "pkg1" + FS + "RegClass.html",131"<a name=\"RegClass-java.lang.String-int-\">"132},133{BUG_ID + FS + "pkg1" + FS + "RegClass.html",134"<a href=\"../pkg1/RegClass.html#RegClass-java.lang.String-int-\">"135},136//Test some methods137{BUG_ID + FS + "pkg1" + FS + "RegClass.html",138"<a name=\"Z:Z_methodInClass-java.lang.String-\">"139},140{BUG_ID + FS + "pkg1" + FS + "RegClass.html",141"<a href=\"../pkg1/RegClass.html#Z:Z_methodInClass-java.lang.String-\">"142},143{BUG_ID + FS + "pkg1" + FS + "RegClass.html",144"<a name=\"method--\">"145},146{BUG_ID + FS + "pkg1" + FS + "RegClass.html",147"<a href=\"../pkg1/RegClass.html#method--\">"148},149{BUG_ID + FS + "pkg1" + FS + "RegClass.html",150"<a name=\"foo-java.util.Map-\">"151},152{BUG_ID + FS + "pkg1" + FS + "RegClass.html",153"<a href=\"../pkg1/RegClass.html#foo-java.util.Map-\">"154},155{BUG_ID + FS + "pkg1" + FS + "RegClass.html",156"<a name=\"methodInCla:Ds-java.lang.String:A-\">"157},158{BUG_ID + FS + "pkg1" + FS + "RegClass.html",159"<a href=\"../pkg1/RegClass.html#methodInCla:Ds-java.lang.String:A-\">"160},161{BUG_ID + FS + "pkg1" + FS + "RegClass.html",162"<a name=\"Z:Z_methodInClas:D-java.lang.String-int-\">"163},164{BUG_ID + FS + "pkg1" + FS + "RegClass.html",165"<a href=\"../pkg1/RegClass.html#Z:Z_methodInClas:D-java.lang.String-int-\">"166},167{BUG_ID + FS + "pkg1" + FS + "RegClass.html",168"<a name=\"methodD-pkg1.RegClass.:DA-\">"169},170{BUG_ID + FS + "pkg1" + FS + "RegClass.html",171"<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.:DA-\">"172},173{BUG_ID + FS + "pkg1" + FS + "RegClass.html",174"<a name=\"methodD-pkg1.RegClass.D:A-\">"175},176{BUG_ID + FS + "pkg1" + FS + "RegClass.html",177"<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.D:A-\">"178},179{BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html",180"<a name=\"Z:Z:Dmethod_In_Class--\">"181},182{BUG_ID + FS + "pkg1" + FS + "DeprMemClass.html",183"<a href=\"../pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">"184},185186//Test enum187188{BUG_ID + FS + "pkg1" + FS + "RegClass.Te$t_Enum.html",189"<a name=\"Z:Z:DFLD2\">"190},191{BUG_ID + FS + "pkg1" + FS + "RegClass.Te$t_Enum.html",192"<a href=\"../pkg1/RegClass.Te$t_Enum.html#Z:Z:DFLD2\">"193},194195//Test nested class196197{BUG_ID + FS + "pkg1" + FS + "RegClass._NestedClas$.html",198"<a name=\"Z:Z_NestedClas:D--\">"199},200{BUG_ID + FS + "pkg1" + FS + "RegClass._NestedClas$.html",201"<a href=\"../pkg1/RegClass._NestedClas$.html#Z:Z_NestedClas:D--\">"202},203204//Test class use page205206{BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "DeprMemClass.html",207"<a href=\"../../pkg1/RegClass.html#d____mc\">"208},209210//Test deprecated list page211212{BUG_ID + FS + "deprecated-list.html",213"<a href=\"pkg1/DeprMemClass.html#Z:Z_field_In_Class\">"214},215{BUG_ID + FS + "deprecated-list.html",216"<a href=\"pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">"217},218219//Test constant values page220221{BUG_ID + FS + "constant-values.html",222"<a href=\"pkg1/RegClass.html#S_:D:D:D:D:DINT\">"223},224225//Test serialized form page226227//This is the marker for the link that appears in the pkg1.RegClass.html page228{BUG_ID + FS + "serialized-form.html",229"<a name=\"pkg1.RegClass\">"230},231232//Test member name index page233234{BUG_ID + FS + "index-all.html",235"<a name=\"I:Z:Z:D\">"236},237{BUG_ID + FS + "index-all.html",238"<a href=\"#I:Z:Z:D\">$"239},240{BUG_ID + FS + "index-all.html",241"<a href=\"#I:Z:Z_\">_"242}243};244245private static final String[][] NEGATED_TEST = {246//The marker name conversion should only affect HTML anchors. It should not247//affect the lables.248{BUG_ID + FS + "pkg1" + FS + "RegClass.html",249" Z:Z_"250},251{BUG_ID + FS + "pkg1" + FS + "RegClass.html",252" Z:Z:Dfield"253},254{BUG_ID + FS + "pkg1" + FS + "RegClass.html",255" Z:Z_field_In_Class"256},257{BUG_ID + FS + "pkg1" + FS + "RegClass.html",258" S_:D:D:D:D:DINT"259},260};261262private static final String[] ARGS = new String[] {263"-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1"264};265266/**267* The entry point of the test.268* @param args the array of command line arguments.269*/270public static void main(String[] args) throws Exception {271TestAnchorNames tester = new TestAnchorNames();272run(tester, ARGS, TEST, NEGATED_TEST);273tester.printSummary();274}275276/**277* {@inheritDoc}278*/279public String getBugId() {280return BUG_ID;281}282283/**284* {@inheritDoc}285*/286public String getBugName() {287return getClass().getName();288}289}290291292