author | ksrini |
Fri, 18 Apr 2014 08:35:59 -0700 | |
changeset 24220 | eb213562268d |
child 24394 | 74279778c307 |
permissions | -rw-r--r-- |
24220
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
1 |
/* |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
4 |
* |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
8 |
* |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
14 |
* |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
18 |
* |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
21 |
* questions. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
22 |
*/ |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
23 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
24 |
/* |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
25 |
* @test |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
26 |
* @bug 8039410 |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
27 |
* @summary test to determine if members are ordered correctly |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
28 |
* @author ksrini |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
29 |
* @library ../lib/ |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
30 |
* @build JavadocTester |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
31 |
* @build TestOrdering |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
32 |
* @run main TestOrdering |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
33 |
*/ |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
34 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
35 |
import java.util.regex.Matcher; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
36 |
import java.util.regex.Pattern; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
37 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
38 |
public class TestOrdering extends JavadocTester { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
39 |
/** |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
40 |
* The entry point of the test. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
41 |
* @param args the array of command line arguments. |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
42 |
*/ |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
43 |
public static void main(String[] args) throws Exception { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
44 |
TestOrdering tester = new TestOrdering(); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
45 |
// test unnamed packages |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
46 |
String[] ARGS = { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
47 |
"-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-use", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
48 |
SRC_DIR + "/C.java", SRC_DIR + "/UsedInC.java" |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
49 |
}; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
50 |
tester.runJavadoc(ARGS); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
51 |
checkExecutableMemberOrdering(tester.readFileToString("class-use/UsedInC.html")); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
52 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
53 |
// next test using packages |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
54 |
String[] ARGS1 = { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
55 |
"-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "-use", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
56 |
"pkg1" |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
57 |
}; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
58 |
tester.runJavadoc(ARGS1); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
59 |
checkClassUseOrdering(tester.readFileToString("pkg1/class-use/UsedClass.html")); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
60 |
checkIndexPathOrdering(tester.readFileToString("index-all.html")); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
61 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
62 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
63 |
static void checkExecutableMemberOrdering(String usePage) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
64 |
// check constructors |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
65 |
int idx1 = usePage.indexOf("C.html#C-UsedInC"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
66 |
int idx2 = usePage.indexOf("C.html#C-UsedInC-int"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
67 |
int idx3 = usePage.indexOf("C.html#C-UsedInC-java.lang.String"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
68 |
if (idx1 == -1 || idx2 == -1 || idx3 == -1) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
69 |
throw new Error("ctor strings not found"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
70 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
71 |
if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
72 |
throw new Error("ctor strings are out of order"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
73 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
74 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
75 |
// check methods |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
76 |
idx1 = usePage.indexOf("C.html#ymethod-int"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
77 |
idx2 = usePage.indexOf("C.html#ymethod-java.lang.String"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
78 |
if (idx1 == -1 || idx2 == -1) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
79 |
throw new Error("#ymethod strings not found"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
80 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
81 |
if (idx1 > idx2) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
82 |
throw new Error("#ymethod strings are out of order"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
83 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
84 |
System.out.println("Executable Member Ordering: OK"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
85 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
86 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
87 |
static void checkClassUseOrdering(String usePage) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
88 |
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zfield"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
89 |
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#fieldInC#ITERATION#"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
90 |
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zmethod-pkg1.UsedClass"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
91 |
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#methodInC#ITERATION#"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
92 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
93 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
94 |
static void checkClassUseOrdering(String usePage, String searchString) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
95 |
int lastidx = 0; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
96 |
System.out.println("testing for " + searchString); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
97 |
for (int i = 1; i < 5; i++) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
98 |
String s = searchString.replaceAll("#ITERATION#", Integer.toString(i)); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
99 |
System.out.println(s); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
100 |
int idx = usePage.indexOf(s); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
101 |
if (idx < lastidx) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
102 |
throw new Error(s + ", member ordering error, last:" + lastidx + ", got:" + idx); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
103 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
104 |
System.out.println("\tlast: " + lastidx + " got:" + idx); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
105 |
lastidx = idx; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
106 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
107 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
108 |
|
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
109 |
static void checkIndexPathOrdering(String indexPage) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
110 |
String[] OrderedExpectedStrings = { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
111 |
"pkg1/UsedClass.html#add-java.lang.Double", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
112 |
"pkg1/ZZTop.html#add-double", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
113 |
"pkg1/ZZTop.html#add-java.lang.Double", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
114 |
"pkg1/UsedClass.html#add-float", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
115 |
"pkg1/ZZTop.html#add-float", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
116 |
"pkg1/UsedClass.html#add-int", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
117 |
"pkg1/ZZTop.html#add-int", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
118 |
"pkg1/UsedClass.html#add-java.lang.Integer", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
119 |
"pkg1/ZZTop.html#add-java.lang.Integer", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
120 |
"pkg1/UsedClass.html#add-double-double", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
121 |
"pkg1/UsedClass.html#add-double-java.lang.Double", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
122 |
"pkg1/ZZTop.html#add-double-double", |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
123 |
"pkg1/ZZTop.html#add-double-java.lang.Double" |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
124 |
}; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
125 |
int lastidx = 0; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
126 |
for (String x : OrderedExpectedStrings) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
127 |
int idx = indexPage.indexOf(x); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
128 |
if (idx < lastidx) { |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
129 |
throw new Error(x + ", index is out of order, last:" + lastidx + ", got:" + idx); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
130 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
131 |
System.out.println(x + ": OK"); |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
132 |
lastidx = idx; |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
133 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
134 |
} |
eb213562268d
8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff
changeset
|
135 |
} |