macroParameters.put( "section", "sec1" );
File basedir = new File( "" );
SinkEventTestingSink sink = new SinkEventTestingSink();
MacroRequest request = new MacroRequest( macroParameters, basedir );
TocMacro macro = new TocMacro();
macro.execute( sink, request );
Iterator<SinkEventElement> it = sink.getEventList().iterator();
assertEquals( "list", ( it.next() ).getName() );
assertEquals( "listItem", ( it.next() ).getName() );
assertEquals( "link", ( it.next() ).getName() );
assertEquals( "text", ( it.next() ).getName() );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "listItem_", ( it.next() ).getName() );
assertEquals( "listItem", ( it.next() ).getName() );
assertEquals( "link", ( it.next() ).getName() );
assertEquals( "text", ( it.next() ).getName() );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "list", ( it.next() ).getName() );
assertEquals( "listItem", ( it.next() ).getName() );
assertEquals( "link", ( it.next() ).getName() );
assertEquals( "text", ( it.next() ).getName() );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "list", ( it.next() ).getName() );
assertEquals( "listItem", ( it.next() ).getName() );
assertEquals( "link", ( it.next() ).getName() );
assertEquals( "text", ( it.next() ).getName() );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "listItem_", ( it.next() ).getName() );
assertEquals( "list_", ( it.next() ).getName() );
assertEquals( "listItem_", ( it.next() ).getName() );
assertEquals( "list_", ( it.next() ).getName() );
assertEquals( "listItem_", ( it.next() ).getName() );
assertEquals( "listItem", ( it.next() ).getName() );
assertEquals( "link", ( it.next() ).getName() );
assertEquals( "text", ( it.next() ).getName() );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "listItem_", ( it.next() ).getName() );
assertEquals( "list_", ( it.next() ).getName() );
assertFalse( it.hasNext() );
// test parameters
parser = new XhtmlBaseParser();
parser.setSecondParsing( true );
macroParameters.put( "parser", parser );
macroParameters.put( "section", "2" );
macroParameters.put( "fromDepth", "1" );
macroParameters.put( "toDepth", "2" );
macroParameters.put( "class", "myClass" );
macroParameters.put( "id", "myId" );
sink.reset();
request = new MacroRequest( macroParameters, basedir );
macro.execute( sink, request );
it = sink.getEventList().iterator();
SinkEventElement event = it.next();
assertEquals( "list", event.getName() );