KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > tidy > TidyWarningBugsTest


1 /*
2  * Java HTML Tidy - JTidy
3  * HTML parser and pretty printer
4  *
5  * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
6  * Institute of Technology, Institut National de Recherche en
7  * Informatique et en Automatique, Keio University). All Rights
8  * Reserved.
9  *
10  * Contributing Author(s):
11  *
12  * Dave Raggett <dsr@w3.org>
13  * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
14  * Gary L Peskin <garyp@firstech.com> (Java development)
15  * Sami Lempinen <sami@lempinen.net> (release management)
16  * Fabrizio Giustina <fgiust at users.sourceforge.net>
17  *
18  * The contributing author(s) would like to thank all those who
19  * helped with testing, bug fixes, and patience. This wouldn't
20  * have been possible without all of you.
21  *
22  * COPYRIGHT NOTICE:
23  *
24  * This software and documentation is provided "as is," and
25  * the copyright holders and contributing author(s) make no
26  * representations or warranties, express or implied, including
27  * but not limited to, warranties of merchantability or fitness
28  * for any particular purpose or that the use of the software or
29  * documentation will not infringe any third party patents,
30  * copyrights, trademarks or other rights.
31  *
32  * The copyright holders and contributing author(s) will not be
33  * liable for any direct, indirect, special or consequential damages
34  * arising out of any use of the software or documentation, even if
35  * advised of the possibility of such damage.
36  *
37  * Permission is hereby granted to use, copy, modify, and distribute
38  * this source code, or portions hereof, documentation and executables,
39  * for any purpose, without fee, subject to the following restrictions:
40  *
41  * 1. The origin of this source code must not be misrepresented.
42  * 2. Altered versions must be plainly marked as such and must
43  * not be misrepresented as being the original source.
44  * 3. This Copyright notice may not be removed or altered from any
45  * source or altered source distribution.
46  *
47  * The copyright holders and contributing author(s) specifically
48  * permit, without fee, and encourage the use of this source code
49  * as a component for supporting the Hypertext Markup Language in
50  * commercial products. If you use this source code in a product,
51  * acknowledgment is not required but would be appreciated.
52  *
53  */

54 package org.w3c.tidy;
55
56 /**
57  * Testcase for Tidy resolved bugs (Tidy warning and errors).
58  * <p>
59  * see <code>http://sourceforge.net/support/tracker.php?aid=(item number)</code>
60  * </p>
61  * @author fgiust
62  * @version $Revision: 1.16 $ ($Author: fgiust $)
63  */

