1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
import java.io.*;
import java.util.*;
import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;
import org.apache.tools.ant.types.*;
/**
* Tests the Ajdoc ant task.
*/
public class AjdocTaskTester extends AntTaskTester {
/** todo correlate with basedir, local.properties in test-ant-task */
protected final static String TEST_DOCDIR
= "test-docs";
protected final static String TEST_SOURCES = "../src";
protected File docDir = null;
/**
* We use <code>"tests/ant/etc/ajc.xml"</code>.
*/
public String getAntFile() {
return "tests/ant/etc/ajdoc.xml";
}
/**
* Put {@link #TEST_DOCDIR} and {@link #TEST_SOURCES}
* into the user properties.
*/
protected Map getUserProperties() {
Map userProps = new HashMap();
// these are in local.properties per test-ant-tasks.xml
//userProps.put("ajdoc.relative.doc.dir", TEST_DOCDIR );
//userProps.put("ajdoc.relative.src.dir", TEST_SOURCES);
return userProps;
}
////// Begin tests //////////////////////////////////////////////
public void test_stylesheetfile() {
avoid(STYLESHEET_CSS);
wantFiles("One.html");
wantFiles("mystylesheet.css");
}
public void test_helpfile() {
avoid(HELP_DOC_HTML);
wantFiles("One.html");
wantFiles("myhelp.html");
}
public void test_nodeprecatedlist_no() {
wantFiles("One.html");
}
public void test_nodeprecatedlist_yes() {
avoid(DEPRECATED_LIST_HTML);
wantFiles("One.html");
}
public void test_nodeprecated_no() { wantFiles("One.html"); }
public void test_nodeprecated_yes() { wantFiles("One.html"); }
public void test_use_no() {
wantFiles("One.html");
}
public void test_use_yes() {
wantFiles("One.html");
wantFiles("class-use/One.html");
}
public void test_standard_no() {
wantFiles("One.html");
}
public void test_standard_yes() {
wantFiles("One.html");
}
public void test_author_no() { wantFiles("One.html"); }
public void test_author_yes() { wantFiles("One.html"); }
public void test_public_no() { wantFiles("One.html"); }
public void test_public_yes() { wantFiles("One.html"); }
public void test_package_no() { wantFiles("One.html"); }
public void test_package_yes() { wantFiles("One.html"); }
public void test_protected_no() { wantFiles("One.html"); }
public void test_protected_yes() { wantFiles("One.html"); }
public void test_private_no() { wantFiles("One.html"); }
public void test_private_yes() { wantFiles("One.html"); }
public void test_splitindex_no() {
wantFiles("One.html");
}
public void test_splitindex_yes() {
avoid(INDEX_ALL_HTML);
wantFiles("One.html");
}
public void test_windowtitle() {
wantFiles("One.html");
}
public void test_doctitle() {
wantFiles("One.html");
}
public void test_bottom() {
wantFiles("One.html");
}
public void test_footer() {
wantFiles("One.html");
}
public void test_header() {
wantFiles("One.html");
}
public void test_nohelp_no() {
wantFiles("One.html");
}
public void test_nohelp_yes() {
avoid(HELP_DOC_HTML);
wantFiles("One.html");
}
public void test_noindex_no() {
wantFiles("One.html");
}
public void test_noindex_yes() {
avoid(INDEX_ALL_HTML);
wantFiles("One.html");
}
public void test_notree_no() {
wantFiles("One.html");
}
public void test_notree_yes() {
avoid(OVERVIEW_TREE_HTML);
wantFiles("One.html");
}
public void test985() {
wantFiles("p1/One.html,p1/pp1/One.html");
wantFiles("p2/Two.html,p2/pp2/Two.html");
}
public void test986() {
wantFiles("p1/One.html,p1/pp1/One.html");
}
public void test987() {
wantFiles("p1/One.html");
wantFiles("p2/Two.html");
}
public void test988() {
wantFiles("p1/One.html");
}
public void test989() {
wantFiles("p1/One.html,p1/pp1/One.html");
wantFiles("p2/Two.html,p2/pp2/Two.html");
}
public void test990() {
wantFiles("p1/One.html,p1/pp1/One.html");
wantFiles("p2/Two.html,p2/pp2/Two.html");
}
public void test991() {
wantFiles("p1/One.html,p1/pp1/One.html");
wantFiles("p2/Two.html");
}
public void test992() {
wantFiles("p1/One.html,p2/Two.html");
}
public void test993() {
wantFiles("p1/One.html,p1/pp1/One.html");
}
public void test994() {
wantFiles("p1/One.html,p1/pp1/One.html");
}
public void test995() {
wantFiles("p1/One.html");
}
public void test996() {
wantFiles("One.html,Two.html");
}
public void test997() {
wantFiles("One.html");
}
public void test998() {
wantFiles("One.html,Two.html");
}
public void test999() {
wantFiles("One.html");
}
////// End tests ////////////////////////////////////////////////
private final static int OVERVIEW_TREE_HTML = 0x000001;
private final static int INDEX_ALL_HTML = 0x000002;
private final static int DEPRECATED_LIST_HTML = 0x000004;
private final static int ALLCLASSES_FRAME_HTML = 0x000008;
private final static int INDEX_HTML = 0x000010;
private final static int PACKAGES_HTML = 0x000020;
private final static int OVERVIEW_SUMMARY_HTML = 0x000040;
private final static int PACKAGE_LIST = 0x000080;
private final static int HELP_DOC_HTML = 0x000100;
private final static int STYLESHEET_CSS = 0x000200;
private final static int ALL = 0x0003ff;
private final static int TOP = ((ALL<<1)|1)&~ALL;
private final static String[] FILES = new String[] {
"overview-tree.html",
"index-all.html",
"deprecated-list.html",
"allclasses-frame.html",
"index.html",
"packages.html",
"overview-summary.html",
"package-list",
"help-doc.html",
"stylesheet.css",
};
private void wantFiles(int mods) {
mods &= (ALL | TOP);
for (int c = 0; mods != 0x1; c++, mods >>= 0x1) {
if ((mods & 0x1) == 0x1) {
wantFiles(FILES[c]);
} else {
avoidFiles(FILES[c]);
}
}
}
private int MODS = ALL;
private void avoid(int mods) {
MODS &= ~mods;
}
/**
* Make the doc dir -- e.g. call {@link #makeDocDir}
*/
protected void beforeEveryTask() {
makeDocDir();
wantFiles(MODS);
}
/**
* Assert classes and clear doc dir.
*
* @see #checkDocs()
* @see #clearDocDir()
*/
protected void afterEveryTask() {
checkDocs();
clearDocDir();
MODS = ALL;
}
protected void avoidFiles(String filesWithoutHtmlExtensions) {
List list = new ArrayList();
for (StringTokenizer tok =
new StringTokenizer(filesWithoutHtmlExtensions, " ,;");
tok.hasMoreTokens();) {
list.add(tok.nextToken());
}
avoidFiles(list);
}
protected void avoidFiles(List filesWithoutHtmlExtensions) {
for (Iterator iter = filesWithoutHtmlExtensions.iterator(); iter.hasNext();) {
dont(iter.next()+"");
}
}
protected void wantFiles(String filesWithoutHtmlExtensions) {
List list = new ArrayList();
for (StringTokenizer tok =
new StringTokenizer(filesWithoutHtmlExtensions, " ,;");
tok.hasMoreTokens();) {
list.add(tok.nextToken());
}
wantFiles(list);
}
protected void wantFiles(List filesWithoutHtmlExtensions) {
for (Iterator iter = filesWithoutHtmlExtensions.iterator(); iter.hasNext();) {
want(iter.next()+"");
}
}
protected void checkDocs() {
for (Iterator iter = wants.iterator(); iter.hasNext();) {
String filename = iter.next() + "";
File file = new File(docDir, filename);
if (file != null && file.exists()) {
have(filename);
} else {
//System.err.println("westodo expected " + file.getPath());
}
}
for (Iterator iter = donts.iterator(); iter.hasNext();) {
String filename = iter.next() + "";
File file = new File(docDir, filename);
if (file != null && file.exists()) {
have(filename);
} else {
//System.err.println("westodo avoiding " + file.getPath());
}
}
}
/**
* Create a new doc dir.
*/
protected void init() {
docDir = new File(project.getBaseDir(), TEST_DOCDIR);
}
/**
* Make a new doc dir using ANT.
*/
protected void makeDocDir() {
try {
Mkdir mkdir = (Mkdir)project.createTask("mkdir");
mkdir.setDir(docDir);
mkdir.execute();
} catch (BuildException be) {
be.printStackTrace();
}
}
/**
* Clear the build dir using ANT.
*/
protected void clearDocDir() {
try {
Delete delete = (Delete)project.createTask("delete");
FileSet fileset = new FileSet();
fileset.setDir(docDir);
fileset.setIncludes("**");
delete.addFileset(fileset);
delete.execute();
} catch (BuildException be) {
be.printStackTrace();
}
}
/**
* Invoke {@link #runTests(String[])} on a
* new instanceof {@link #AjdocTaskTester}.
*
* @param args Command line arguments.
*/
public static void main(String[] args) {
new AjdocTaskTester().runTests(args);
}
}
|