author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 26779 | 5437f17cbf69 |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
8632
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26779
diff
changeset
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
8632
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
4 |
* |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
8 |
* |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
14 |
* |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
18 |
* |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
21 |
* questions. |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
22 |
*/ |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
23 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
24 |
/* |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
25 |
* @test |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
26 |
* @bug 6227454 |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
27 |
* @summary package.html and overview.html may not be read fully |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26779
diff
changeset
|
28 |
* @modules jdk.javadoc |
8632
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
29 |
*/ |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
30 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
31 |
import java.io.*; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
32 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
33 |
import com.sun.javadoc.Doclet; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
34 |
import com.sun.javadoc.RootDoc; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
35 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
36 |
public class Test extends Doclet { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
37 |
public static void main(String... args) throws Exception { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
38 |
new Test().run(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
39 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
40 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
41 |
void run() throws Exception { |
26779
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
42 |
test("<body>ABC XYZ</body>"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
43 |
test("<body>ABC XYZ</BODY>"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
44 |
test("<BODY>ABC XYZ</body>"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
45 |
test("<BODY>ABC XYZ</BODY>"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
46 |
test("<BoDy>ABC XYZ</bOdY>"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
47 |
test(" ABC XYZ</bOdY>", "Body tag missing from HTML"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
48 |
test("<body>ABC XYZ ", "Close body tag missing from HTML"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
49 |
test(" ABC XYZ ", "Body tag missing from HTML"); |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
50 |
test("<body>ABC" + bigText(8192, 40) + "XYZ</body>"); |
8632
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
51 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
52 |
if (errors > 0) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
53 |
throw new Exception(errors + " errors occurred"); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
54 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
55 |
|
26779
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
56 |
void test(String body) throws IOException { |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
57 |
test(body, null); |
8632
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
58 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
59 |
|
26779
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
60 |
void test(String body, String expectError) throws IOException { |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
61 |
String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
62 |
+ "\"http://www.w3.org/TR/html4/loose.dtd\">"; |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
63 |
String headTag = "<head><title>Title </title></head>"; |
5437f17cbf69
8058755: Update tools/javadoc/6227454 to add head tag
sogoel
parents:
25297
diff
changeset
|
64 |
String text = docType + "<html>" + headTag + body + "</html>"; |
8632
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
65 |
testNum++; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
66 |
System.err.println("test " + testNum); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
67 |
File file = writeFile("overview" + testNum + ".html", text); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
68 |
String thisClassName = Test.class.getName(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
69 |
File testSrc = new File(System.getProperty("test.src")); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
70 |
String[] args = { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
71 |
"-bootclasspath", |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
72 |
System.getProperty("java.class.path") |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
73 |
+ File.pathSeparator |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
74 |
+ System.getProperty("sun.boot.class.path"), |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
75 |
"-classpath", ".", |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
76 |
"-package", |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
77 |
"-overview", file.getPath(), |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
78 |
new File(testSrc, thisClassName + ".java").getPath() |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
79 |
}; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
80 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
81 |
StringWriter sw = new StringWriter(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
82 |
PrintWriter pw = new PrintWriter(sw); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
83 |
int rc = com.sun.tools.javadoc.Main.execute( |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
84 |
"javadoc", |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
85 |
pw, pw, pw, |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
86 |
thisClassName, |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
87 |
args); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
88 |
pw.close(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
89 |
String out = sw.toString(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
90 |
if (!out.isEmpty()) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
91 |
System.err.println(out); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
92 |
System.err.println("javadoc exit: rc=" + rc); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
93 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
94 |
if (expectError == null) { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
95 |
if (rc != 0) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
96 |
error("unexpected exit from javadoc; rc:" + rc); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
97 |
} else { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
98 |
if (!out.contains(expectError)) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
99 |
error("expected error text not found: " + expectError); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
100 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
101 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
102 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
103 |
String bigText(int lines, int lineLength) { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
104 |
StringBuilder sb = new StringBuilder(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
105 |
for (int i = 0; i < lineLength; i++) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
106 |
sb.append(String.valueOf(i % 10)); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
107 |
sb.append("\n"); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
108 |
String line = sb.toString(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
109 |
sb.setLength(0); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
110 |
for (int i = 0; i < lines; i++) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
111 |
sb.append(line); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
112 |
return sb.toString(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
113 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
114 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
115 |
File writeFile(String path, String body) throws IOException { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
116 |
File f = new File(path); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
117 |
FileWriter out = new FileWriter(f); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
118 |
try { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
119 |
out.write(body); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
120 |
} finally { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
121 |
out.close(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
122 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
123 |
return f; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
124 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
125 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
126 |
void error(String msg) { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
127 |
System.err.println("Error: " + msg); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
128 |
errors++; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
129 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
130 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
131 |
int testNum; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
132 |
int errors; |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
133 |
|
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
134 |
public static boolean start(RootDoc root) { |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
135 |
String text = root.commentText(); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
136 |
if (text.length() < 64) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
137 |
System.err.println("text: '" + text + "'"); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
138 |
else |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
139 |
System.err.println("text: '" |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
140 |
+ text.substring(0, 20) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
141 |
+ "..." |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
142 |
+ text.substring(text.length() - 20) |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
143 |
+ "'"); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
144 |
return text.startsWith("ABC") && text.endsWith("XYZ"); |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
145 |
} |
af2a1f02c8ac
6227454: package.html and overview.html may not be read fully
jjg
parents:
diff
changeset
|
146 |
} |