64 public class TidyWarningBugsTest extends TidyTestCase
65 {
66
67     /**
68      * Instantiate a new Test case.
69      * @param name test name
70      */

71     public TidyWarningBugsTest(String JavaDoc name)
72     {
73         super(name);
74     }
75
76     /**
77      * test for Tidy [427810] : Proprietary elements not reported as err.
78      * @throws Exception any exception generated during the test
79      */

80     public void test427810() throws Exception JavaDoc
81     {
82         // line 1 column 1 - Warning: missing <!DOCTYPE> declaration
83
// line 8 column 1 - Warning: <blink> is not approved by W3C
84
// line 9 column 1 - Warning: <wbr> is not approved by W3C
85
// line 10 column 1 - Warning: <nobr> is not approved by W3C
86
// Info: Document content looks like HTML Proprietary
87
// 4 warnings, 0 errors were found!
88

89         executeTidyTest("427810.html");
90         assertWarnings(4);
91     }
92
93     /**
94      * test for Tidy [431874] : Nested anchors not detected.
95      * @throws Exception any exception generated during the test
96      */

97     public void test431874() throws Exception JavaDoc
98     {
99         executeTidyTest("431874.html");
100         assertWarnings(2);
101     }
102
103     /**
104      * test for Tidy [427827] : Nested anchor elements allowed.
105      * @throws Exception any exception generated during the test
106      */

107     public void test427827() throws Exception JavaDoc
108     {
109         // line 6 column 1 - Warning: missing </a> before <a>
110
// line 7 column 6 - Warning: discarding unexpected </a>
111
// 2 warnings, 0 errors were found!
112

113         executeTidyTest("427827.html");
114         assertWarnings(2);
115     }
116
117     /**
118      * test for Tidy [427834] : Warning given for newline in DOCTYPE.
119      * @throws Exception any exception generated during the test
120      */

121     public void test427834() throws Exception JavaDoc
122     {
123         // no warnings
124
executeTidyTest("427834.html");
125         assertNoWarnings();
126     }
127
128     /**
129      * test for Tidy [427844] : End tags containing whitespace warning.
130      * @throws Exception any exception generated during the test
131      */

132     public void test427844() throws Exception JavaDoc
133     {
134         executeTidyTest("427844.html");
135
136         assertNoWarnings();
137     }
138
139     /**
140      * test for Tidy [431719] : Spec want "HTML 3.2 Final", but everyone in the world, including Tidy, uses "HTML 3.2".
141      * So the software has to recognize both FPI's as equivalent.
142      * @throws Exception any exception generated during the test
143      */

144     public void test431719() throws Exception JavaDoc
145     {
146         // line 11 column 3 - Warning: <table> lacks "summary" attribute
147
// Info: Doctype given is "-//W3C//DTD HTML 3.2//EN"
148
// Info: Document content looks like HTML 3.2
149
// 1 warning, 0 errors were found!
150

151         // still bad in tidy?
152

153         executeTidyTest("431719.html");
154         assertNoWarnings();
155     }
156
157     /**
158      * test for Tidy [431883] : Given doctype reported incorrectly.
159      * @throws Exception any exception generated during the test
160      */

161     public void test431883() throws Exception JavaDoc
162     {
163         executeTidyTest("431883.html");
164
165         assertLogContains("Doctype given is \"-//W3C//DTD HTML 4.0");
166     }
167
168     /**
169      * test for Tidy [431956] : Well formed XSL xsl:text gives error.
170      * @throws Exception any exception generated during the test
171      */

172     public void test431956() throws Exception JavaDoc
173     {
174         // No warnings or errors were found. (-xml)
175

176         executeTidyTest("431956.xml");
177         assertNoWarnings();
178     }
179
180     /**
181      * test for Tidy [431964] : table height="" not flagged as error.
182      * @throws Exception any exception generated during the test
183      */

184     public void test431964() throws Exception JavaDoc
185     {
186         // line 7 column 1 - Warning: <table> attribute "height" lacks value
187
// line 7 column 1 - Warning: <table> proprietary attribute "height"
188
// Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
189
// Info: Document content looks like HTML Proprietary
190
// 2 warnings, 0 errors were found!
191

192         executeTidyTest("431964.html");
193         assertWarnings(2);
194     }
195
196     /**
197      * test for Tidy [433021] : Identify attribute whose value is bad.
198      * @throws Exception any exception generated during the test
199      */

200     public void test433021() throws Exception JavaDoc
201     {
202         executeTidyTest("433021.html");
203         assertLogContains("align");
204         assertLogContains("valign");
205         assertWarnings(5);
206     }
207
208     /**
209      * test for Tidy [433607] : No warning for omitted end tag with -xml.
210      * @throws Exception any exception generated during the test
211      */

212     public void test433607() throws Exception JavaDoc
213     {
214         // No warnings or errors were found. (-xml)
215

216         // still bad in tidy?
217
executeTidyTest("433607.xml");
218
219         assertWarnings(1);
220     }
221
222     /**
223      * test for Tidy [433670] : &amp;apos not recognized as valid XML entity.
224      * @throws Exception any exception generated during the test
225      */

226     public void test433670() throws Exception JavaDoc
227     {
228         // No warnings or errors were found. (-xml)
229
executeTidyTest("433670.xml");
230         assertNoWarnings();
231     }
232
233     /**
234      * test for Tidy [434047] : Mixed content in 4.01 Strict not allowed.
235      * @throws Exception any exception generated during the test
236      */

237     public void test434047() throws Exception JavaDoc
238     {
239         // Info: Doctype given is "-//W3C//DTD HTML 4.01//EN"
240
// Info: Document content looks like HTML 4.01 Strict
241
// No warnings or errors were found.
242

243         executeTidyTest("434047.html");
244
245         assertLogContains("HTML 4.01 Strict");
246
247     }
248
249     /**
250      * test for Tidy [434100] : Error actually reported as a warning (-xml).
251      * @throws Exception any exception generated during the test
252      */

253     public void test434100() throws Exception JavaDoc
254     {
255         // -xml
256
// line 13 column 1 - Error: unexpected </head> in <link>
257
// 0 warnings, 1 error were found!
258

259         executeTidyTest("434100.html");
260         assertErrors(1);
261         assertNoWarnings();
262     }
263
264     /**
265      * test for Tidy [435917] : &lt;input onfocus=""&gt; reported unknown attr.
266      * @throws Exception any exception generated during the test
267      */

268     public void test435917() throws Exception JavaDoc
269     {
270         // should not report: invalid attribute "onfocus"
271

272         executeTidyTest("435917.html");
273         assertWarnings(1);
274     }
275
276     /**
277      * test for Tidy [435917] : missing "=" in attribute confuses tidy.
278      * @throws Exception any exception generated during the test
279      */

280     public void test435917b() throws Exception JavaDoc
281     {
282         // line 11 column 1 - Warning: <input> attribute with missing trailing quote mark
283

284         // should not report:
285
// line 11 column 2 - Warning: <input> unknown attribute value "null"
286

287         executeTidyTest("435917.html");
288         assertLogDoesntContains("null");
289     }
290
291     /**
292      * test for Tidy [435922] : Missing &lt;form&gt; around &lt;input&gt; no warning.
293      * @throws Exception any exception generated during the test
294      */

295     public void test435922() throws Exception JavaDoc
296     {
297         // line 6 column 1 - Warning: <input> isn't allowed in <body> elements
298
// line 7 column 3 - Warning: inserting implicit <form>
299
// line 7 column 3 - Warning: missing </form>
300
// line 7 column 3 - Warning: <form> lacks "action" attribute
301
// Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
302
// Info: Document content looks like HTML 4.01 Transitional
303
// 4 warnings, 0 errors were found!
304

305         executeTidyTest("435922.html");
306         assertWarnings(4);
307     }
308
309     /**
310      * test for Tidy [438956] : Bad head-endtag reported incorrectly.
311      * @throws Exception any exception generated during the test
312      */

313     public void test438956() throws Exception JavaDoc
314     {
315         // line 3 column 1 - Warning: plain text isn't allowed in <head> elements
316
// line 6 column 1 - Warning: discarding unexpected <body>
317
// Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
318
// Info: Document content looks like HTML 4.01 Transitional
319
// 2 warnings, 0 errors were found!
320

321         executeTidyTest("438956.html");
322
323         assertWarnings(2);
324     }
325
326     /**
327      * test for Tidy [446019] : &lt;img name="foo"&gt; allowed in XTHML-Strict.
328      * @throws Exception any exception generated during the test
329      */

330     public void test446019() throws Exception JavaDoc
331     {
332         // Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
333
// Info: Document content looks like XHTML 1.0 Transitional
334
// No warnings or errors were found.
335

336         executeTidyTest("446019.xhtml");
337
338         assertLogContains("XHTML 1.0 Transitional");
339     }
340
341     /**
342      * test for Tidy [450389] : Color attval check allows only black/#.
343      * @throws Exception any exception generated during the test
344      */

345     public void test450389() throws Exception JavaDoc
346     {
347         // line 1 column 1 - Warning: missing <!DOCTYPE> declaration
348
// line 44 column 1 - Warning: <font> attribute "color" has invalid value "reddish"
349
// line 72 column 1 - Warning: <font> attribute "color" has invalid value "#FF"
350
// line 76 column 1 - Warning: <font> attribute "color" has invalid value "grurple"
351
// line 77 column 1 - Warning: <font> attribute "color" has invalid value "#grurple"
352
// line 78 column 1 - Warning: <font> attribute "color" has invalid value "#1234567"
353
// Info: Document content looks like HTML 3.2
354

355         executeTidyTest("450389.html");
356         assertWarnings(6);
357     }
358
359     /**
360      * test for Tidy [501230] : "0" (Zero) has to be lower case.
361      * @throws Exception any exception generated during the test
362      */

363     public void test501230() throws Exception JavaDoc
364     {
365         executeTidyTest("501230.xhtml");
366         assertLogDoesntContains("lower case");
367     }
368
369     /**
370      * test for Tidy [501669] : width="n*" marked invalid on &lt;COL&gt;.
371      * @throws Exception any exception generated during the test
372      */

373     public void test501669() throws Exception JavaDoc
374     {
375         // Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
376
// Info: Document content looks like HTML 4.01 Strict
377
// No warnings or errors were found.
378

379         executeTidyTest("501669.html");
380
381         assertNoWarnings();
382     }
383
384     /**
385      * test for Tidy [516370] : Invalid ID value.
386      * @throws Exception any exception generated during the test
387      */

388     public void test516370() throws Exception JavaDoc
389     {
390         // line 10 column 1 - Warning: <h2> ID "_ValidID2" uses XML ID syntax
391
// line 11 column 1 - Warning: <h2> ID ":ValidID3" uses XML ID syntax
392
// line 13 column 1 - Warning: <h2> attribute "id" has invalid value ".InvalidID1"
393
// line 14 column 1 - Warning: <h2> attribute "id" has invalid value "2InvalidID2"
394
// line 15 column 1 - Warning: <h2> attribute "id" lacks value
395

396         executeTidyTest("516370.xhtml");
397         assertWarnings(5);
398         assertLogContains("XML ID syntax");
399     }
400
401     /**
402      * test for Tidy [517528] : Parser complains about xml:lang.
403      * @throws Exception any exception generated during the test
404      */

405     public void test517528() throws Exception JavaDoc
406     {
407         executeTidyTest("517528.html");
408
409         assertNoWarnings();
410     }
411
412     /**
413      * test for Tidy [525081] : frameset rows attr. not recognized.
414      * @throws Exception any exception generated during the test
415      */

416     public void test525081() throws Exception JavaDoc
417     {
418         // Info: Doctype given is "-//W3C//DTD HTML 4.01 Frameset//EN"
419
// Info: Document content looks like HTML 4.01 Frameset
420
// No warnings or errors were found.
421

422         executeTidyTest("525081.html");
423         assertNoWarnings();
424     }
425
426     /**
427      * test for Tidy [538536] : Extra endtags not detected.
428      * @throws Exception any exception generated during the test
429      */

430     public void test538536() throws Exception JavaDoc
431     {
432         // line 5 column 1 - Warning: content occurs after end of body
433
// line 9 column 1 - Warning: discarding unexpected </html>
434
// Info: Doctype given is "-//W3C//DTD HTML 4.01//EN"
435
// Info: Document content looks like HTML 4.01 Strict
436
// 2 warnings, 0 errors were found!
437

438         executeTidyTest("538536.html");
439         assertNoErrors();
440         assertWarnings(2);
441     }
442
443     /**
444      * test for Tidy [545067] : Implicit closing of head broken.
445      * @throws Exception any exception generated during the test
446      */

447     public void test545067() throws Exception JavaDoc
448     {
449         // should NOT output:
450
// line 3 column 1 - Warning: <p> isn't allowed in <head> elements
451
// since body tags implicitly terminate the <head> section
452

453         // ok in jtidy r7
454

455         executeTidyTest("545067.html");
456         assertLogDoesntContains("<head>");
457     }
458
459     /**
460      * test for Tidy [552861] : &lt;td with=""> not recognized.
461      * @throws Exception any exception generated during the test
462      */

463     public void test552861() throws Exception JavaDoc
464     {
465         executeTidyTest("552861.html");
466         // should complain about invalid "with" attribute
467
assertWarnings(1);
468     }
469
470     /**
471      * test for Tidy [553414] : XHTML strict accept '_target' attribute.
472      * @throws Exception any exception generated during the test
473      */

474     public void test553414() throws Exception JavaDoc
475     {
476         executeTidyTest("553414.html");
477         assertLogContains("given is \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
478         assertLogContains("looks like XHTML 1.0 Transitional");
479         assertWarnings(1);
480     }
481
482     /**
483      * test for Tidy [553468] : Doesn't warn about &lt;u&gt; in XHTML strict.
484      * @throws Exception any exception generated during the test
485      */

486     public void test553468() throws Exception JavaDoc
487     {
488
489         // Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
490
// Info: Document content looks like XHTML 1.0 Transitional
491
// No warnings or errors were found.
492

493         executeTidyTest("553468.xhtml");
494
495         assertLogContains("XHTML 1.0 Transitional");
496     }
497
498     /**
499      * test for Tidy [559774] : tidy version rejects all id values.
500      * @throws Exception any exception generated during the test
501      */

502     public void test559774() throws Exception JavaDoc
503     {
504         executeTidyTest("559774.html");
505         assertNoWarnings();
506     }
507
508     /**
509      * test for Tidy [706260] : size not accepted for input.
510      * @throws Exception any exception generated during the test
511      */

512     public void test706260() throws Exception JavaDoc
513     {
514         // Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
515
// Info: Document content looks like XHTML 1.0 Transitional
516
// No warnings or errors were found.
517

518         executeTidyTest("706260.html");
519         assertNoWarnings();
520     }
521
522 }
Popular Tags