View Javadoc

1   package org.apache.maven.doxia.sink;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.CharArrayWriter;
23  import java.io.IOException;
24  import java.io.Writer;
25  
26  import org.apache.maven.doxia.AbstractModuleTest;
27  import org.apache.maven.doxia.logging.PlexusLoggerWrapper;
28  import org.codehaus.plexus.util.IOUtil;
29  
30  /**
31   * Abstract base class to test sinks.
32   *
33   * @version $Id: AbstractSinkTest.java 1467294 2013-04-12 14:51:42Z rfscholte $
34   * @since 1.0
35   */
36  public abstract class AbstractSinkTest
37      extends AbstractModuleTest
38  {
39      private final CharArrayWriter testWriter = new CharArrayWriter();
40      private Sink sink;
41  
42      /**
43       * Resets the writer and creates a new sink with it.
44       *
45       * {@inheritDoc}
46       *
47       * @throws java.lang.Exception if something goes wrong.
48       */
49      @Override
50      protected void setUp()
51          throws Exception
52      {
53          super.setUp();
54  
55          testWriter.reset();
56          sink = createSink( testWriter );
57          sink.enableLogging( new PlexusLoggerWrapper( getContainer().getLogger() ) );
58      }
59  
60      // ---------------------------------------------------------------------
61      // Common test cases
62      // ----------------------------------------------------------------------
63  
64      /**
65       * Tests that the current sink is able to render the common test document. If the sink is an Xml sink defined
66       * by {@link #isXmlSink()}, it uses an Xml Writer defined by {@link #getXmlTestWriter(String)}. If not, it uses
67       * the Writer defined by {@link #getTestWriter(String)}.
68       *
69       * @see SinkTestDocument
70       * @throws IOException If the target test document could not be generated.
71       * @see #isXmlSink()
72       * @see #getTestWriter(String)
73       * @see #getXmlTestWriter(String)
74       */
75      public final void testTestDocument() throws IOException
76      {
77          Writer writer = ( isXmlSink() ? getXmlTestWriter( "testDocument" ) : getTestWriter( "testDocument" ) );
78          Sink testSink = createSink( writer );
79  
80          try
81          {
82              SinkTestDocument.generate( testSink );
83          }
84          finally
85          {
86              testSink.close();
87              IOUtil.close( writer );
88          }
89      }
90  
91      /**
92       * Checks that the sequence <code>[title(), text( title ), title_()]</code>,
93       * invoked on the current sink, produces the same result as
94       * {@link #getTitleBlock getTitleBlock}( title ).
95       */
96      public void testTitle()
97      {
98          String title = "Grodek";
99          sink.title();
100         sink.text( title );
101         sink.title_();
102         sink.flush();
103         sink.close();
104 
105         String actual = testWriter.toString();
106         String expected = getTitleBlock( title );
107 
108         assertEquals( "Wrong title!", expected, actual );
109     }
110 
111     /**
112      * Checks that the sequence <code>[author(), text( author ), author_()]
113      * </code>, invoked on the current sink, produces the same result as
114      * {@link #getAuthorBlock getAuthorBlock}( author ).
115      */
116     public void testAuthor()
117     {
118         String author = "Georg_Trakl";
119         sink.author();
120         sink.text( author );
121         sink.author_();
122         sink.flush();
123         sink.close();
124 
125         String actual = testWriter.toString();
126         String expected = getAuthorBlock( author );
127 
128         assertEquals( "Wrong author!", expected, actual );
129     }
130 
131     /**
132      * Checks that the sequence <code>[date(), text( date ), date_()]</code>,
133      * invoked on the current sink, produces the same result as
134      * {@link #getDateBlock getDateBlock}( date ).
135      */
136     public void testDate()
137     {
138         String date = "1914";
139         sink.date();
140         sink.text( date );
141         sink.date_();
142         sink.flush();
143         sink.close();
144 
145         String actual = testWriter.toString();
146         String expected = getDateBlock( date );
147 
148         assertEquals( "Wrong date!", expected, actual );
149     }
150 
151     /**
152      * Checks that the sequence <code>[head(), head_()]</code>,
153      * invoked on the current sink, produces the same result as
154      * {@link #getHeadBlock getHeadBlock()}.
155      */
156     public void testHead()
157     {
158         sink.head();
159         sink.head_();
160         sink.flush();
161         sink.close();
162 
163         String actual = testWriter.toString();
164         String expected = getHeadBlock();
165 
166         assertEquals( "Wrong head!", expected, actual );
167     }
168 
169     /**
170      * Checks that the sequence <code>[body(), body_()]</code>,
171      * invoked on the current sink, produces the same result as
172      * {@link #getBodyBlock getBodyBlock()}.
173      */
174     public void testBody()
175     {
176         sink.body();
177         sink.body_();
178         sink.flush();
179         sink.close();
180 
181         String actual = testWriter.toString();
182         String expected = getBodyBlock();
183 
184         assertEquals( "Wrong body!", expected, actual );
185     }
186 
187     /**
188      * Checks that the sequence <code>[sectionTitle(), text( title ),
189      * sectionTitle_()]</code>, invoked on the current sink, produces
190      * the same result as
191      * {@link #getSectionTitleBlock getSectionTitleBlock}( title ).
192      */
193     public void testSectionTitle()
194     {
195         String title = "Title";
196         sink.sectionTitle();
197         sink.text( title );
198         sink.sectionTitle_();
199         sink.flush();
200         sink.close();
201 
202         String actual = testWriter.toString();
203         String expected = getSectionTitleBlock( title );
204 
205         assertEquals( "Wrong sectionTitle!", expected, actual );
206     }
207 
208     /**
209      * Checks that the sequence <code>[section1(), sectionTitle1(),
210      * text( title ), sectionTitle1_(), section1_()]</code>,
211      * invoked on the current sink, produces the same result as
212      * {@link #getSection1Block getSection1Block}( title ).
213      */
214     public void testSection1()
215     {
216         String title = "Title1";
217         sink.section1();
218         sink.sectionTitle1();
219         sink.text( title );
220         sink.sectionTitle1_();
221         sink.section1_();
222         sink.flush();
223         sink.close();
224 
225         String actual = testWriter.toString();
226         String expected = getSection1Block( title );
227 
228         assertEquals( "Wrong section1 block!", expected, actual );
229     }
230 
231     /**
232      * Checks that the sequence <code>[section2(), sectionTitle2(),
233      * text( title ), sectionTitle2_(), section2_()]</code>,
234      * invoked on the current sink, produces the same result as
235      * {@link #getSection2Block getSection2Block}( title ).
236      */
237     public void testSection2()
238     {
239         String title = "Title2";
240         sink.section2();
241         sink.sectionTitle2();
242         sink.text( title );
243         sink.sectionTitle2_();
244         sink.section2_();
245         sink.flush();
246         sink.close();
247 
248         String actual = testWriter.toString();
249         String expected = getSection2Block( title );
250 
251         assertEquals( "Wrong section2 block!", expected, actual );
252     }
253 
254     /**
255      * Checks that the sequence <code>[section3(), sectionTitle3(),
256      * text( title ), sectionTitle3_(), section3_()]</code>,
257      * invoked on the current sink, produces the same result as
258      * {@link #getSection3Block getSection3Block}( title ).
259      */
260     public void testSection3()
261     {
262         String title = "Title3";
263         sink.section3();
264         sink.sectionTitle3();
265         sink.text( title );
266         sink.sectionTitle3_();
267         sink.section3_();
268         sink.flush();
269         sink.close();
270 
271         String actual = testWriter.toString();
272         String expected = getSection3Block( title );
273 
274         assertEquals( "Wrong section3 block!", expected, actual );
275     }
276 
277     /**
278      * Checks that the sequence <code>[section4(), sectionTitle4(),
279      * text( title ), sectionTitle4_(), section4_()]</code>,
280      * invoked on the current sink, produces the same result as
281      * {@link #getSection4Block getSection4Block}( title ).
282      *
283      */
284     public void testSection4()
285     {
286         String title = "Title4";
287         sink.section4();
288         sink.sectionTitle4();
289         sink.text( title );
290         sink.sectionTitle4_();
291         sink.section4_();
292         sink.flush();
293         sink.close();
294 
295         String actual = testWriter.toString();
296         String expected = getSection4Block( title );
297 
298         assertEquals( "Wrong section4 block!", expected, actual );
299     }
300 
301     /**
302      * Checks that the sequence <code>[section5(), sectionTitle5(),
303      * text( title ), sectionTitle5_(), section5_()]</code>,
304      * invoked on the current sink, produces the same result as
305      * {@link #getSection5Block getSection5Block}( title ).
306      */
307     public void testSection5()
308     {
309         String title = "Title5";
310         sink.section5();
311         sink.sectionTitle5();
312         sink.text( title );
313         sink.sectionTitle5_();
314         sink.section5_();
315         sink.flush();
316         sink.close();
317 
318         String actual = testWriter.toString();
319         String expected = getSection5Block( title );
320 
321         assertEquals( "Wrong section5 block!", expected, actual );
322     }
323 
324     /**
325      * Checks that the sequence <code>[list(), listItem(), text( item ),
326      * listItem_(), list_()]</code>, invoked on the current sink, produces
327      * the same result as {@link #getListBlock getListBlock}( item ).
328      *
329      */
330     public void testList()
331     {
332         String item = "list_item";
333         sink.list();
334         sink.listItem();
335         sink.text( item );
336         sink.listItem_();
337         sink.list_();
338         sink.flush();
339         sink.close();
340 
341         String actual = testWriter.toString();
342         String expected = getListBlock( item );
343 
344         assertEquals( "Wrong list!", expected, actual );
345     }
346 
347     /**
348      * Checks that the sequence <code>
349      * [numberedList( Sink.NUMBERING_LOWER_ROMAN ), numberedListItem(),
350      * text( item ), numberedListItem_(), numberedList_()]</code>,
351      * invoked on the current sink, produces the same result as
352      * {@link #getNumberedListBlock getNumberedListBlock}( item ).
353      */
354     public void testNumberedList()
355     {
356         String item = "numbered_list_item";
357         sink.numberedList( Sink.NUMBERING_LOWER_ROMAN );
358         sink.numberedListItem();
359         sink.text( item );
360         sink.numberedListItem_();
361         sink.numberedList_();
362         sink.flush();
363         sink.close();
364 
365         String actual = testWriter.toString();
366         String expected = getNumberedListBlock( item );
367 
368         assertEquals( "Wrong numbered list!", expected, actual );
369     }
370 
371     /**
372      * Checks that the sequence <code>[definitionList(), definitionListItem(),
373      * definedTerm(), text( definum ), definedTerm_(), definition(),
374      * text( definition ), definition_(), definitionListItem_(),
375      * definitionList_()]</code>, invoked on the current sink, produces the same
376      * result as {@link #getDefinitionListBlock getDefinitionListBlock}
377      * ( definum, definition ).
378      */
379     public void testDefinitionList()
380     {
381         String definum = "definum";
382         String definition = "definition";
383         sink.definitionList();
384         sink.definitionListItem();
385         sink.definedTerm();
386         sink.text( definum );
387         sink.definedTerm_();
388         sink.definition();
389         sink.text( definition );
390         sink.definition_();
391         sink.definitionListItem_();
392         sink.definitionList_();
393         sink.flush();
394         sink.close();
395 
396         String actual = testWriter.toString();
397         String expected = getDefinitionListBlock( definum, definition );
398 
399         assertEquals( "Wrong definition list!", expected, actual );
400     }
401 
402     /**
403      * Checks that the sequence <code>[figure(), figureGraphics( source ),
404      * figureCaption(), text( caption ), figureCaption_(), figure_()]</code>,
405      * invoked on the current sink, produces the same result as
406      * {@link #getFigureBlock getFigureBlock}( source, caption ).
407      */
408     public void testFigure()
409     {
410         String source = "figure.jpg";
411         String caption = "Figure_caption";
412         sink.figure();
413         sink.figureGraphics( source );
414         sink.figureCaption();
415         sink.text( caption );
416         sink.figureCaption_();
417         sink.figure_();
418         sink.flush();
419         sink.close();
420 
421         String actual = testWriter.toString();
422         String expected = getFigureBlock( source, caption );
423 
424         assertEquals( "Wrong figure!", expected, actual );
425     }
426 
427 
428     public void testFigureWithoutCaption()
429     {
430         String source = "figure.jpg";
431         sink.figure();
432         sink.figureGraphics( source );
433         sink.figure_();
434         sink.flush();
435         sink.close();
436 
437         String actual = testWriter.toString();
438         String expected = getFigureBlock( source, null );
439 
440         assertEquals( "Wrong figure!", expected, actual );
441         
442     }
443     
444     /**
445      * Checks that the sequence <code>[table(),
446      * tableRows( Sink.JUSTIFY_CENTER, false ), tableRow(), tableCell(),
447      * text( cell ), tableCell_(), tableRow_(), tableRows_(), tableCaption(),
448      * text( caption ), tableCaption_(), table_()]</code>,
449      * invoked on the current sink, produces the same result as
450      * {@link #getTableBlock getTableBlock}( cell, caption ).
451      */
452     public void testTable()
453     {
454         String cell = "cell";
455         String caption = "Table_caption";
456         int[] justify = { Sink.JUSTIFY_CENTER };
457         sink.table();
458         sink.tableRows( justify, false );
459         sink.tableRow();
460         sink.tableCell();
461         sink.text( cell );
462         sink.tableCell_();
463         sink.tableRow_();
464         sink.tableRows_();
465         sink.tableCaption();
466         sink.text( caption );
467         sink.tableCaption_();
468         sink.table_();
469         sink.flush();
470         sink.close();
471 
472         String actual = testWriter.toString();
473         String expected = getTableBlock( cell, caption );
474 
475         assertEquals( "Wrong table!", expected, actual );
476     }
477 
478     /**
479      * Checks that the sequence <code>[paragraph(), text( text ),
480      * paragraph_()]</code>, invoked on the current sink, produces
481      * the same result as {@link #getParagraphBlock getParagraphBlock}( text ).
482      */
483     public void testParagraph()
484     {
485         String text = "Text";
486         sink.paragraph();
487         sink.text( text );
488         sink.paragraph_();
489         sink.flush();
490         sink.close();
491 
492         String actual = testWriter.toString();
493         String expected = getParagraphBlock( text );
494 
495         assertEquals( "Wrong paragraph!", expected, actual );
496     }
497 
498     /**
499      * Checks that the sequence <code>[verbatim( SinkEventAttributeSet.BOXED ), text( text ),
500      * verbatim_()]</code>, invoked on the current sink, produces the
501      * same result as {@link #getVerbatimBlock getVerbatimBlock}( text ).
502      */
503     public void testVerbatim()
504     {
505         String text = "Text";
506         sink.verbatim( SinkEventAttributeSet.BOXED );
507         sink.text( text );
508         sink.verbatim_();
509         sink.flush();
510         sink.close();
511 
512         String actual = testWriter.toString();
513         String expected = getVerbatimBlock( text );
514 
515         assertEquals( "Wrong verbatim!", expected, actual );
516     }
517 
518     /**
519      * Checks that the sequence <code>[horizontalRule()]</code>,
520      * invoked on the current sink, produces the same result as
521      * {@link #getHorizontalRuleBlock getHorizontalRuleBlock()}.
522      */
523     public void testHorizontalRule()
524     {
525         sink.horizontalRule();
526         sink.flush();
527         sink.close();
528 
529         String actual = testWriter.toString();
530         String expected = getHorizontalRuleBlock();
531 
532         assertEquals( "Wrong horizontal rule!", expected, actual );
533     }
534 
535     /**
536      * Checks that the sequence <code>[pageBreak()]</code>,
537      * invoked on the current sink, produces the same result as
538      * {@link #getPageBreakBlock getPageBreakBlock()}.
539      */
540     public void testPageBreak()
541     {
542         sink.pageBreak();
543         sink.flush();
544         sink.close();
545 
546         String actual = testWriter.toString();
547         String expected = getPageBreakBlock();
548 
549         assertEquals( "Wrong pageBreak!", expected, actual );
550     }
551 
552     /**
553      * Checks that the sequence <code>[anchor( anchor ), text( anchor ),
554      * anchor_()]</code>, invoked on the current sink, produces the same
555      * result as {@link #getAnchorBlock getAnchorBlock}( anchor ).
556      */
557     public void testAnchor()
558     {
559         String anchor = "Anchor";
560         sink.anchor( anchor );
561         sink.text( anchor );
562         sink.anchor_();
563         sink.flush();
564         sink.close();
565 
566         String actual = testWriter.toString();
567         String expected = getAnchorBlock( anchor );
568 
569         assertEquals( "Wrong anchor!", expected, actual );
570     }
571 
572     /**
573      * Checks that the sequence <code>[link( link ), text( text ),
574      * link_()]</code>, invoked on the current sink, produces the same
575      * result as {@link #getLinkBlock getLinkBlock}( link, text ).
576      */
577     public void testLink()
578     {
579         String link = "#Link";
580         String text = "Text";
581         sink.link( link );
582         sink.text( text );
583         sink.link_();
584         sink.flush();
585         sink.close();
586 
587         String actual = testWriter.toString();
588         String expected = getLinkBlock( link, text );
589 
590         assertEquals( "Wrong link!", expected, actual );
591     }
592 
593     /**
594      * Checks that the sequence <code>[italic(), text( text ), italic_()]</code>,
595      * invoked on the current sink, produces the same result as
596      * {@link #getItalicBlock getItalicBlock}( text ).
597      */
598     public void testItalic()
599     {
600         String text = "Italic";
601         sink.italic();
602         sink.text( text );
603         sink.italic_();
604         sink.flush();
605         sink.close();
606 
607         String actual = testWriter.toString();
608         String expected = getItalicBlock( text );
609 
610         assertEquals( "Wrong italic!", expected, actual );
611     }
612 
613     /**
614      * Checks that the sequence <code>[bold(), text( text ), bold_()]</code>,
615      * invoked on the current sink, produces the same result as
616      * {@link #getBoldBlock getBoldBlock}( text ).
617      */
618     public void testBold()
619     {
620         String text = "Bold";
621         sink.bold();
622         sink.text( text );
623         sink.bold_();
624         sink.flush();
625         sink.close();
626 
627         String actual = testWriter.toString();
628         String expected = getBoldBlock( text );
629 
630         assertEquals( "Wrong bold!", expected, actual );
631     }
632 
633     /**
634      * Checks that the sequence <code>[monospaced(), text( text ),
635      * monospaced_()]</code>, invoked on the current sink, produces the same
636      * result as {@link #getMonospacedBlock getMonospacedBlock}( text ).
637      */
638     public void testMonospaced()
639     {
640         String text = "Monospaced";
641         sink.monospaced();
642         sink.text( text );
643         sink.monospaced_();
644         sink.flush();
645         sink.close();
646 
647         String actual = testWriter.toString();
648         String expected = getMonospacedBlock( text );
649 
650         assertEquals( "Wrong monospaced!", expected, actual );
651     }
652 
653     /**
654      * Checks that the sequence <code>[lineBreak()]</code>,
655      * invoked on the current sink, produces the same result as
656      * {@link #getLineBreakBlock getLineBreakBlock()}.
657      */
658     public void testLineBreak()
659     {
660         sink.lineBreak();
661         sink.flush();
662         sink.close();
663 
664         String actual = testWriter.toString();
665         String expected = getLineBreakBlock();
666 
667         assertEquals( "Wrong lineBreak!", expected, actual );
668     }
669 
670     /**
671      * Checks that the sequence <code>[nonBreakingSpace()]</code>,
672      * invoked on the current sink, produces the same result as
673      * {@link #getNonBreakingSpaceBlock getNonBreakingSpaceBlock()}.
674      */
675     public void testNonBreakingSpace()
676     {
677         sink.nonBreakingSpace();
678         sink.flush();
679         sink.close();
680 
681         String actual = testWriter.toString();
682         String expected = getNonBreakingSpaceBlock();
683 
684         assertEquals( "Wrong nonBreakingSpace!", expected, actual );
685     }
686 
687     /**
688      * Checks that the sequence <code>[text( text )]</code>,
689      * invoked on the current sink, produces the same result as
690      * {@link #getTextBlock getTextBlock()}.
691      */
692     public void testText()
693     {
694         String text = "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\";
695         sink.text( text );
696         sink.flush();
697         sink.close();
698 
699         String actual = testWriter.toString();
700         String expected = getTextBlock( text );
701 
702         assertEquals( "Wrong text!", expected, actual );
703     }
704 
705     /**
706      * Checks that the sequence <code>[rawText( text )]</code>,
707      * invoked on the current sink, produces the same result as
708      * {@link #getRawTextBlock getRawTextBlock}( text ).
709      */
710     public void testRawText()
711     {
712         String text = "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\";
713         sink.rawText( text );
714         sink.flush();
715         sink.close();
716 
717         String actual = testWriter.toString();
718         String expected = getRawTextBlock( text );
719 
720         assertEquals( "Wrong rawText!", expected, actual );
721     }
722 
723     /**
724      * Checks that the sequence <code>[comment(comment)]</code>,
725      * invoked on the current sink, produces the same result as
726      * {@link #getCommentBlock getCommentBlock}( comment ).
727      * @since 1.1.1
728      */
729     public void testComment()
730     {
731         String comment = "Simple comment with ----";
732         sink.comment( comment );
733         sink.flush();
734         sink.close();
735 
736         String actual = testWriter.toString();
737         String expected = getCommentBlock( comment );
738 
739         assertEquals( "Wrong comment!", expected, actual );
740     }
741 
742     // ----------------------------------------------------------------------
743     // Utility methods
744     // ----------------------------------------------------------------------
745 
746     /**
747      * Returns the sink that is currently being tested.
748      * @return The current test sink.
749      */
750     protected Sink getSink()
751     {
752         return sink;
753     }
754 
755     /**
756      * Returns a String representation of all events that have been written to the sink.
757      * @return The Sink content as a String.
758      */
759     protected String getSinkContent()
760     {
761         return testWriter.toString();
762     }
763 
764     /**
765      * Returns the directory where all sink test output will go.
766      * @return The test output directory.
767      */
768     protected String getOutputDir()
769     {
770         return "sink/";
771     }
772 
773     // ----------------------------------------------------------------------
774     // Abstract methods the individual SinkTests must provide
775     // ----------------------------------------------------------------------
776 
777     /**
778      * This method allows to use the correct Writer in {@link #testTestDocument()}.
779      *
780      * @return <code>true</code> if the Sink is an XML one, <code>false</code> otherwise.
781      * @see #testTestDocument()
782      */
783     protected abstract boolean isXmlSink();
784 
785     /**
786      * Return a new instance of the sink that is being tested.
787      * @param writer The writer for the sink.
788      * @return A new sink.
789      */
790     protected abstract Sink createSink( Writer writer );
791 
792     /**
793      * Returns a title block generated by this sink.
794      * @param title The title to use.
795      * @return The result of invoking a title block on the current sink.
796      * @see #testTitle()
797      */
798     protected abstract String getTitleBlock( String title );
799 
800     /**
801      * Returns an author block generated by this sink.
802      * @param author The author to use.
803      * @return The result of invoking an author block on the current sink.
804      * @see #testAuthor()
805      */
806     protected abstract String getAuthorBlock( String author );
807 
808     /**
809      * Returns a date block generated by this sink.
810      * @param date The date to use.
811      * @return The result of invoking a date block on the current sink.
812      * @see #testDate()
813      */
814     protected abstract String getDateBlock( String date );
815 
816     /**
817      * Returns a head block generated by this sink.
818      * @return The result of invoking a head block on the current sink.
819      * @see #testHead()
820      */
821     protected abstract String getHeadBlock();
822 
823     /**
824      * Returns a body block generated by this sink.
825      * @return The result of invoking a body block on the current sink.
826      * @see #testBody()
827      */
828     protected abstract String getBodyBlock();
829 
830     /**
831      * Returns a SectionTitle block generated by this sink.
832      * @param title The title to use.
833      * @return The result of invoking a SectionTitle block on the current sink.
834      * @see #testSectionTitle()
835      */
836     protected abstract String getSectionTitleBlock( String title );
837 
838     /**
839      * Returns a Section1 block generated by this sink.
840      * @param title The title to use.
841      * @return The result of invoking a Section1 block on the current sink.
842      * @see #testSection1()
843      */
844     protected abstract String getSection1Block( String title );
845 
846     /**
847      * Returns a Section2 block generated by this sink.
848      * @param title The title to use.
849      * @return The result of invoking a Section2 block on the current sink.
850      * @see #testSection2()
851      */
852     protected abstract String getSection2Block( String title );
853 
854     /**
855      * Returns a Section3 block generated by this sink.
856      * @param title The title to use.
857      * @return The result of invoking a Section3 block on the current sink.
858      * @see #testSection3()
859      */
860     protected abstract String getSection3Block( String title );
861 
862     /**
863      * Returns a Section4 block generated by this sink.
864      * @param title The title to use.
865      * @return The result of invoking a Section4 block on the current sink.
866      * @see #testSection4()
867      */
868     protected abstract String getSection4Block( String title );
869 
870     /**
871      * Returns a Section5 block generated by this sink.
872      * @param title The title to use.
873      * @return The result of invoking a Section5 block on the current sink.
874      * @see #testSection5()
875      */
876     protected abstract String getSection5Block( String title );
877 
878     /**
879      * Returns a list block generated by this sink.
880      * @param item The item to use.
881      * @return The result of invoking a list block on the current sink.
882      * @see #testList()
883      */
884     protected abstract String getListBlock( String item );
885 
886     /**
887      * Returns a NumberedList block generated by this sink.
888      * @param item The item to use.
889      * @return The result of invoking a NumberedList block on the current sink.
890      * @see #testNumberedList()
891      */
892     protected abstract String getNumberedListBlock( String item );
893 
894     /**
895      * Returns a DefinitionList block generated by this sink.
896      * @param definum The term to define.
897      * @param definition The definition.
898      * @return The result of invoking a DefinitionList block on the current sink.
899      * @see #testDefinitionList()
900      */
901     protected abstract String getDefinitionListBlock( String definum,
902         String definition );
903 
904     /**
905      * Returns a Figure block generated by this sink.
906      * @param source The figure source string.
907      * @param caption The caption to use (may be null).
908      * @return The result of invoking a Figure block on the current sink.
909      * @see #testFigure()
910      */
911     protected abstract String getFigureBlock( String source, String caption );
912     
913     /**
914      * Returns a Table block generated by this sink.
915      * @param cell A tabel cell to use.
916      * @param caption The caption to use (may be null).
917      * @return The result of invoking a Table block on the current sink.
918      * @see #testTable()
919      */
920     protected abstract String getTableBlock( String cell, String caption );
921 
922     /**
923      * Returns a Paragraph block generated by this sink.
924      * @param text The text to use.
925      * @return The result of invoking a Paragraph block on the current sink.
926      * @see #testParagraph()
927      */
928     protected abstract String getParagraphBlock( String text );
929 
930     /**
931      * Returns a Verbatim block generated by this sink.
932      * @param text The text to use.
933      * @return The result of invoking a Verbatim block on the current sink.
934      * @see #testVerbatim()
935      */
936     protected abstract String getVerbatimBlock( String text );
937 
938     /**
939      * Returns a HorizontalRule block generated by this sink.
940      * @return The result of invoking a HorizontalRule block on the current sink.
941      * @see #testHorizontalRule()
942      */
943     protected abstract String getHorizontalRuleBlock();
944 
945     /**
946      * Returns a PageBreak block generated by this sink.
947      * @return The result of invoking a PageBreak block on the current sink.
948      * @see #testPageBreak()
949      */
950     protected abstract String getPageBreakBlock();
951 
952     /**
953      * Returns a Anchor block generated by this sink.
954      * @param anchor The anchor to use.
955      * @return The result of invoking a Anchor block on the current sink.
956      * @see #testAnchor()
957      */
958     protected abstract String getAnchorBlock( String anchor );
959 
960     /**
961      * Returns a Link block generated by this sink.
962      * @param link The link to use.
963      * @param text The link text.
964      * @return The result of invoking a Link block on the current sink.
965      * @see #testLink()
966      */
967     protected abstract String getLinkBlock( String link, String text );
968 
969     /**
970      * Returns a Italic block generated by this sink.
971      * @param text The text to use.
972      * @return The result of invoking a Italic block on the current sink.
973      * @see #testItalic()
974      */
975     protected abstract String getItalicBlock( String text );
976 
977     /**
978      * Returns a Bold block generated by this sink.
979      * @param text The text to use.
980      * @return The result of invoking a Bold block on the current sink.
981      * @see #testBold()
982      */
983     protected abstract String getBoldBlock( String text );
984 
985     /**
986      * Returns a Monospaced block generated by this sink.
987      * @param text The text to use.
988      * @return The result of invoking a Monospaced block on the current sink.
989      * @see #testMonospaced()
990      */
991     protected abstract String getMonospacedBlock( String text );
992 
993     /**
994      * Returns a LineBreak block generated by this sink.
995      * @return The result of invoking a LineBreak block on the current sink.
996      * @see #testLineBreak()
997      */
998     protected abstract String getLineBreakBlock();
999 
1000     /**
1001      * Returns a NonBreakingSpace block generated by this sink.
1002      * @return The result of invoking a NonBreakingSpace block
1003      * on the current sink.
1004      * @see #testNonBreakingSpace()
1005      */
1006     protected abstract String getNonBreakingSpaceBlock();
1007 
1008     /**
1009      * Returns a Text block generated by this sink.
1010      * @param text The text to use.
1011      * @return The result of invoking a Text block on the current sink.
1012      * @see #testText()
1013      */
1014     protected abstract String getTextBlock( String text );
1015 
1016     /**
1017      * Returns a RawText block generated by this sink.
1018      * @param text The text to use.
1019      * @return The result of invoking a RawText block on the current sink.
1020      * @see #testRawText()
1021      */
1022     protected abstract String getRawTextBlock( String text );
1023 
1024     /**
1025      * Returns a comment block generated by this sink.
1026      * @param text The text to use.
1027      * @return The result of invoking a comment block on the current sink.
1028      * @see #testComment()
1029      * @since 1.1.1
1030      */
1031     protected abstract String getCommentBlock( String text );
1032     
1033     protected final void verifyValignSup( String text )
1034     {
1035         sink.text( "ValignSup", new SinkEventAttributeSet( SinkEventAttributes.VALIGN, "sup"  ) );
1036         sink.flush();
1037         sink.close();
1038 
1039         String actual = testWriter.toString();
1040 
1041         assertEquals( "Wrong valign sup!", text, actual );
1042     }
1043     
1044     protected final void verifyValignSub( String text )
1045     {
1046         sink.text( "ValignSub", new SinkEventAttributeSet( SinkEventAttributes.VALIGN, "sub"  ) );
1047         sink.flush();
1048         sink.close();
1049 
1050         String actual = testWriter.toString();
1051 
1052         assertEquals( "Wrong valign sub!", text, actual );
1053     }
1054 
1055     protected final void verifyDecorationUnderline( String text )
1056     {
1057         sink.text( "DecorationUnderline", new SinkEventAttributeSet( SinkEventAttributes.DECORATION, "underline"  ) );
1058         sink.flush();
1059         sink.close();
1060 
1061         String actual = testWriter.toString();
1062 
1063         assertEquals( "Wrong decoration underline!", text, actual );
1064     }
1065 
1066     protected final void verifyDecorationLineThrough( String text )
1067     {
1068         sink.text( "DecorationLineThrough", new SinkEventAttributeSet( SinkEventAttributes.DECORATION, "line-through"  ) );
1069         sink.flush();
1070         sink.close();
1071 
1072         String actual = testWriter.toString();
1073 
1074         assertEquals( "Wrong decoration line-through!", text, actual );
1075     }
1076 
1077     
1078 }