### Question:
FoAggregateSink extends FoSink { public void link( String name ) { link( name, null ); } FoAggregateSink( Writer writer ); void head(); void head( SinkEventAttributes attributes ); void head_(); void title(); void title( SinkEventAttributes attributes ); void title_(); void author(); void author( SinkEventAttributes attributes ); void author_(); void date(); void date( SinkEventAttributes attributes ); void date_(); void body(); void body( SinkEventAttributes attributes ); void body_(); void setDocumentTitle( String title ); void setDocumentName( String name ); void setDocumentModel( DocumentModel model ); void setDocumentModel( DocumentModel model, int tocPos ); void figureGraphics( String name ); void figureGraphics( String src, SinkEventAttributes attributes ); void anchor( String name ); void anchor( String name, SinkEventAttributes attributes ); void link( String name ); void link( String name, SinkEventAttributes attributes ); void toc(); void coverPage(); static final int TOC_NONE; static final int TOC_START; static final int TOC_END; }### Answer:
@Test public void testLink() { try { sink = new FoAggregateSink( writer ); sink.link( "http: sink.text( "http: sink.link_(); sink.setDocumentName( "./folder\\docName.xml" ); sink.link( "#anchor" ); sink.text( "#anchor" ); sink.link_(); sink.link( "./././index.html" ); sink.text( "./././index.html" ); sink.link_(); sink.link( "./../download.html" ); sink.text( "./../download.html" ); sink.link_(); sink.link( ". sink.text( "./test.html" ); sink.link_(); sink.link( "./whatsnew-1.1.html" ); sink.text( "./whatsnew-1.1.html" ); sink.link_(); sink.setDocumentName( ". sink.body(); sink.body_(); } finally { sink.close(); } String result = writer.toString(); assertTrue( result.contains( "<fo:basic-link external-destination=\"http: assertTrue( result.contains( "<fo:basic-link internal-destination=\"./folder/docName#anchor\">" ) ); assertTrue( result.contains( "<fo:basic-link internal-destination=\"./folder/index\">" ) ); assertTrue( result.contains( "<fo:basic-link internal-destination=\"./download\">" ) ); assertTrue( result.contains( "<fo:basic-link internal-destination=\"./folder/test\">" ) ); assertTrue( result.contains( "<fo:basic-link internal-destination=\"./folder/whatsnew-1.1\">" ) ); assertTrue( result.contains( "<fo:block id=\"./whatsnew-1.1\">" ) ); writer = new StringWriter(); try { sink = new FoAggregateSink( writer ); sink.setDocumentName( "./subdir/dir/index.html" ); sink.link( "../../root.html" ); sink.text( "../../root.html" ); sink.link_(); sink.link( "../../../outside.html" ); sink.text( "../../../outside.html" ); sink.link_(); sink.body(); sink.body_(); } finally { sink.close(); } result = writer.toString(); assertTrue( result.contains( "<fo:basic-link internal-destination=\"./root\">" ) ); assertTrue( result.contains( "<fo:basic-link internal-destination=\"./outside\">" ) ); }