Package org.apache.maven.doxia.macro

Examples of org.apache.maven.doxia.macro.MacroRequest


                    for (int i = 1; i < count; i++)
                    {
                        parameters.put(parser.getAttributeName(i), parser.getAttributeValue(i));
                    }

                    MacroRequest request = new MacroRequest(parameters);

                    executeMacro(macroId, request, sink);
                }

                // ----------------------------------------------------------------------
View Full Code Here


                macroParameters.put( "sourceContent", sourceContent );
                FmlParser fmlParser = new FmlParser();
                fmlParser.setSecondParsing( true );
                macroParameters.put( "parser", fmlParser );

                MacroRequest request = new MacroRequest( macroParameters, getBasedir() );

                try
                {
                    StringWriter sw = new StringWriter();
                    XhtmlBaseSink sink = new XhtmlBaseSink(sw);
View Full Code Here

            aptParser.enableLogging( getLog() );
            parameters.put( "parser", aptParser );

            // getBasedir() does not work in multi-module builds, see DOXIA-373
            // the basedir should be injected from here, see DOXIA-224
            MacroRequest request = new MacroRequest( parameters, getBasedir() );
            try
            {
                AptParser.this.executeMacro( macroId, request, sink );
            }
            catch ( MacroExecutionException e )
View Full Code Here

        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() );
View Full Code Here

        File basedir = new File( "" );

        StringWriter out = new StringWriter();
        XhtmlBaseSink sink = new XhtmlBaseSink( out );
        MacroRequest request = new MacroRequest( macroParameters, basedir );
        TocMacro macro = new TocMacro();
        macro.execute( sink, request );

        assertTrue( out.toString().contains( "<a href=\"#h21\">h21</a>" ) );
        assertTrue( out.toString().contains( "<a href=\"#h22\">h22</a>" ) );
View Full Code Here

                macroParameters.put( "sourceContent", sourceContent );
                XdocParser xdocParser = new XdocParser();
                xdocParser.setSecondParsing( true );
                macroParameters.put( "parser", xdocParser );

                MacroRequest request = new MacroRequest( macroParameters, getBasedir() );

                try
                {
                    executeMacro( macroName, request, sink );
                }
View Full Code Here

        Map<String, Object> macroParameters = new HashMap<String, Object>();
        macroParameters.put( "file", "src/test/resources/macro/snippet/testSnippet.txt" );

        SinkEventTestingSink sink = new SinkEventTestingSink();

        MacroRequest request = new MacroRequest( macroParameters, basedir );
        SnippetMacro macro = new SnippetMacro();
        macro.execute( sink, request );

        Iterator<SinkEventElement> it = sink.getEventList().iterator();
        assertEquals( "verbatim", ( it.next() ).getName() );
        SinkEventElement event = it.next();
        assertEquals( "text", event.getName() );
        String snippet = (String) event.getArgs()[0];
        assertEquals( "verbatim_", ( it.next() ).getName() );
        assertFalse( it.hasNext() );

        assertTrue( snippet.contains( "preamble" ) );
        assertTrue( snippet.contains( "first snippet" ) );
        assertTrue( snippet.contains( "interlude" ) );
        assertTrue( snippet.contains( "second snippet" ) );
        assertTrue( snippet.contains( "conclusion" ) );

        // again

        macroParameters.put( "id", "firstId" );
        macroParameters.put( "verbatim", "" );
        sink.reset();
        request = new MacroRequest( macroParameters, basedir );
        macro.execute( sink, request );

        it = sink.getEventList().iterator();
        assertEquals( "verbatim", ( it.next() ).getName() );
        event = it.next();
        assertEquals( "text", event.getName() );
        snippet = (String) event.getArgs()[0];
        assertEquals( "verbatim_", ( it.next() ).getName() );
        assertFalse( it.hasNext() );

        assertFalse( snippet.contains( "preamble" ) );
        assertTrue( snippet.contains( "first snippet" ) );
        assertFalse( snippet.contains( "interlude" ) );
        assertFalse( snippet.contains( "second snippet" ) );
        assertFalse( snippet.contains( "conclusion" ) );

        // again

        macroParameters.put( "id", "secondId" );
        macroParameters.put( "verbatim", "false" );
        sink.reset();
        request = new MacroRequest( macroParameters, basedir );
        macro.execute( sink, request );

        it = sink.getEventList().iterator();
        event = it.next();
        assertEquals( "rawText", event.getName() );
