001: /*
002: * Java HTML Tidy - JTidy
003: * HTML parser and pretty printer
004: *
005: * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
006: * Institute of Technology, Institut National de Recherche en
007: * Informatique et en Automatique, Keio University). All Rights
008: * Reserved.
009: *
010: * Contributing Author(s):
011: *
012: * Dave Raggett <dsr@w3.org>
013: * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
014: * Gary L Peskin <garyp@firstech.com> (Java development)
015: * Sami Lempinen <sami@lempinen.net> (release management)
016: * Fabrizio Giustina <fgiust at users.sourceforge.net>
017: *
018: * The contributing author(s) would like to thank all those who
019: * helped with testing, bug fixes, and patience. This wouldn't
020: * have been possible without all of you.
021: *
022: * COPYRIGHT NOTICE:
023: *
024: * This software and documentation is provided "as is," and
025: * the copyright holders and contributing author(s) make no
026: * representations or warranties, express or implied, including
027: * but not limited to, warranties of merchantability or fitness
028: * for any particular purpose or that the use of the software or
029: * documentation will not infringe any third party patents,
030: * copyrights, trademarks or other rights.
031: *
032: * The copyright holders and contributing author(s) will not be
033: * liable for any direct, indirect, special or consequential damages
034: * arising out of any use of the software or documentation, even if
035: * advised of the possibility of such damage.
036: *
037: * Permission is hereby granted to use, copy, modify, and distribute
038: * this source code, or portions hereof, documentation and executables,
039: * for any purpose, without fee, subject to the following restrictions:
040: *
041: * 1. The origin of this source code must not be misrepresented.
042: * 2. Altered versions must be plainly marked as such and must
043: * not be misrepresented as being the original source.
044: * 3. This Copyright notice may not be removed or altered from any
045: * source or altered source distribution.
046: *
047: * The copyright holders and contributing author(s) specifically
048: * permit, without fee, and encourage the use of this source code
049: * as a component for supporting the Hypertext Markup Language in
050: * commercial products. If you use this source code in a product,
051: * acknowledgment is not required but would be appreciated.
052: *
053: */
054: package org.w3c.tidy;
055:
056: import junit.framework.TestCase;
057:
058: /**
059: * Test for Report messages. <strong>This test case actually requires EN locale to run successfully. </strong>.
060: * @author fgiust
061: * @version $Revision: 1.11 $ ($Author: fgiust $)
062: */
063: public class ReportTest extends TestCase {
064:
065: /**
066: * report instance.
067: */
068: private Report report;
069:
070: /**
071: * lexer instance.
072: */
073: private Lexer lexer;
074:
075: /**
076: * instantiates a new test.
077: * @param name test name
078: */
079: public ReportTest(String name) {
080: super (name);
081: }
082:
083: /**
084: * @see junit.framework.TestCase#setUp()
085: */
086: protected void setUp() throws Exception {
087: super .setUp();
088: this .report = new Report();
089: this .lexer = new Lexer(null, new Configuration(report),
090: this .report);
091: lexer.lines = 12;
092: lexer.columns = 34;
093: }
094:
095: /**
096: * test getMessage with the <code>missing_endtag_for</code> key.
097: * @throws Exception any Exception generated during test
098: */
099: public void testGetMessageMissingEndtagFor() throws Exception {
100: String message = this .report.getMessage(-1, lexer,
101: "missing_endtag_for", new Object[] { "test" },
102: TidyMessage.Level.WARNING);
103: assertEquals("line 12 column 34 - Warning: missing </test>",
104: message);
105: }
106:
107: /**
108: * test getMessage with the <code>missing_endtag_before</code> key.
109: * @throws Exception any Exception generated during test
110: */
111: public void testGetMessageMissingEndtagBefore() throws Exception {
112: String message = this .report.getMessage(-1, lexer,
113: "missing_endtag_before",
114: new Object[] { "test", "bee" },
115: TidyMessage.Level.WARNING);
116: assertEquals(
117: "line 12 column 34 - Warning: missing </test> before bee",
118: message);
119: }
120:
121: /**
122: * test getMessage with the <code>discarding_unexpected</code> key.
123: * @throws Exception any Exception generated during test
124: */
125: public void testGetMessageDiscardingUnexpected() throws Exception {
126: String message = this .report.getMessage(-1, lexer,
127: "discarding_unexpected", new Object[] { "test" },
128: TidyMessage.Level.WARNING);
129: assertEquals(
130: "line 12 column 34 - Warning: discarding unexpected test",
131: message);
132: }
133:
134: /**
135: * test getMessage with the <code>nested_emphasis</code> key.
136: * @throws Exception any Exception generated during test
137: */
138: public void testGetMessageNestedEmphasis() throws Exception {
139: String message = this .report.getMessage(-1, lexer,
140: "nested_emphasis", new Object[] { "test" },
141: TidyMessage.Level.INFO);
142: assertEquals("line 12 column 34 - nested emphasis test",
143: message);
144: }
145:
146: /**
147: * test getMessage with the <code>coerce_to_endtag</code> key.
148: * @throws Exception any Exception generated during test
149: */
150: public void testGetMessageCoerceToEndtag() throws Exception {
151: String message = this .report.getMessage(-1, lexer,
152: "coerce_to_endtag", new Object[] { "test" },
153: TidyMessage.Level.INFO);
154: assertEquals(
155: "line 12 column 34 - <test> is probably intended as </test>",
156: message);
157: }
158:
159: /**
160: * test getMessage with the <code>non_matching_endtag</code> key.
161: * @throws Exception any Exception generated during test
162: */
163: public void testGetMessageNonMatchingEndtag() throws Exception {
164: String message = this .report.getMessage(-1, lexer,
165: "non_matching_endtag",
166: new Object[] { "<test>", "bee" },
167: TidyMessage.Level.WARNING);
168: assertEquals(
169: "line 12 column 34 - Warning: replacing unexpected <test> by </bee>",
170: message);
171: }
172:
173: /**
174: * test getMessage with the <code>tag_not_allowed_in</code> key.
175: * @throws Exception any Exception generated during test
176: */
177: public void testGetMessageTagNonAllowedIn() throws Exception {
178: String message = this .report.getMessage(-1, lexer,
179: "tag_not_allowed_in", new Object[] { "<test>", "bee" },
180: TidyMessage.Level.WARNING);
181: assertEquals(
182: "line 12 column 34 - Warning: <test> isn't allowed in <bee> elements",
183: message);
184: }
185:
186: /**
187: * test getMessage with the <code>doctype_after_tags</code> key.
188: * @throws Exception any Exception generated during test
189: */
190: public void testGetMessageDoctypeAfterTags() throws Exception {
191: String message = this .report.getMessage(-1, lexer,
192: "doctype_after_tags", null, TidyMessage.Level.WARNING);
193: assertEquals(
194: "line 12 column 34 - Warning: <!DOCTYPE> isn't allowed after elements",
195: message);
196: }
197:
198: /**
199: * test getMessage with the <code>missing_starttag</code> key.
200: * @throws Exception any Exception generated during test
201: */
202: public void testGetMessageMissingStarttag() throws Exception {
203: String message = this .report.getMessage(-1, lexer,
204: "missing_starttag", new Object[] { "test" },
205: TidyMessage.Level.WARNING);
206: assertEquals("line 12 column 34 - Warning: missing <test>",
207: message);
208: }
209:
210: /**
211: * test getMessage with the <code>using_br_inplace_of</code> key.
212: * @throws Exception any Exception generated during test
213: */
214: public void testGetMessageUsingBrInPlaceOf() throws Exception {
215: String message = this .report.getMessage(-1, lexer,
216: "using_br_inplace_of", new Object[] { "test" },
217: TidyMessage.Level.WARNING);
218: assertEquals(
219: "line 12 column 34 - Warning: using <br> in place of test",
220: message);
221: }
222:
223: /**
224: * test getMessage with the <code>inserting_tag</code> key.
225: * @throws Exception any Exception generated during test
226: */
227: public void testGetMessageInsertingTag() throws Exception {
228: String message = this .report.getMessage(-1, lexer,
229: "inserting_tag", new Object[] { "test" },
230: TidyMessage.Level.WARNING);
231: assertEquals(
232: "line 12 column 34 - Warning: inserting implicit <test>",
233: message);
234: }
235:
236: /**
237: * test getMessage with the <code>cant_be_nested</code> key.
238: * @throws Exception any Exception generated during test
239: */
240: public void testGetMessageCantBeNested() throws Exception {
241: String message = this .report.getMessage(-1, lexer,
242: "cant_be_nested", new Object[] { "<test>" },
243: TidyMessage.Level.WARNING);
244: assertEquals(
245: "line 12 column 34 - Warning: <test> can't be nested",
246: message);
247: }
248:
249: /**
250: * test getMessage with the <code>proprietary_element</code> key.
251: * @throws Exception any Exception generated during test
252: */
253: public void testGetMessageProprietaryElement() throws Exception {
254: String message = this .report.getMessage(-1, lexer,
255: "proprietary_element", new Object[] { "<test>" },
256: TidyMessage.Level.WARNING);
257: assertEquals(
258: "line 12 column 34 - Warning: <test> is not approved by W3C",
259: message);
260: }
261:
262: /**
263: * test getMessage with the <code>obsolete_element</code> key.
264: * @throws Exception any Exception generated during test
265: */
266: public void testGetMessageObsoleteElement() throws Exception {
267: String message = this .report.getMessage(-1, lexer,
268: "obsolete_element", new Object[] { "<test>", "<bee>" },
269: TidyMessage.Level.WARNING);
270: assertEquals(
271: "line 12 column 34 - Warning: replacing obsolete element <test> by <bee>",
272: message);
273: }
274:
275: /**
276: * test getMessage with the <code>replacing_element</code> key.
277: * @throws Exception any Exception generated during test
278: */
279: public void testGetMessageReplacingElement() throws Exception {
280: String message = this .report.getMessage(-1, lexer,
281: "replacing_element",
282: new Object[] { "<test>", "<bee>" },
283: TidyMessage.Level.WARNING);
284: assertEquals(
285: "line 12 column 34 - Warning: replacing element <test> by <bee>",
286: message);
287: }
288:
289: /**
290: * test getMessage with the <code>trim_empty_element</code> key.
291: * @throws Exception any Exception generated during test
292: */
293: public void testGetMessageTrimEmptyElement() throws Exception {
294: String message = this .report.getMessage(-1, lexer,
295: "trim_empty_element", new Object[] { "<test>" },
296: TidyMessage.Level.WARNING);
297: assertEquals(
298: "line 12 column 34 - Warning: trimming empty <test>",
299: message);
300: }
301:
302: /**
303: * test getMessage with the <code>missing_title_element</code> key.
304: * @throws Exception any Exception generated during test
305: */
306: public void testGetMessageMissingTitleElement() throws Exception {
307: String message = this .report.getMessage(-1, lexer,
308: "missing_title_element", null,
309: TidyMessage.Level.WARNING);
310: assertEquals(
311: "line 12 column 34 - Warning: inserting missing 'title' element",
312: message);
313: }
314:
315: /**
316: * test getMessage with the <code>illegal_nesting</code> key.
317: * @throws Exception any Exception generated during test
318: */
319: public void testGetMessageIllegalNesting() throws Exception {
320: String message = this .report.getMessage(-1, lexer,
321: "illegal_nesting", new Object[] { "<test>" },
322: TidyMessage.Level.WARNING);
323: assertEquals(
324: "line 12 column 34 - Warning: <test> shouldn't be nested",
325: message);
326: }
327:
328: /**
329: * test getMessage with the <code>noframes_content</code> key.
330: * @throws Exception any Exception generated during test
331: */
332: public void testGetMessageNoframesContent() throws Exception {
333: String message = this .report.getMessage(-1, lexer,
334: "noframes_content", new Object[] { "<test>" },
335: TidyMessage.Level.WARNING);
336: assertEquals(
337: "line 12 column 34 - Warning: <test> not inside 'noframes' element",
338: message);
339: }
340:
341: /**
342: * test getMessage with the <code>inconsistent_version</code> key.
343: * @throws Exception any Exception generated during test
344: */
345: public void testGetMessageInconsistentVersion() throws Exception {
346: String message = this .report
347: .getMessage(-1, lexer, "inconsistent_version", null,
348: TidyMessage.Level.WARNING);
349: assertEquals(
350: "line 12 column 34 - Warning: html doctype doesn't match content",
351: message);
352: }
353:
354: /**
355: * test getMessage with the <code>malformed_doctype</code> key.
356: * @throws Exception any Exception generated during test
357: */
358: public void testGetMessageMalformedDoctype() throws Exception {
359: String message = this .report.getMessage(-1, lexer,
360: "malformed_doctype", null, TidyMessage.Level.WARNING);
361: assertEquals(
362: "line 12 column 34 - Warning: expected \"html PUBLIC\" or \"html SYSTEM\"",
363: message);
364: }
365:
366: /**
367: * test getMessage with the <code>content_after_body</code> key.
368: * @throws Exception any Exception generated during test
369: */
370: public void testGetMessageContentAfterBody() throws Exception {
371: String message = this .report.getMessage(-1, lexer,
372: "content_after_body", null, TidyMessage.Level.WARNING);
373: assertEquals(
374: "line 12 column 34 - Warning: content occurs after end of body",
375: message);
376: }
377:
378: /**
379: * test getMessage with the <code>malformed_comment</code> key.
380: * @throws Exception any Exception generated during test
381: */
382: public void testGetMessageMalformedComment() throws Exception {
383: String message = this .report.getMessage(-1, lexer,
384: "malformed_comment", null, TidyMessage.Level.WARNING);
385: assertEquals(
386: "line 12 column 34 - Warning: adjacent hyphens within comment",
387: message);
388: }
389:
390: /**
391: * test getMessage with the <code>bad_comment_chars</code> key.
392: * @throws Exception any Exception generated during test
393: */
394: public void testGetMessageBadCommentChars() throws Exception {
395: String message = this .report.getMessage(-1, lexer,
396: "bad_comment_chars", null, TidyMessage.Level.WARNING);
397: assertEquals("line 12 column 34 - Warning: expecting -- or >",
398: message);
399: }
400:
401: /**
402: * test getMessage with the <code>bad_xml_comment</code> key.
403: * @throws Exception any Exception generated during test
404: */
405: public void testGetMessageBadXmlComment() throws Exception {
406: String message = this .report.getMessage(-1, lexer,
407: "bad_xml_comment", null, TidyMessage.Level.WARNING);
408: assertEquals(
409: "line 12 column 34 - Warning: XML comments can't contain --",
410: message);
411: }
412:
413: /**
414: * test getMessage with the <code>bad_cdata_content</code> key.
415: * @throws Exception any Exception generated during test
416: */
417: public void testGetMessageBadCdataComment() throws Exception {
418: String message = this .report.getMessage(-1, lexer,
419: "bad_cdata_content", null, TidyMessage.Level.WARNING);
420: assertEquals(
421: "line 12 column 34 - Warning: '<' + '/' + letter not allowed here",
422: message);
423: }
424:
425: /**
426: * test getMessage with the <code>inconsistent_namespace</code> key.
427: * @throws Exception any Exception generated during test
428: */
429: public void testGetMessageInconsistentNamespace() throws Exception {
430: String message = this .report.getMessage(-1, lexer,
431: "inconsistent_namespace", null,
432: TidyMessage.Level.WARNING);
433: assertEquals(
434: "line 12 column 34 - Warning: html namespace doesn't match content",
435: message);
436: }
437:
438: /**
439: * test getMessage with the <code>dtype_not_upper_case</code> key.
440: * @throws Exception any Exception generated during test
441: */
442: public void testGetMessageDtypeNotUpperCase() throws Exception {
443: String message = this .report
444: .getMessage(-1, lexer, "dtype_not_upper_case", null,
445: TidyMessage.Level.WARNING);
446: assertEquals(
447: "line 12 column 34 - Warning: SYSTEM, PUBLIC, W3C, DTD, EN must be upper case",
448: message);
449: }
450:
451: /**
452: * test getMessage with the <code>unexpected_end_of_file</code> key.
453: * @throws Exception any Exception generated during test
454: */
455: public void testGetMessageUnexpectedEndOfFile() throws Exception {
456: String message = this .report.getMessage(-1, lexer,
457: "unexpected_end_of_file", new Object[] { "<test>" },
458: TidyMessage.Level.WARNING);
459: assertEquals(
460: "line 12 column 34 - Warning: end of file while parsing attributes <test>",
461: message);
462: }
463:
464: /**
465: * test getMessage with the <code>suspected_missing_quote</code> key.
466: * @throws Exception any Exception generated during test
467: */
468: public void testGetMessageSuspectedMissingQuote() throws Exception {
469: String message = this .report.getMessage(-1, lexer,
470: "suspected_missing_quote", null,
471: TidyMessage.Level.ERROR);
472: assertEquals(
473: "line 12 column 34 - Error: missing quotemark for attribute value",
474: message);
475: }
476:
477: /**
478: * test getMessage with the <code>duplicate_frameset</code> key.
479: * @throws Exception any Exception generated during test
480: */
481: public void testGetMessageDuplicateFrameset() throws Exception {
482: String message = this .report.getMessage(-1, lexer,
483: "duplicate_frameset", null, TidyMessage.Level.ERROR);
484: assertEquals(
485: "line 12 column 34 - Error: repeated FRAMESET element",
486: message);
487: }
488:
489: /**
490: * test getMessage with the <code>unknown_element</code> key.
491: * @throws Exception any Exception generated during test
492: */
493: public void testGetMessageUnknownElement() throws Exception {
494: String message = this .report.getMessage(-1, lexer,
495: "unknown_element", new Object[] { "<test>" },
496: TidyMessage.Level.ERROR);
497: assertEquals(
498: "line 12 column 34 - Error: <test> is not recognized!",
499: message);
500: }
501:
502: /**
503: * test getMessage with the <code>unexpected_endtag</code> key.
504: * @throws Exception any Exception generated during test
505: */
506: public void testGetMessageUnexpectedEndtag() throws Exception {
507: String message = this .report.getMessage(-1, lexer,
508: "unexpected_endtag", new Object[] { "test" },
509: TidyMessage.Level.ERROR);
510: assertEquals("line 12 column 34 - Error: unexpected </test>",
511: message);
512: }
513:
514: /**
515: * test getMessage with the <code>unexpected_endtag_in</code> key.
516: * @throws Exception any Exception generated during test
517: */
518: public void testGetMessageUnexpectedEndtagIn() throws Exception {
519: String message = this .report.getMessage(-1, lexer,
520: "unexpected_endtag_in", new Object[] { "test", "bee" },
521: TidyMessage.Level.ERROR);
522: assertEquals(
523: "line 12 column 34 - Error: unexpected </test> in <bee>",
524: message);
525: }
526:
527: /**
528: * test getMessage with the <code>too_many_elements</code> key.
529: * @throws Exception any Exception generated during test
530: */
531: public void testGetMessageTooManyElements() throws Exception {
532: String message = this .report.getMessage(-1, lexer,
533: "too_many_elements", new Object[] { "<test>" },
534: TidyMessage.Level.WARNING);
535: assertEquals(
536: "line 12 column 34 - Warning: too many <test> elements",
537: message);
538: }
539:
540: /**
541: * test getMessage with the <code>too_many_elements_in</code> key.
542: * @throws Exception any Exception generated during test
543: */
544: public void testGetMessageTooManyElementsIn() throws Exception {
545: String message = this .report.getMessage(-1, lexer,
546: "too_many_elements_in",
547: new Object[] { "<test>", "bee" },
548: TidyMessage.Level.WARNING);
549: assertEquals(
550: "line 12 column 34 - Warning: too many <test> elements in <bee>",
551: message);
552: }
553:
554: /**
555: * test getMessage with the <code>unknown_attribute</code> key.
556: * @throws Exception any Exception generated during test
557: */
558: public void testGetMessageUnknownAttribute() throws Exception {
559: String message = this .report.getMessage(-1, lexer,
560: "unknown_attribute", new Object[] { "test" },
561: TidyMessage.Level.WARNING);
562: assertEquals(
563: "line 12 column 34 - Warning: unknown attribute \"test\"",
564: message);
565: }
566:
567: /**
568: * test getMessage with the <code>missing_attribute</code> key.
569: * @throws Exception any Exception generated during test
570: */
571: public void testGetMessageMissingAttribute() throws Exception {
572: String message = this .report.getMessage(-1, lexer,
573: "missing_attribute", new Object[] { "<test>", "bee" },
574: TidyMessage.Level.WARNING);
575: assertEquals(
576: "line 12 column 34 - Warning: <test> lacks \"bee\" attribute",
577: message);
578: }
579:
580: /**
581: * test getMessage with the <code>missing_attr_value</code> key.
582: * @throws Exception any Exception generated during test
583: */
584: public void testGetMessageMissingAttrValue() throws Exception {
585: String message = this .report.getMessage(-1, lexer,
586: "missing_attr_value", new Object[] { "<test>", "bee" },
587: TidyMessage.Level.WARNING);
588: assertEquals(
589: "line 12 column 34 - Warning: <test> attribute \"bee\" lacks value",
590: message);
591: }
592:
593: /**
594: * test getMessage with the <code>missing_imagemap</code> key.
595: * @throws Exception any Exception generated during test
596: */
597: public void testGetMessageMissingImagemap() throws Exception {
598: String message = this .report.getMessage(-1, lexer,
599: "missing_imagemap", new Object[] { "<test>" },
600: TidyMessage.Level.WARNING);
601: assertEquals(
602: "line 12 column 34 - Warning: <test> should use client-side image map",
603: message);
604: }
605:
606: /**
607: * test getMessage with the <code>bad_attribute_value</code> key.
608: * @throws Exception any Exception generated during test
609: */
610: public void testGetMessageBadAttributeValue() throws Exception {
611: String message = this .report.getMessage(-1, lexer,
612: "bad_attribute_value", new Object[] { "<test>", "bee",
613: "ant" }, TidyMessage.Level.WARNING);
614: assertEquals(
615: "line 12 column 34 - Warning: <test> attribute \"bee\" has invalid value \"ant\"",
616: message);
617: }
618:
619: /**
620: * test getMessage with the <code>xml_attribute_value</code> key.
621: * @throws Exception any Exception generated during test
622: */
623: public void testGetMessageXmlAttributeValue() throws Exception {
624: String message = this .report.getMessage(-1, lexer,
625: "xml_attribute_value",
626: new Object[] { "<test>", "bee" },
627: TidyMessage.Level.WARNING);
628: assertEquals(
629: "line 12 column 34 - Warning: <test> has XML attribute \"bee\"",
630: message);
631: }
632:
633: /**
634: * test getMessage with the <code>unexpected_gt</code> key.
635: * @throws Exception any Exception generated during test
636: */
637: public void testGetMessageUnexpectedGt() throws Exception {
638: String message = this .report.getMessage(-1, lexer,
639: "unexpected_gt", new Object[] { "<test>" },
640: TidyMessage.Level.ERROR);
641: assertEquals(
642: "line 12 column 34 - Error: <test> missing '>' for end of tag",
643: message);
644: }
645:
646: /**
647: * test getMessage with the <code>unexpected_quotemark</code> key.
648: * @throws Exception any Exception generated during test
649: */
650: public void testGetMessageUnexpectedQuotemark() throws Exception {
651: String message = this .report.getMessage(-1, lexer,
652: "unexpected_quotemark", new Object[] { "<test>" },
653: TidyMessage.Level.WARNING);
654: assertEquals(
655: "line 12 column 34 - Warning: <test> unexpected or duplicate quote mark",
656: message);
657: }
658:
659: /**
660: * test getMessage with the <code>repeated_attribute</code> key.
661: * @throws Exception any Exception generated during test
662: */
663: public void testGetMessageRepeatedAttribute() throws Exception {
664: String message = this .report.getMessage(-1, lexer,
665: "repeated_attribute", new Object[] { "<test>", "bee",
666: "ant" }, TidyMessage.Level.WARNING);
667: assertEquals(
668: "line 12 column 34 - Warning: <test> dropping value \"bee\" for repeated attribute \"ant\"",
669: message);
670: }
671:
672: /**
673: * test getMessage with the <code>proprietary_attr_value</code> key.
674: * @throws Exception any Exception generated during test
675: */
676: public void testGetMessageProprietaryAttrValue() throws Exception {
677: String message = this .report.getMessage(-1, lexer,
678: "proprietary_attr_value", new Object[] { "<test>",
679: "bee" }, TidyMessage.Level.WARNING);
680: assertEquals(
681: "line 12 column 34 - Warning: <test> proprietary attribute value \"bee\"",
682: message);
683: }
684:
685: /**
686: * test getMessage with the <code>proprietary_attribute</code> key.
687: * @throws Exception any Exception generated during test
688: */
689: public void testGetMessageProprietaryAttribute() throws Exception {
690: String message = this .report.getMessage(-1, lexer,
691: "proprietary_attribute",
692: new Object[] { "<test>", "bee" },
693: TidyMessage.Level.WARNING);
694: assertEquals(
695: "line 12 column 34 - Warning: <test> proprietary attribute \"bee\"",
696: message);
697: }
698:
699: /**
700: * test getMessage with the <code>id_name_mismatch</code> key.
701: * @throws Exception any Exception generated during test
702: */
703: public void testGetMessageIdNameMismatch() throws Exception {
704: String message = this .report.getMessage(-1, lexer,
705: "id_name_mismatch", new Object[] { "<test>" },
706: TidyMessage.Level.WARNING);
707: assertEquals(
708: "line 12 column 34 - Warning: <test> id and name attribute value mismatch",
709: message);
710: }
711:
712: /**
713: * test getMessage with the <code>missing_doctype</code> key.
714: * @throws Exception any Exception generated during test
715: */
716: public void testGetMessageMissingDoctype() throws Exception {
717: String message = this .report.getMessage(-1, lexer,
718: "missing_doctype", null, TidyMessage.Level.WARNING);
719: assertEquals(
720: "line 12 column 34 - Warning: missing <!DOCTYPE> declaration",
721: message);
722: }
723:
724: /**
725: * test getMessage with the <code>doctype_given</code> key.
726: * @throws Exception any Exception generated during test
727: */
728: public void testGetMessageDoctypeGiven() throws Exception {
729: String message = this .report.getMessage(-1, lexer,
730: "doctype_given", new Object[] { "test", "bee" },
731: TidyMessage.Level.SUMMARY);
732: assertEquals("test: Doctype given is \"bee\"", message);
733: }
734:
735: /**
736: * test getMessage with the <code>report_version</code> key.
737: * @throws Exception any Exception generated during test
738: */
739: public void testGetMessageReportVersion() throws Exception {
740: String message = this .report.getMessage(-1, lexer,
741: "report_version", new Object[] { "test", "bee" },
742: TidyMessage.Level.SUMMARY);
743: assertEquals("test: Document content looks like bee", message);
744: }
745:
746: /**
747: * test getMessage with the <code>xml_attribute_value</code> key.
748: * @throws Exception any Exception generated during test
749: */
750: public void testGetMessageNumWarning() throws Exception {
751: String message = this .report.getMessage(-1, lexer,
752: "num_warnings", new Object[] { new Integer(0),
753: new Integer(33) }, TidyMessage.Level.SUMMARY);
754: assertEquals("no warnings, 33 errors were found!", message);
755: }
756:
757: }
|