TestAnchorNames.java revision 3233:b5d08bc0d224
1243791Sdim/*
2243791Sdim * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
3243791Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4243791Sdim *
5243791Sdim * This code is free software; you can redistribute it and/or modify it
6243791Sdim * under the terms of the GNU General Public License version 2 only, as
7243791Sdim * published by the Free Software Foundation.
8243791Sdim *
9243791Sdim * This code is distributed in the hope that it will be useful, but WITHOUT
10243791Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11243791Sdim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12243791Sdim * version 2 for more details (a copy is included in the LICENSE file that
13243791Sdim * accompanied this code).
14243791Sdim *
15243791Sdim * You should have received a copy of the GNU General Public License version
16243791Sdim * 2 along with this work; if not, write to the Free Software Foundation,
17263509Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18243791Sdim *
19252723Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20243791Sdim * or visit www.oracle.com if you need additional information or have any
21243791Sdim * questions.
22243791Sdim */
23243791Sdim
24243791Sdim/*
25243791Sdim * @test
26243791Sdim * @bug 8025633 8025524 8081854
27243791Sdim * @summary Test for valid name attribute in HTML anchors.
28243791Sdim * @author Bhavesh Patel
29243791Sdim * @library ../lib
30243791Sdim * @modules jdk.javadoc
31243791Sdim * @build JavadocTester
32243791Sdim * @run main TestAnchorNames
33243791Sdim */
34243791Sdim
35243791Sdimpublic class TestAnchorNames extends JavadocTester {
36243791Sdim
37243791Sdim    private static final String[] ARGS = new String[] {
38243791Sdim
39243791Sdim    };
40243791Sdim
41243791Sdim    public static void main(String[] args) throws Exception {
42243791Sdim        TestAnchorNames tester = new TestAnchorNames();
43243791Sdim        tester.runTests();
44243791Sdim    }
45243791Sdim
46243791Sdim    @Test
47243791Sdim    void test() {
48243791Sdim        javadoc("-d", "out",
49243791Sdim                "-sourcepath", testSrc,
50243791Sdim                "-source", "8", //so that '_' can be used as an identifier
51243791Sdim                "-use",
52243791Sdim                "pkg1");
53243791Sdim        checkExit(Exit.OK);
54243791Sdim
55243791Sdim        // Test some section markers and links to these markers
56243791Sdim        checkOutput("pkg1/RegClass.html", true,
57243791Sdim                "<a name=\"skip.navbar.top\">",
58243791Sdim                "<a href=\"#skip.navbar.top\" title=\"Skip navigation links\">",
59243791Sdim                "<a name=\"nested.class.summary\">",
60243791Sdim                "<a href=\"#nested.class.summary\">",
61243791Sdim                "<a name=\"method.summary\">",
62243791Sdim                "<a href=\"#method.summary\">",
63243791Sdim                "<a name=\"field.detail\">",
64243791Sdim                "<a href=\"#field.detail\">",
65243791Sdim                "<a name=\"constructor.detail\">",
66243791Sdim                "<a href=\"#constructor.detail\">");
67243791Sdim
68243791Sdim        // Test some members and link to these members
69243791Sdim        checkOutput("pkg1/RegClass.html", true,
70243791Sdim                //The marker for this appears in the serialized-form.html which we will
71243791Sdim                //test below
72243791Sdim                "<a href=\"../serialized-form.html#pkg1.RegClass\">");
73243791Sdim
74243791Sdim        // Test some fields
75243791Sdim        checkOutput("pkg1/RegClass.html", true,
76243791Sdim                "<a name=\"Z:Z_\">",
77243791Sdim                "<a href=\"../pkg1/RegClass.html#Z:Z_\">",
78243791Sdim                "<a name=\"Z:Z_:D\">",
79243791Sdim                "<a href=\"../pkg1/RegClass.html#Z:Z_:D\">",
80243791Sdim                "<a name=\"Z:Z:D_\">",
81243791Sdim                "<a href=\"../pkg1/RegClass.html#Z:Z:D_\">",
82243791Sdim                "<a name=\"Z:Z:Dfield\">",
83243791Sdim                "<a href=\"../pkg1/RegClass.html#Z:Z:Dfield\">",
84243791Sdim                "<a name=\"fieldInCla:D:D\">",
85243791Sdim                "<a href=\"../pkg1/RegClass.html#fieldInCla:D:D\">",
86243791Sdim                "<a name=\"S_:D:D:D:D:DINT\">",
87243791Sdim                "<a href=\"../pkg1/RegClass.html#S_:D:D:D:D:DINT\">",
88243791Sdim                "<a name=\"method:D:D\">",
89243791Sdim                "<a href=\"../pkg1/RegClass.html#method:D:D\">");
90243791Sdim
91243791Sdim        checkOutput("pkg1/DeprMemClass.html", true,
92243791Sdim                "<a name=\"Z:Z_field_In_Class\">",
93243791Sdim                "<a href=\"../pkg1/DeprMemClass.html#Z:Z_field_In_Class\">");
94243791Sdim
95243791Sdim        // Test constructor
96243791Sdim        checkOutput("pkg1/RegClass.html", true,
97243791Sdim                "<a name=\"RegClass-java.lang.String-int-\">",
98243791Sdim                "<a href=\"../pkg1/RegClass.html#RegClass-java.lang.String-int-\">");
99243791Sdim
100243791Sdim        // Test some methods
101243791Sdim        checkOutput("pkg1/RegClass.html", true,
102243791Sdim                "<a name=\"Z:Z_methodInClass-java.lang.String-\">",
103243791Sdim                "<a href=\"../pkg1/RegClass.html#Z:Z_methodInClass-java.lang.String-\">",
104243791Sdim                "<a name=\"method--\">",
105243791Sdim                "<a href=\"../pkg1/RegClass.html#method--\">",
106243791Sdim                "<a name=\"foo-java.util.Map-\">",
107243791Sdim                "<a href=\"../pkg1/RegClass.html#foo-java.util.Map-\">",
108243791Sdim                "<a name=\"methodInCla:Ds-java.lang.String:A-\">",
109243791Sdim                "<a href=\"../pkg1/RegClass.html#methodInCla:Ds-java.lang.String:A-\">",
110243791Sdim                "<a name=\"Z:Z_methodInClas:D-java.lang.String-int-\">",
111243791Sdim                "<a href=\"../pkg1/RegClass.html#Z:Z_methodInClas:D-java.lang.String-int-\">",
112243791Sdim                "<a name=\"methodD-pkg1.RegClass.:DA-\">",
113243791Sdim                "<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.:DA-\">",
114243791Sdim                "<a name=\"methodD-pkg1.RegClass.D:A-\">",
115243791Sdim                "<a href=\"../pkg1/RegClass.html#methodD-pkg1.RegClass.D:A-\">");
116243791Sdim
117243791Sdim        checkOutput("pkg1/DeprMemClass.html", true,
118243791Sdim                "<a name=\"Z:Z:Dmethod_In_Class--\">",
119243791Sdim                "<a href=\"../pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">");
120243791Sdim
121243791Sdim        // Test enum
122243791Sdim        checkOutput("pkg1/RegClass.Te$t_Enum.html", true,
123243791Sdim                "<a name=\"Z:Z:DFLD2\">",
124243791Sdim                "<a href=\"../pkg1/RegClass.Te$t_Enum.html#Z:Z:DFLD2\">");
125243791Sdim
126243791Sdim        // Test nested class
127243791Sdim        checkOutput("pkg1/RegClass._NestedClas$.html", true,
128243791Sdim                "<a name=\"Z:Z_NestedClas:D--\">",
129243791Sdim                "<a href=\"../pkg1/RegClass._NestedClas$.html#Z:Z_NestedClas:D--\">");
130243791Sdim
131243791Sdim        // Test class use page
132243791Sdim        checkOutput("pkg1/class-use/DeprMemClass.html", true,
133243791Sdim                "<a href=\"../../pkg1/RegClass.html#d____mc\">");
134243791Sdim
135243791Sdim        // Test deprecated list page
136243791Sdim        checkOutput("deprecated-list.html", true,
137243791Sdim                "<a href=\"pkg1/DeprMemClass.html#Z:Z_field_In_Class\">",
138243791Sdim                "<a href=\"pkg1/DeprMemClass.html#Z:Z:Dmethod_In_Class--\">");
139243791Sdim
140243791Sdim        // Test constant values page
141243791Sdim        checkOutput("constant-values.html", true,
142243791Sdim                "<a href=\"pkg1/RegClass.html#S_:D:D:D:D:DINT\">");
143243791Sdim
144243791Sdim        // Test serialized form page
145243791Sdim        checkOutput("serialized-form.html", true,
146243791Sdim                //This is the marker for the link that appears in the pkg1.RegClass.html page
147243791Sdim                "<a name=\"pkg1.RegClass\">");
148243791Sdim
149243791Sdim        // Test member name index page
150243791Sdim        checkOutput("index-all.html", true,
151243791Sdim                "<a name=\"I:Z:Z:D\">",
152243791Sdim                "<a href=\"#I:Z:Z:D\">$",
153243791Sdim                "<a href=\"#I:Z:Z_\">_");
154243791Sdim
155243791Sdim        // The marker name conversion should only affect HTML anchors. It should not
156243791Sdim        // affect the lables.
157243791Sdim        checkOutput("pkg1/RegClass.html", false,
158243791Sdim                " Z:Z_",
159243791Sdim                " Z:Z:Dfield",
160243791Sdim                " Z:Z_field_In_Class",
161243791Sdim                " S_:D:D:D:D:DINT");
162243791Sdim    }
163243791Sdim}
164243791Sdim