View Full Code Here

        File basedir = new File( getBasedir() );

        SinkEventTestingSink sink = new SinkEventTestingSink();

        MacroRequest request = new MacroRequest( macroParameters, basedir );
        SnippetMacro macro = new SnippetMacro();
        macro.execute( sink, request );
        Iterator<SinkEventElement> it = sink.getEventList().iterator();
        assertEquals( "verbatim", ( it.next() ).getName() );
        SinkEventElement event = it.next();
View Full Code Here

                macroParameters.put( "sourceContent", sourceContent );
                FmlParser fmlParser = new FmlParser();
                fmlParser.setSecondParsing( true );
                macroParameters.put( "parser", fmlParser );

                MacroRequest request = new MacroRequest( macroParameters, getBasedir() );

                try
                {
                    StringWriter sw = new StringWriter();
                    XhtmlBaseSink sink = new XhtmlBaseSink( sw );
View Full Code Here

        macroParameters.put( "file", "src/test/resources/macro/snippet/testSnippet.txt" );
        macroParameters.put( "encoding", "UTF-8" );

        SinkEventTestingSink sink = new SinkEventTestingSink();

        MacroRequest request = new MacroRequest( macroParameters, basedir );
        SnippetMacro macro = new SnippetMacro();
        macro.execute( sink, request );

        Iterator<SinkEventElement> it = sink.getEventList().iterator();
        assertEquals( "verbatim", ( it.next() ).getName() );
        SinkEventElement event = it.next();
        assertEquals( "text", event.getName() );
        String snippet = (String) event.getArgs()[0];
        assertEquals( "verbatim_", ( it.next() ).getName() );
        assertFalse( it.hasNext() );

        assertTrue( snippet.contains( "preamble" ) );
        assertTrue( snippet.contains( "first snippet" ) );
        assertTrue( snippet.contains( "interlude" ) );
        assertTrue( snippet.contains( "second snippet" ) );
        assertTrue( snippet.contains( "conclusion" ) );

        // again

        macroParameters.put( "id", "firstId" );
        macroParameters.put( "verbatim", "" );
        sink.reset();
        request = new MacroRequest( macroParameters, basedir );
        macro.execute( sink, request );

        it = sink.getEventList().iterator();
        assertEquals( "verbatim", ( it.next() ).getName() );
        event = it.next();
        assertEquals( "text", event.getName() );
        snippet = (String) event.getArgs()[0];
        assertEquals( "verbatim_", ( it.next() ).getName() );
        assertFalse( it.hasNext() );

        assertFalse( snippet.contains( "preamble" ) );
        assertTrue( snippet.contains( "first snippet" ) );
        assertFalse( snippet.contains( "interlude" ) );
        assertFalse( snippet.contains( "second snippet" ) );
        assertFalse( snippet.contains( "conclusion" ) );

        // again

        macroParameters.put( "id", "secondId" );
        macroParameters.put( "verbatim", "false" );
        sink.reset();
        request = new MacroRequest( macroParameters, basedir );
        macro.execute( sink, request );

        it = sink.getEventList().iterator();
        event = it.next();
        assertEquals( "rawText", event.getName() );
        snippet = (String) event.getArgs()[0];
        assertFalse( it.hasNext() );

        assertFalse( snippet.contains( "preamble" ) );
        assertFalse( snippet.contains( "first snippet" ) );
        assertFalse( snippet.contains( "interlude" ) );
        assertTrue( snippet.contains( "second snippet" ) );
        assertFalse( snippet.contains( "conclusion" ) );

        // again

        macroParameters.put( "id", "thirdId" );
        macroParameters.put( "verbatim", "false" );
        sink.reset();
        request = new MacroRequest( macroParameters, basedir );
        macro.execute( sink, request );

        it = sink.getEventList().iterator();
        event = it.next();
        assertEquals( "rawText", event.getName() );
View Full Code Here

TOP

Related Classes of org.apache.maven.doxia.macro.MacroRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.