You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by lt...@apache.org on 2007/07/25 23:43:31 UTC

svn commit: r559622 - in /maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia: ./ module/ parser/ sink/

Author: ltheussl
Date: Wed Jul 25 14:43:30 2007
New Revision: 559622

URL: http://svn.apache.org/viewvc?view=rev&rev=559622
Log:
DOXIA-101: add basic classes that can be used to test parsers and sinks.

Added:
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java   (with props)
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java   (with props)
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java   (with props)
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java   (with props)
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java   (with props)
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java   (with props)

Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java?view=auto&rev=559622
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java Wed Jul 25 14:43:30 2007
@@ -0,0 +1,162 @@
+package org.apache.maven.doxia;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Writer;
+
+/**
+ * Provide some common convenience methods to
+ * test Doxia modules (parsers and sinks).
+ */
+public abstract class AbstractModuleTest
+    extends PlexusTestCase
+{
+
+    // ----------------------------------------------------------------------
+    // Methods for creating test reader and writer
+    // ----------------------------------------------------------------------
+
+    /**
+     * Returns a FileWriter to write to a file with the given name
+     * in the test target output directory.
+     *
+     * @param baseName The name of the target file.
+     * @param extension The file extension of the file to write.
+     * @return A FileWriter.
+     * @throws IOException If the FileWriter could not be generated.
+     */
+    protected Writer getTestWriter( String baseName, String extension )
+        throws IOException
+    {
+        File outputDirectory =
+            new File( getBasedirFile(), outputBaseDir() + getOutputDir() );
+
+        if ( !outputDirectory.exists() )
+        {
+            outputDirectory.mkdirs();
+        }
+
+        return new FileWriter(
+            new File( outputDirectory, baseName + "." + extension ) );
+    }
+
+    /**
+     * Returns a FileWriter to write to a file with the given name
+     * in the test target output directory.
+     *
+     * @param baseName The name of the target file.
+     * @return A FileWriter.
+     * @throws IOException If the FileWriter could not be generated.
+     */
+    protected Writer getTestWriter( String baseName )
+        throws IOException
+    {
+        return getTestWriter( baseName, outputExtension() );
+    }
+
+    /**
+     * Returns an InputStreamReader to read a resource from a file
+     * in the test target output directory.
+     *
+     * @param baseName The name of the resource file to read.
+     * @param extension The file extension of the resource file to read.
+     * @return An InputStreamReader.
+     */
+    protected Reader getTestReader( String baseName, String extension )
+    {
+        InputStream is =
+            Thread.currentThread().getContextClassLoader().getResourceAsStream(
+                baseName + "." + extension );
+
+        assertNotNull( "Could not find resource: "
+            + baseName + "." + extension, is );
+
+        InputStreamReader reader = new InputStreamReader( is );
+
+        return reader;
+    }
+
+    /**
+     * Returns an InputStreamReader to read a resource from a file
+     * in the test target output directory.
+     *
+     * @param baseName The name of the resource file to read.
+     * @param extension The file extension of the resource file to read.
+     * @return An InputStreamReader.
+     */
+    protected Reader getTestReader( String baseName )
+    {
+        return getTestReader( baseName, outputExtension() );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Utility methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * Returns the common base directory.
+     *
+     * @return The common base directory as a File.
+     */
+    protected File getBasedirFile()
+    {
+        return new File( getBasedir() );
+    }
+
+    /**
+     * Returns the base directory where all test output will go.
+     *
+     * @return The test output directory.
+     */
+    protected final String outputBaseDir()
+    {
+        return "target/test-output/";
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Abstract methods the individual ModuleTests must provide
+    // ----------------------------------------------------------------------
+
+    /**
+     * Determines the default file extension for the current module.
+     *
+     * @return The default file extension.
+     */
+    protected abstract String outputExtension();
+
+    /**
+     * Returns the directory where test output will go.
+     * Should be relative to outputBaseDir().
+     *
+     * @return The test output directory, relative to outputBaseDir().
+     */
+    protected abstract String getOutputDir();
+
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java?view=auto&rev=559622
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java Wed Jul 25 14:43:30 2007
@@ -0,0 +1,148 @@
+package org.apache.maven.doxia.module;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.apache.maven.doxia.AbstractModuleTest;
+
+import org.apache.maven.doxia.parser.ParseException;
+import org.apache.maven.doxia.parser.Parser;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkTestDocument;
+import org.apache.maven.doxia.sink.TextSink;
+
+/**
+ * If a module provides both Parser and Sink, this class
+ * can be used to check that chaining them together
+ * results in the identity transformation, ie the model is still the same
+ * after being piped through a Parser and the corresponding Sink.
+ */
+public abstract class AbstractIdentityTest extends AbstractModuleTest
+{
+
+    /**
+     * Create a new instance of the parser to test.
+     * 
+     * @return the parser to test.
+     */
+    protected abstract Parser createParser();
+
+    /**
+     * Return a new instance of the sink that is being tested.
+     *
+     * @param writer The writer for the sink.
+     * @return A new sink.
+     */
+    protected abstract Sink createSink( Writer writer );
+
+
+    /**
+     * Pipes a full model generated by {@see SinkTestDocument} through
+     * a Sink (generated by {@see #createSink(Writer)}) and a Parser
+     * (generated by {@see #createParser()}) and checks if the result
+     * is the same as the original model. Currently, this doesn't actually
+     * assert anything, but the two generated output files, expected.txt
+     * and actual.txt can be compared for differences.
+     */
+    public void testIdentity()
+        throws IOException, ParseException
+    {
+        Writer writer = null;
+
+        Writer fileWriter = null;
+
+        Reader reader = null;
+
+        try
+        {
+            // generate the expected model
+            writer =  new StringWriter();
+            SinkTestDocument.generate( new TextSink( writer ) );
+            String expected = writer.toString();
+
+            // write to file for comparison
+            fileWriter = getTestWriter( "expected", "txt" );
+            SinkTestDocument.generate( new TextSink( fileWriter ) );
+
+
+            // generate the actual model
+            writer =  new StringWriter();
+            SinkTestDocument.generate( createSink( writer ) );
+            reader = new StringReader( writer.toString() );
+
+            writer =  new StringWriter();
+            createParser().parse( reader, new TextSink( writer ) );
+            String actual = writer.toString();
+
+            // write to file for comparison
+            fileWriter = getTestWriter( "actual", "txt" );
+            reader.reset();
+            createParser().parse( reader, new TextSink( fileWriter ) );
+
+            // Disabled for now, it's unlikely that any of our modules
+            // will pass this test any time soon, but the generated
+            // output files can still be compared.
+
+            // TODO: make this work for at least apt and xdoc modules?
+            //assertEquals( "Identity test failed!", expected, actual );
+
+        }
+        finally
+        {
+            if ( writer  != null )
+            {
+                writer.close();
+            }
+
+            if ( fileWriter  != null )
+            {
+                fileWriter.close();
+            }
+
+            if ( reader != null )
+            {
+                reader.close();
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected String getOutputDir()
+    {
+        return "identity/";
+    }
+
+    /**
+     * Not used here, just required by AbstractModuleTest.
+     *
+     * @return An empty String.
+     */
+    protected String outputExtension()
+    {
+        return "";
+    }
+
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java?view=auto&rev=559622
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java Wed Jul 25 14:43:30 2007
@@ -0,0 +1,132 @@
+package org.apache.maven.doxia.parser;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.doxia.AbstractModuleTest;
+import org.apache.maven.doxia.WellformednessCheckingSink;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.TextSink;
+import org.apache.maven.doxia.parser.ParseException;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+/**
+ * Test the parsing of sample input files.
+ * <b>Note</b>: you have to provide a sample "test." + outputExtension()
+ * file in the test resources directory if you extend this class.
+ */
+public abstract class AbstractParserTest
+    extends AbstractModuleTest
+{
+    /**
+     * Create a new instance of the parser to test.
+     * 
+     * @return the parser to test.
+     */
+    protected abstract Parser createParser();
+
+    /**
+     * Returns the directory where all parser test output will go.
+     *
+     * @return The test output directory.
+     */
+    protected String getOutputDir()
+    {
+        return "parser/";
+    }
+
+    /**
+     * Parse a test document '"test." + outputExtension()'
+     * with parser from {@link #createParser()}, and output to a new
+     * {@link WellformednessCheckingSink}. Asserts that output is well-formed.
+     *
+     * @throws IOException if the test document cannot be read.
+     * @throws ParseException if the test document cannot be parsed.
+     */
+    public final void testParser()
+        throws IOException, ParseException
+    {
+
+        WellformednessCheckingSink sink = new WellformednessCheckingSink();
+
+        Reader reader = null;
+
+        try
+        {
+            reader = getTestReader( "test", outputExtension() );
+
+            createParser().parse( reader, sink );
+
+            assertTrue( "Parser output not well-formed, last offending element: "
+                + sink.getOffender(), sink.isWellformed() );
+        }
+        finally
+        {
+            if ( reader != null )
+            {
+                reader.close();
+            }
+        }
+    }
+
+     /**
+     * Parse a test document '"test." + outputExtension()'
+     * with parser from {@link #createParser()}, and output to a text file,
+     * using the {@link org.apache.maven.doxia.sink.TextSink TextSink}.
+     *
+     * @throws IOException if the test document cannot be read.
+     * @throws ParseException if the test document cannot be parsed.
+     */
+    public final void testDocument()
+        throws IOException, ParseException
+    {
+        Writer writer = null;
+        Reader reader = null;
+
+        try
+        {
+            writer = getTestWriter( "test", "txt" );
+
+            reader = getTestReader( "test", outputExtension() );
+
+            Sink sink = new TextSink( writer );
+
+            createParser().parse( reader, sink );
+        }
+        finally
+        {
+            if ( writer  != null )
+            {
+                writer.close();
+            }
+
+            if ( reader != null )
+            {
+                reader.close();
+            }
+        }
+    }
+
+
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java?view=auto&rev=559622
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java Wed Jul 25 14:43:30 2007
@@ -0,0 +1,886 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.doxia.AbstractModuleTest;
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Abstract base class to test sinks.
+ */
+public abstract class AbstractSinkTest
+    extends AbstractModuleTest
+{
+    private final CharArrayWriter writer = new CharArrayWriter();
+    private Sink sink;
+
+    /**
+     * Resets the writer and creates a new sink with it.
+     */
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        writer.reset();
+        sink = createSink( writer );
+    }
+
+    // ---------------------------------------------------------------------
+    // Common test cases
+    // ----------------------------------------------------------------------
+
+    /**
+     * Tests that the current sink is able to render the common test document.
+     * @see SinkTestDocument
+     * @throws IOException If the target test document could not be generated.
+     */
+    public final void testTestDocument() throws IOException
+    {
+        Sink testSink = createSink( getTestWriter( "testDocument" ) );
+
+        SinkTestDocument.generate( testSink );
+
+        testSink.close();
+    }
+
+    /**
+     * Checks that the sequence <code>[title(), text( title ), title_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getTitleBlock getTitleBlock}( title ).
+     * NewLines are ignored.
+     */
+    public void testTitle()
+    {
+        String title = "Grodek";
+        sink.title();
+        sink.text( title );
+        sink.title_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong title!",
+            expected, noNewLine( getTitleBlock( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[author(), text( author ), author_()]
+     * </code>, invoked on the current sink, produces the same result as
+     * {@link #getAuthorBlock getAuthorBlock}( author ).
+     * NewLines are ignored.
+     */
+    public void testAuthor()
+    {
+        String author = "Georg Trakl";
+        sink.author();
+        sink.text( author );
+        sink.author_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong author!",
+            expected, noNewLine( getAuthorBlock( author ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[date(), text( date ), date_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getDateBlock getDateBlock}( date ). NewLines are ignored.
+     */
+    public void testDate()
+    {
+        String date = "1914";
+        sink.date();
+        sink.text( date );
+        sink.date_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong date!",
+            expected, noNewLine( getDateBlock( date ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[head(), head_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getHeadBlock getHeadBlock()}. NewLines are ignored.
+     */
+    public void testHead()
+    {
+        sink.head();
+        sink.head_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong head!", expected, noNewLine( getHeadBlock() ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[body(), body_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getBodyBlock getBodyBlock()}. NewLines are ignored.
+     */
+    public void testBody()
+    {
+        sink.body();
+        sink.body_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong body!", expected, noNewLine( getBodyBlock() ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[sectionTitle(), text( title ),
+     * sectionTitle_()]</code>, invoked on the current sink, produces
+     * the same result as
+     * {@link #getSectionTitleBlock getSectionTitleBlock}( title ).
+     * NewLines are ignored.
+     */
+    public void testSectionTitle()
+    {
+        String title = "Title";
+        sink.sectionTitle();
+        sink.text( title );
+        sink.sectionTitle_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong sectionTitle!",
+            expected, noNewLine( getSectionTitleBlock( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[section1(), sectionTitle1(),
+     * text( title ), sectionTitle1_(), section1_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getSection1Block getSection1Block}( title ).
+     * NewLines are ignored.
+     */
+    public void testSection1()
+    {
+        String title = "Title1";
+        sink.section1();
+        sink.sectionTitle1();
+        sink.text( title );
+        sink.sectionTitle1_();
+        sink.section1_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong section1 block!",
+            expected, noNewLine( getSection1Block( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[section2(), sectionTitle2(),
+     * text( title ), sectionTitle2_(), section2_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getSection2Block getSection2Block}( title ).
+     * NewLines are ignored.
+     */
+    public void testSection2()
+    {
+        String title = "Title2";
+        sink.section2();
+        sink.sectionTitle2();
+        sink.text( title );
+        sink.sectionTitle2_();
+        sink.section2_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong section2 block!",
+            expected, noNewLine( getSection2Block( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[section3(), sectionTitle3(),
+     * text( title ), sectionTitle3_(), section3_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getSection3Block getSection3Block}( title ).
+     * NewLines are ignored.
+     */
+    public void testSection3()
+    {
+        String title = "Title3";
+        sink.section3();
+        sink.sectionTitle3();
+        sink.text( title );
+        sink.sectionTitle3_();
+        sink.section3_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong section3 block!",
+            expected, noNewLine( getSection3Block( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[section4(), sectionTitle4(),
+     * text( title ), sectionTitle4_(), section4_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getSection4Block getSection4Block}( title ).
+     * NewLines are ignored.
+     */
+    public void testSection4()
+    {
+        String title = "Title4";
+        sink.section4();
+        sink.sectionTitle4();
+        sink.text( title );
+        sink.sectionTitle4_();
+        sink.section4_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong section4 block!",
+            expected, noNewLine( getSection4Block( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[section5(), sectionTitle5(),
+     * text( title ), sectionTitle5_(), section5_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getSection5Block getSection5Block}( title ).
+     * NewLines are ignored.
+     */
+    public void testSection5()
+    {
+        String title = "Title5";
+        sink.section5();
+        sink.sectionTitle5();
+        sink.text( title );
+        sink.sectionTitle5_();
+        sink.section5_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong section5 block!",
+            expected, noNewLine( getSection5Block( title ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[list(), listItem(), text( item ),
+     * listItem_(), list_()]</code>, invoked on the current sink, produces
+     * the same result as {@link #getListBlock getListBlock}( item ).
+     * NewLines are ignored.
+     */
+    public void testList()
+    {
+        String item = "list item";
+        sink.list();
+        sink.listItem();
+        sink.text( item );
+        sink.listItem_();
+        sink.list_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong list!",
+            expected, noNewLine( getListBlock( item ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>
+     * [numberedList( Sink.NUMBERING_LOWER_ROMAN ), numberedListItem(),
+     * text( item ), numberedListItem_(), numberedList_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getNumberedListBlock getNumberedListBlock}( item ).
+     * NewLines are ignored.
+     */
+    public void testNumberedList()
+    {
+        String item = "numbered list item";
+        sink.numberedList( Sink.NUMBERING_LOWER_ROMAN );
+        sink.numberedListItem();
+        sink.text( item );
+        sink.numberedListItem_();
+        sink.numberedList_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong numbered list!",
+            expected, noNewLine( getNumberedListBlock( item ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[definitionList(), definitionListItem(),
+     * definedTerm(), text( definum ), definedTerm_(), definition(),
+     * text( definition ), definition_(), definitionListItem_(),
+     * definitionList_()]</code>, invoked on the current sink, produces the same
+     * result as {@link #getDefinitionListBlock getDefinitionListBlock}
+     * ( definum, definition ). NewLines are ignored.
+     */
+    public void testDefinitionList()
+    {
+        String definum = "definum";
+        String definition = "definition";
+        sink.definitionList();
+        sink.definitionListItem();
+        sink.definedTerm();
+        sink.text( definum );
+        sink.definedTerm_();
+        sink.definition();
+        sink.text( definition );
+        sink.definition_();
+        sink.definitionListItem_();
+        sink.definitionList_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong definition list!", expected,
+            noNewLine( getDefinitionListBlock( definum, definition ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[figure(), figureGraphics( source ),
+     * figureCaption(), text( caption ), figureCaption_(), figure_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getFigureBlock getFigureBlock}( source, caption ).
+     * NewLines are ignored.
+     */
+    public void testFigure()
+    {
+        String source = "figure";
+        String caption = "Figure caption";
+        sink.figure();
+        sink.figureGraphics( source );
+        sink.figureCaption();
+        sink.text( caption );
+        sink.figureCaption_();
+        sink.figure_();
+
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong figure!", expected,
+            noNewLine( getFigureBlock( source, caption ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[table(),
+     * tableRows( Parser.JUSTIFY_CENTER, false ), tableRow(), tableCell(),
+     * text( cell ), tableCell_(), tableRow_(), tableRows_(), tableCaption(),
+     * text( caption ), tableCaption_(), table_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getTableBlock getTableBlock}( cell, caption ).
+     * NewLines are ignored.
+     */
+    public void testTable()
+    {
+        String cell = "cell";
+        String caption = "Table caption";
+        int[] justify = { Parser.JUSTIFY_CENTER };
+        sink.table();
+        sink.tableRows( justify, false );
+        sink.tableRow();
+        sink.tableCell();
+        sink.text( cell );
+        sink.tableCell_();
+        sink.tableRow_();
+        sink.tableRows_();
+        sink.tableCaption();
+        sink.text( caption );
+        sink.tableCaption_();
+        sink.table_();
+
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong table!", expected,
+            noNewLine( getTableBlock( cell, caption ) ) );
+    }
+    /**
+     * Checks that the sequence <code>[paragraph(), text( text ),
+     * paragraph_()]</code>, invoked on the current sink, produces
+     * the same result as {@link #getParagraphBlock getParagraphBlock}( text ).
+     * NewLines are ignored.
+     */
+    public void testParagraph()
+    {
+        String text = "Text";
+        sink.paragraph();
+        sink.text( text );
+        sink.paragraph_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong paragraph!",
+            expected, noNewLine( getParagraphBlock( text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[verbatim( true ), text( text ),
+     * verbatim_()]</code>, invoked on the current sink, produces the
+     * same result as {@link #getVerbatimBlock getVerbatimBlock}( text ).
+     * NewLines are ignored.
+     */
+    public void testVerbatim()
+    {
+        String text = "Text";
+        sink.verbatim( true );
+        sink.text( text );
+        sink.verbatim_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong verbatim!",
+            expected, noNewLine( getVerbatimBlock( text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[horizontalRule()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getHorizontalRuleBlock getHorizontalRuleBlock()}.
+     * NewLines are ignored.
+     */
+    public void testHorizontalRule()
+    {
+        sink.horizontalRule();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong horizontal rule!",
+            expected, noNewLine( getHorizontalRuleBlock() ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[pageBreak()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getPageBreakBlock getPageBreakBlock()}. NewLines are ignored.
+     */
+    public void testPageBreak()
+    {
+        sink.pageBreak();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong pageBreak!",
+            expected, noNewLine( getPageBreakBlock() ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[anchor( anchor ), text( anchor ),
+     * anchor_()]</code>, invoked on the current sink, produces the same
+     * result as {@link #getAnchorBlock getAnchorBlock}( anchor ).
+     * NewLines are ignored.
+     */
+    public void testAnchor()
+    {
+        String anchor = "Anchor";
+        sink.anchor( anchor );
+        sink.text( anchor );
+        sink.anchor_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong anchor!",
+            expected, noNewLine( getAnchorBlock( anchor ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[link( link ), text( text ),
+     * link_()]</code>, invoked on the current sink, produces the same
+     * result as {@link #getLinkBlock getLinkBlock}( link, text ).
+     * NewLines are ignored.
+     */
+    public void testLink()
+    {
+        String link = "Link";
+        String text = "Text";
+        sink.link( link );
+        sink.text( text );
+        sink.link_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong link!",
+            expected, noNewLine( getLinkBlock( link, text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[italic(), text( text ), italic_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getItalicBlock getItalicBlock}( text ). NewLines are ignored.
+     */
+    public void testItalic()
+    {
+        String text = "Italic";
+        sink.italic();
+        sink.text( text );
+        sink.italic_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong italic!",
+            expected, noNewLine( getItalicBlock( text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[bold(), text( text ), bold_()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getBoldBlock getBoldBlock}( text ). NewLines are ignored.
+     */
+    public void testBold()
+    {
+        String text = "Bold";
+        sink.bold();
+        sink.text( text );
+        sink.bold_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong bold!",
+            expected, noNewLine( getBoldBlock( text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[monospaced(), text( text ),
+     * monospaced_()]</code>, invoked on the current sink, produces the same
+     * result as {@link #getMonospacedBlock getMonospacedBlock}( text ).
+     * NewLines are ignored.
+     */
+    public void testMonospaced()
+    {
+        String text = "Monospaced";
+        sink.monospaced();
+        sink.text( text );
+        sink.monospaced_();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong monospaced!",
+            expected, noNewLine( getMonospacedBlock( text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[lineBreak()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getLineBreakBlock getLineBreakBlock()}. NewLines are ignored.
+     */
+    public void testLineBreak()
+    {
+        sink.lineBreak();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong lineBreak!",
+            expected, noNewLine( getLineBreakBlock() ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[nonBreakingSpace()]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getNonBreakingSpaceBlock getNonBreakingSpaceBlock()}.
+     * NewLines are ignored.
+     */
+    public void testNonBreakingSpace()
+    {
+        sink.nonBreakingSpace();
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong nonBreakingSpace!",
+            expected, noNewLine( getNonBreakingSpaceBlock() ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[text( text )]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getTextBlock getTextBlock()}. NewLines are ignored.
+     */
+    public void testText()
+    {
+        String text = "~, =, -, +, *, [, ], <, >, {, }, \\";
+        sink.text( text );
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong text!",
+            expected, noNewLine( getTextBlock( text ) ) );
+    }
+
+    /**
+     * Checks that the sequence <code>[rawText( text )]</code>,
+     * invoked on the current sink, produces the same result as
+     * {@link #getRawTextBlock getRawTextBlock}( text ). NewLines are ignored.
+     */
+    public void testRawText()
+    {
+        String text = "~, =, -, +, *, [, ], <, >, {, }, \\";
+        sink.rawText( text );
+
+        String expected = noNewLine( writer.toString() );
+        assertEquals( "Wrong rawText!",
+            expected, noNewLine( getRawTextBlock( text ) ) );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Utility methods
+    // ----------------------------------------------------------------------
+
+    private String noNewLine( String text )
+    {
+        String EOL = System.getProperty( "line.separator" );
+        return text.replaceAll( EOL, "" );
+    }
+
+    /**
+     * Returns the sink that is currently being tested.
+     * @return The current test sink.
+     */
+    protected Sink getSink()
+    {
+        return sink;
+    }
+
+    /**
+     * Returns the directory where all sink test output will go.
+     * @return The test output directory.
+     */
+    protected String getOutputDir()
+    {
+        return "sink/";
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Abstract methods the individual SinkTests must provide
+    // ----------------------------------------------------------------------
+
+    /**
+     * Return a new instance of the sink that is being tested.
+     * @param writer The writer for the sink.
+     * @return A new sink.
+     */
+    protected abstract Sink createSink( Writer writer );
+
+    /**
+     * Returns a title block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a title block on the current sink.
+     * @see #testTitle()
+     */
+    protected abstract String getTitleBlock( String title );
+
+    /**
+     * Returns an author block generated by this sink.
+     * @param author The author to use.
+     * @return The result of invoking an author block on the current sink.
+     * @see #testAuthor()
+     */
+    protected abstract String getAuthorBlock( String author );
+
+    /**
+     * Returns a date block generated by this sink.
+     * @param date The date to use.
+     * @return The result of invoking a date block on the current sink.
+     * @see #testDate()
+     */
+    protected abstract String getDateBlock( String date );
+
+    /**
+     * Returns a head block generated by this sink.
+     * @return The result of invoking a head block on the current sink.
+     * @see #testHead()
+     */
+    protected abstract String getHeadBlock();
+
+    /**
+     * Returns a body block generated by this sink.
+     * @return The result of invoking a body block on the current sink.
+     * @see #testBody()
+     */
+    protected abstract String getBodyBlock();
+
+    /**
+     * Returns a SectionTitle block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a SectionTitle block on the current sink.
+     * @see #testSectionTitle()
+     */
+    protected abstract String getSectionTitleBlock( String title );
+
+    /**
+     * Returns a Section1 block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a Section1 block on the current sink.
+     * @see #testSection1()
+     */
+    protected abstract String getSection1Block( String title );
+
+    /**
+     * Returns a Section2 block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a Section2 block on the current sink.
+     * @see #testSection2()
+     */
+    protected abstract String getSection2Block( String title );
+
+    /**
+     * Returns a Section3 block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a Section3 block on the current sink.
+     * @see #testSection3()
+     */
+    protected abstract String getSection3Block( String title );
+
+    /**
+     * Returns a Section4 block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a Section4 block on the current sink.
+     * @see #testSection4()
+     */
+    protected abstract String getSection4Block( String title );
+
+    /**
+     * Returns a Section5 block generated by this sink.
+     * @param title The title to use.
+     * @return The result of invoking a Section5 block on the current sink.
+     * @see #testSection5()
+     */
+    protected abstract String getSection5Block( String title );
+
+    /**
+     * Returns a list block generated by this sink.
+     * @param item The item to use.
+     * @return The result of invoking a list block on the current sink.
+     * @see #testList()
+     */
+    protected abstract String getListBlock( String item );
+
+    /**
+     * Returns a NumberedList block generated by this sink.
+     * @param item The item to use.
+     * @return The result of invoking a NumberedList block on the current sink.
+     * @see #testNumberedList()
+     */
+    protected abstract String getNumberedListBlock( String item );
+
+    /**
+     * Returns a DefinitionList block generated by this sink.
+     * @param definum The term to define.
+     * @param definition The definition.
+     * @return The result of invoking a DefinitionList block on the current sink.
+     * @see #testDefinitionList()
+     */
+    protected abstract String getDefinitionListBlock( String definum,
+        String definition );
+
+    /**
+     * Returns a Figure block generated by this sink.
+     * @param source The figure source string.
+     * @param caption The caption to use (may be null).
+     * @return The result of invoking a Figure block on the current sink.
+     * @see #testFigure()
+     */
+    protected abstract String getFigureBlock( String source, String caption );
+
+    /**
+     * Returns a Table block generated by this sink.
+     * @param cell A tabel cell to use.
+     * @param caption The caption to use (may be null).
+     * @return The result of invoking a Table block on the current sink.
+     * @see #testTable()
+     */
+    protected abstract String getTableBlock( String cell, String caption );
+
+    /**
+     * Returns a Paragraph block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a Paragraph block on the current sink.
+     * @see #testParagraph()
+     */
+    protected abstract String getParagraphBlock( String text );
+
+    /**
+     * Returns a Verbatim block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a Verbatim block on the current sink.
+     * @see #testVerbatim()
+     */
+    protected abstract String getVerbatimBlock( String text );
+
+    /**
+     * Returns a HorizontalRule block generated by this sink.
+     * @return The result of invoking a HorizontalRule block on the current sink.
+     * @see #testHorizontalRule()
+     */
+    protected abstract String getHorizontalRuleBlock();
+
+    /**
+     * Returns a PageBreak block generated by this sink.
+     * @return The result of invoking a PageBreak block on the current sink.
+     * @see #testPageBreak()
+     */
+    protected abstract String getPageBreakBlock();
+
+    /**
+     * Returns a Anchor block generated by this sink.
+     * @param anchor The anchor to use.
+     * @return The result of invoking a Anchor block on the current sink.
+     * @see #testAnchor()
+     */
+    protected abstract String getAnchorBlock( String anchor );
+
+    /**
+     * Returns a Link block generated by this sink.
+     * @param link The link to use.
+     * @param text The link text.
+     * @return The result of invoking a Link block on the current sink.
+     * @see #testLink()
+     */
+    protected abstract String getLinkBlock( String link, String text );
+
+    /**
+     * Returns a Italic block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a Italic block on the current sink.
+     * @see #testItalic()
+     */
+    protected abstract String getItalicBlock( String text );
+
+    /**
+     * Returns a Bold block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a Bold block on the current sink.
+     * @see #testBold()
+     */
+    protected abstract String getBoldBlock( String text );
+
+    /**
+     * Returns a Monospaced block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a Monospaced block on the current sink.
+     * @see #testMonospaced()
+     */
+    protected abstract String getMonospacedBlock( String text );
+
+    /**
+     * Returns a LineBreak block generated by this sink.
+     * @return The result of invoking a LineBreak block on the current sink.
+     * @see #testLineBreak()
+     */
+    protected abstract String getLineBreakBlock();
+
+    /**
+     * Returns a NonBreakingSpace block generated by this sink.
+     * @return The result of invoking a NonBreakingSpace block 
+     * on the current sink.
+     * @see #testNonBreakingSpace()
+     */
+    protected abstract String getNonBreakingSpaceBlock();
+
+    /**
+     * Returns a Text block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a Text block on the current sink.
+     * @see #testText()
+     */
+    protected abstract String getTextBlock( String text );
+
+    /**
+     * Returns a RawText block generated by this sink.
+     * @param text The text to use.
+     * @return The result of invoking a RawText block on the current sink.
+     * @see #testRawText()
+     */
+    protected abstract String getRawTextBlock( String text );
+
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java?view=auto&rev=559622
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java Wed Jul 25 14:43:30 2007
@@ -0,0 +1,605 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+
+/**
+ * Static methods to generate standard Doxia sink events.
+ */
+public class SinkTestDocument
+{
+
+    /** Private constructor. */
+    private SinkTestDocument()
+    {
+        // do not instantiate
+    }
+
+    /**
+     * Dumps a full model that mimics aptconvert's test.apt,
+     * into the specified sink. The sink is closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generate( Sink sink )
+    {
+        generateHead( sink );
+
+        sink.body();
+
+        // TODO: what is this supposed to do?
+        //sink.sectionTitle();
+        //sink.text( "Section Title" );
+        //sink.sectionTitle_();
+
+        sink.paragraph();
+        sink.text( "Paragraph 1, line 1. " );
+        sink.text( "Paragraph 1, line 2." );
+        sink.paragraph_();
+
+        sink.paragraph();
+        sink.text( "Paragraph 2, line 1. " );
+        sink.text( "Paragraph 2, line 2." );
+        sink.paragraph_();
+
+        sink.section1();
+        sink.sectionTitle1();
+        sink.text( "Section title" );
+        sink.sectionTitle1_();
+
+        sink.section2();
+        sink.sectionTitle2();
+        sink.text( "Sub-section title" );
+        sink.sectionTitle2_();
+
+        sink.section3();
+        sink.sectionTitle3();
+        sink.text( "Sub-sub-section title" );
+        sink.sectionTitle3_();
+
+        sink.section4();
+        sink.sectionTitle4();
+        sink.text( "Sub-sub-sub-section title" );
+        sink.sectionTitle4_();
+
+        sink.section5();
+        sink.sectionTitle5();
+        sink.text( "Sub-sub-sub-sub-section title" );
+        sink.sectionTitle5_();
+
+        generateList( sink );
+
+        sink.verbatim( true );
+        sink.text( "Verbatim text not contained in list item 3" );
+        sink.verbatim_();
+
+        generateNumberedList( sink );
+
+        sink.paragraph();
+        sink.text( "List numbering schemes: [[1]], [[a]], [[A]], [[i]], [[I]]." );
+        sink.paragraph_();
+
+        generateDefinitionList( sink );
+
+        sink.paragraph();
+        sink.text( "--- instead of +-- suppresses the box around verbatim text." );
+        sink.paragraph_();
+
+        generateFigure( sink );
+
+        generateTable( sink );
+
+        sink.paragraph();
+        sink.text( "No grid, no caption:" );
+        sink.paragraph_();
+
+        generateNoGridTable( sink );
+
+        generateHeaderTable( sink );
+
+        generateHorizontalRule( sink );
+
+        generatePageBreak( sink );
+
+        generateFonts( sink );
+
+        generateAnchors( sink );
+
+        generateLineBreak( sink );
+
+        generateNonBreakingSpace( sink );
+
+        generateSpecialCharacters( sink );
+
+        sink.section5_();
+        sink.section4_();
+        sink.section3_();
+        sink.section2_();
+        sink.section1_();
+
+        sink.body_();
+
+        sink.flush();
+        sink.close();
+    }
+
+    /**
+     * Dumps a header with title, author and date elements
+     * into the specified sink. The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateHead( Sink sink )
+    {
+        sink.head();
+
+        sink.title();
+        sink.text( "Title" );
+        sink.title_();
+
+        sink.author();
+        sink.text( "Author" );
+        sink.author_();
+
+        sink.date();
+        sink.text( "Date" );
+        sink.date_();
+
+        sink.head_();
+    }
+
+    /**
+     * Dumps a list into the specified sink. The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateList( Sink sink )
+    {
+        sink.list();
+
+        sink.listItem();
+        sink.paragraph();
+        sink.text( "List item 1." );
+        sink.paragraph_();
+        sink.listItem_();
+
+        sink.listItem();
+        sink.paragraph();
+        sink.text( "List item 2." );
+        sink.paragraph_();
+        sink.paragraph();
+        sink.text( "Paragraph contained in list item 2." );
+        sink.paragraph_();
+
+        sink.list();
+
+        sink.listItem();
+        sink.paragraph();
+        sink.text( "Sub-list item 1." );
+        sink.paragraph_();
+        sink.listItem_();
+
+        sink.listItem();
+        sink.paragraph();
+        sink.text( "Sub-list item 2." );
+        sink.paragraph_();
+        sink.listItem_();
+
+        sink.list_();
+
+        sink.listItem_();
+
+        sink.listItem();
+        sink.paragraph();
+        sink.text( "List item 3. " );
+        sink.text( "Force end of list:" );
+        sink.paragraph_();
+        sink.listItem_();
+
+        sink.list_();
+    }
+
+    /**
+     * Dumps a numbered list into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateNumberedList( Sink sink )
+    {
+        sink.numberedList( Sink.NUMBERING_DECIMAL );
+
+        sink.numberedListItem();
+        sink.paragraph();
+        sink.text( "Numbered item 1." );
+        sink.paragraph_();
+
+        sink.numberedList( Sink.NUMBERING_UPPER_ALPHA );
+
+        sink.numberedListItem();
+        sink.paragraph();
+        sink.text( "Numbered item A." );
+        sink.paragraph_();
+        sink.numberedListItem_();
+
+        sink.numberedListItem();
+        sink.paragraph();
+        sink.text( "Numbered item B." );
+        sink.paragraph_();
+        sink.numberedListItem_();
+
+        sink.numberedList_();
+
+        sink.numberedListItem_();
+
+        sink.numberedListItem();
+        sink.paragraph();
+        sink.text( "Numbered item 2." );
+        sink.paragraph_();
+        sink.numberedListItem_();
+
+        sink.numberedList_();
+    }
+
+    /**
+     * Dumps a definition list into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateDefinitionList( Sink sink )
+    {
+        sink.definitionList();
+
+        sink.definitionListItem();
+        sink.definedTerm();
+        sink.text( "Defined term 1" );
+        sink.definedTerm_();
+        sink.definition();
+        sink.paragraph();
+        sink.text( "of definition list." );
+        sink.paragraph_();
+        sink.definition_();
+        sink.definitionListItem_();
+
+        sink.definitionListItem();
+        sink.definedTerm();
+        sink.text( "Defined term 2" );
+        sink.definedTerm_();
+        sink.definition();
+        sink.paragraph();
+        sink.text( "of definition list." );
+        sink.paragraph_();
+        sink.verbatim( true );
+        sink.text( "Verbatim text\n                        in a box        " );
+        sink.verbatim_();
+        sink.definition_();
+        sink.definitionListItem_();
+
+        sink.definitionList_();
+    }
+
+    /**
+     * Dumps a figure with figure caption into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateFigure( Sink sink )
+    {
+        sink.figure();
+
+        sink.figureGraphics( "figure" );
+
+        sink.figureCaption();
+        sink.text( "Figure caption" );
+        sink.figureCaption_();
+
+        sink.figure_();
+    }
+
+    /**
+     * Dumps a table with grid and caption into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateTable( Sink sink )
+    {
+        int[] justify =
+        {
+             Parser.JUSTIFY_CENTER, Parser.JUSTIFY_LEFT, Parser.JUSTIFY_RIGHT
+        };
+
+        sink.table();
+
+        sink.tableRows( justify, true );
+
+        sink.tableRow();
+        sink.tableCell();
+        sink.text( "Centered" );
+        sink.lineBreak();
+        sink.text( "cell 1,1" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "Left-aligned" );
+        sink.lineBreak();
+        sink.text( "cell 1,2" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "Right-aligned" );
+        sink.lineBreak();
+        sink.text( "cell 1,3" );
+        sink.table_();
+        sink.tableRow_();
+
+        sink.tableRow();
+        sink.tableCell();
+        sink.text( "cell 2,1" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "cell 2,2" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "cell 2,3" );
+        sink.tableCell_();
+        sink.tableRow_();
+
+        sink.tableRows_();
+
+        sink.tableCaption();
+        sink.text( "Table caption" );
+        sink.tableCaption_();
+
+        sink.table_();
+    }
+
+    /**
+     * Dumps a table without grid into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateNoGridTable( Sink sink )
+    {
+        int[] justify =
+        {
+             Parser.JUSTIFY_CENTER, Parser.JUSTIFY_CENTER
+        };
+
+        sink.table();
+
+        sink.tableRows( justify, false );
+
+        sink.tableRow();
+        sink.tableCell();
+        sink.text( "cell" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "cell" );
+        sink.tableCell_();
+        sink.tableRow_();
+
+        sink.tableRow();
+        sink.tableCell();
+        sink.text( "cell" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "cell" );
+        sink.tableCell_();
+        sink.tableRow_();
+
+        sink.tableRows_();
+
+        sink.table_();
+    }
+
+    /**
+     * Dumps a table with a header row into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateHeaderTable( Sink sink )
+    {
+        int[] justify =
+        {
+             Parser.JUSTIFY_CENTER, Parser.JUSTIFY_CENTER
+        };
+
+        sink.table();
+
+        sink.tableRows( justify, true );
+
+        sink.tableRow();
+        sink.tableHeaderCell();
+        sink.text( "header" );
+        sink.tableHeaderCell_();
+        sink.tableHeaderCell();
+        sink.text( "header" );
+        sink.tableHeaderCell_();
+        sink.tableRow_();
+
+        sink.tableRow();
+        sink.tableCell();
+        sink.text( "cell" );
+        sink.tableCell_();
+        sink.tableCell();
+        sink.text( "cell" );
+        sink.tableCell_();
+        sink.tableRow_();
+
+        sink.tableRows_();
+
+        sink.table_();
+    }
+
+
+
+    /**
+     * Dumps a paragraph with italic, bold and monospaced text
+     * into the specified sink. The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateFonts( Sink sink )
+    {
+        sink.paragraph();
+
+        sink.italic();
+        sink.text( "Italic" );
+        sink.italic_();
+        sink.text( " font. " );
+
+        sink.bold();
+        sink.text( "Bold" );
+        sink.bold_();
+        sink.text( " font. " );
+
+        sink.monospaced();
+        sink.text( "Monospaced" );
+        sink.monospaced_();
+        sink.text( " font." );
+
+        sink.paragraph_();
+    }
+
+    /**
+     * Dumps a paragraph with anchor and link elements
+     * into the specified sink. The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateAnchors( Sink sink )
+    {
+        sink.paragraph();
+
+        sink.anchor( "Anchor" );
+        sink.text( "Anchor" );
+        sink.anchor_();
+
+        sink.text( ". Link to " );
+        sink.link( "Anchor" );
+        sink.text( "Anchor" );
+        sink.link_();
+
+        sink.text( ". Link to " );
+        sink.link( "http://www.pixware.fr" );
+        sink.text( "http://www.pixware.fr" );
+        sink.link_();
+
+        sink.text( ". Link to " );
+        sink.link( "Anchor" );
+        sink.text( "showing alternate text" );
+        sink.link_();
+
+        sink.text( ". Link to " );
+        sink.link( "http://www.pixware.fr" );
+        sink.text( "Pixware home page" );
+        sink.link_();
+
+        sink.text( "." );
+
+        sink.paragraph_();
+    }
+
+    /**
+     * Dumps a horizontal rule block into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateHorizontalRule( Sink sink )
+    {
+        sink.paragraph();
+        sink.text( "Horizontal line:" );
+        sink.paragraph_();
+        sink.horizontalRule();
+    }
+
+    /**
+     * Dumps a pageBreak block into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generatePageBreak( Sink sink )
+    {
+        sink.pageBreak();
+        sink.paragraph();
+        sink.text( "New page." );
+        sink.paragraph_();
+    }
+
+    /**
+     * Dumps a lineBreak block into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateLineBreak( Sink sink )
+    {
+        sink.paragraph();
+        sink.text( "Force line" );
+        sink.lineBreak();
+        sink.text( "break." );
+        sink.paragraph_();
+    }
+
+    /**
+     * Dumps a nonBreakingSpace block into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateNonBreakingSpace( Sink sink )
+    {
+        sink.paragraph();
+        sink.text( "Non" );
+        sink.nonBreakingSpace();
+        sink.text( "breaking" );
+        sink.nonBreakingSpace();
+        sink.text( "space." );
+        sink.paragraph_();
+    }
+
+    /**
+     * Dumps a special character block into the specified sink.
+     * The sink is not flushed or closed.
+     *
+     * @param sink The sink to receive the events.
+     */
+    public static void generateSpecialCharacters( Sink sink )
+    {
+        sink.paragraph();
+        sink.text( "Escaped special characters: " );
+        sink.text( "~, =, -, +, *, [, ], <, >, {, }, \\." );
+        sink.paragraph_();
+
+        sink.paragraph();
+        String copyright = String.valueOf( '\u00a9' );
+        sink.text( "Copyright symbol: " + copyright + ", "
+            + copyright + ", " + copyright + "." );
+        sink.paragraph_();
+    }
+
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkTestDocument.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java?view=auto&rev=559622
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java Wed Jul 25 14:43:30 2007
@@ -0,0 +1,626 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A simple text-based implementation of the <code>Sink</code> interface.
+ * Useful for testing purposes.
+ */
+public class TextSink
+    implements Sink
+{
+
+    /** System-dependent end-of-line string. */
+    private static final String EOL = System.getProperty( "line.separator" );
+
+    /** For writing the result. */
+    private final Writer out;
+
+    /** Constructor.
+     * @param writer The writer for writing the result.
+     */
+    public TextSink( Writer writer )
+    {
+        this.out = writer;
+    }
+
+
+    /** {@inheritDoc} */
+    public void head()
+    {
+        writeln( "begin:head" );
+    }
+
+    /** {@inheritDoc} */
+    public void head_()
+    {
+        writeln( "end:head" );
+    }
+
+    /** {@inheritDoc} */
+    public void body()
+    {
+        writeln( "begin:body" );
+    }
+
+    /** {@inheritDoc} */
+    public void body_()
+    {
+        writeln( "end:body" );
+    }
+
+    /** {@inheritDoc} */
+    public void section1()
+    {
+        write( "begin:section1" );
+    }
+
+    /** {@inheritDoc} */
+    public void section1_()
+    {
+        writeln( "end:section1" );
+    }
+
+    /** {@inheritDoc} */
+    public void section2()
+    {
+        write( "begin:section2" );
+    }
+
+    /** {@inheritDoc} */
+    public void section2_()
+    {
+        writeln( "end:section2" );
+    }
+
+    /** {@inheritDoc} */
+    public void section3()
+    {
+        write( "begin:section3" );
+    }
+
+    /** {@inheritDoc} */
+    public void section3_()
+    {
+        writeln( "end:section3" );
+    }
+
+    /** {@inheritDoc} */
+    public void section4()
+    {
+        write( "begin:section4" );
+    }
+
+    /** {@inheritDoc} */
+    public void section4_()
+    {
+        writeln( "end:section4" );
+    }
+
+    /** {@inheritDoc} */
+    public void section5()
+    {
+        write( "begin:section5" );
+    }
+
+    /** {@inheritDoc} */
+    public void section5_()
+    {
+        writeln( "end:section5" );
+    }
+
+    /** {@inheritDoc} */
+    public void list()
+    {
+        writeln( "begin:list" );
+    }
+
+    /** {@inheritDoc} */
+    public void list_()
+    {
+        writeln( "end:list" );
+    }
+
+    /** {@inheritDoc} */
+    public void listItem()
+    {
+        write( "begin:listItem" );
+    }
+
+    /** {@inheritDoc} */
+    public void listItem_()
+    {
+        writeln( "end:listItem" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList( int numbering )
+    {
+        writeln( "begin:numberedList, numbering: " + numbering );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedList_()
+    {
+        writeln( "end:numberedList" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedListItem()
+    {
+        write( "begin:numberedListItem" );
+    }
+
+    /** {@inheritDoc} */
+    public void numberedListItem_()
+    {
+        writeln( "end:numberedListItem" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionList()
+    {
+        writeln( "begin:definitionList" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionList_()
+    {
+        writeln( "end:definitionList" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionListItem()
+    {
+        write( "begin:definitionListItem" );
+    }
+
+    /** {@inheritDoc} */
+    public void definitionListItem_()
+    {
+        writeln( "end:definitionListItem" );
+    }
+
+    /** {@inheritDoc} */
+    public void definition()
+    {
+        write( "begin:definition" );
+    }
+
+    /** {@inheritDoc} */
+    public void definition_()
+    {
+        writeln( "end:definition" );
+    }
+
+    /** {@inheritDoc} */
+    public void figure()
+    {
+        write( "begin:figure" );
+    }
+
+    /** {@inheritDoc} */
+    public void figure_()
+    {
+        writeln( "end:figure" );
+    }
+
+    /** {@inheritDoc} */
+    public void table()
+    {
+        writeln( "begin:table" );
+    }
+
+    /** {@inheritDoc} */
+    public void table_()
+    {
+        writeln( "end:table" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRows( int[] justification, boolean grid )
+    {
+        writeln( "begin:tableRows" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRows_()
+    {
+        writeln( "end:tableRows" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow()
+    {
+        write( "begin:tableRow" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableRow_()
+    {
+        writeln( "end:tableRow" );
+    }
+
+    /** {@inheritDoc} */
+    public void title()
+    {
+        write( "begin:title" );
+    }
+
+    /** {@inheritDoc} */
+    public void title_()
+    {
+        writeln( "end:title" );
+    }
+
+    /** {@inheritDoc} */
+    public void author()
+    {
+        write( "begin:author" );
+    }
+
+    /** {@inheritDoc} */
+    public void author_()
+    {
+        writeln( "end:author" );
+    }
+
+    /** {@inheritDoc} */
+    public void date()
+    {
+        write( "begin:date" );
+    }
+
+    /** {@inheritDoc} */
+    public void date_()
+    {
+        writeln( "end:date" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle()
+    {
+        write( "begin:sectionTitle" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle_()
+    {
+        writeln( "end:sectionTitle" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle1()
+    {
+        write( "begin:sectionTitle1" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle1_()
+    {
+        writeln( "end:sectionTitle1" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle2()
+    {
+        write( "begin:sectionTitle2" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle2_()
+    {
+        writeln( "end:sectionTitle2" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle3()
+    {
+        write( "begin:sectionTitle3" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle3_()
+    {
+        writeln( "end:sectionTitle3" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle4()
+    {
+        write( "begin:sectionTitle4" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle4_()
+    {
+        writeln( "end:sectionTitle4" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle5()
+    {
+        write( "begin:sectionTitle5" );
+    }
+
+    /** {@inheritDoc} */
+    public void sectionTitle5_()
+    {
+        writeln( "end:sectionTitle5" );
+    }
+
+    /** {@inheritDoc} */
+    public void paragraph()
+    {
+        write( "begin:paragraph" );
+    }
+
+    /** {@inheritDoc} */
+    public void paragraph_()
+    {
+        writeln( "end:paragraph" );
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim( boolean boxed )
+    {
+        write( "begin:verbatim, boxed: " + boxed );
+    }
+
+    /** {@inheritDoc} */
+    public void verbatim_()
+    {
+        writeln( "end:verbatim" );
+    }
+
+    /** {@inheritDoc} */
+    public void definedTerm()
+    {
+        write( "begin:definedTerm" );
+    }
+
+    /** {@inheritDoc} */
+    public void definedTerm_()
+    {
+        writeln( "end:definedTerm" );
+    }
+
+    /** {@inheritDoc} */
+    public void figureCaption()
+    {
+        write( "begin:figureCaption" );
+    }
+
+    /** {@inheritDoc} */
+    public void figureCaption_()
+    {
+        writeln( "end:figureCaption" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell()
+    {
+        write( "begin:tableCell" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell( String width )
+    {
+        write( "begin:tableCell, width: " + width );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCell_()
+    {
+        writeln( "end:tableCell" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell()
+    {
+        write( "begin:tableHeaderCell" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell( String width )
+    {
+        write( "begin:tableHeaderCell, width: " + width );
+    }
+
+    /** {@inheritDoc} */
+    public void tableHeaderCell_()
+    {
+        writeln( "end:tableHeaderCell" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCaption()
+    {
+        write( "begin:tableCaption" );
+    }
+
+    /** {@inheritDoc} */
+    public void tableCaption_()
+    {
+        writeln( "end:tableCaption" );
+    }
+
+    /** {@inheritDoc} */
+    public void figureGraphics( String name )
+    {
+        write( "figureGraphics, name: " + name );
+    }
+
+    /** {@inheritDoc} */
+    public void horizontalRule()
+    {
+        write( "horizontalRule" );
+    }
+
+    /** {@inheritDoc} */
+    public void pageBreak()
+    {
+        write( "pageBreak" );
+    }
+
+    /** {@inheritDoc} */
+    public void anchor( String name )
+    {
+        write( "begin:anchor, name: " + name  );
+    }
+
+    /** {@inheritDoc} */
+    public void anchor_()
+    {
+        writeln( "end:anchor" );
+    }
+
+    /** {@inheritDoc} */
+    public void link( String name )
+    {
+        write( "begin:link, name: " + name  );
+    }
+
+    /** {@inheritDoc} */
+    public void link_()
+    {
+        writeln( "end:link" );
+    }
+
+    /** {@inheritDoc} */
+    public void italic()
+    {
+        write( "begin:italic" );
+    }
+
+    /** {@inheritDoc} */
+    public void italic_()
+    {
+        writeln( "end:italic" );
+    }
+
+    /** {@inheritDoc} */
+    public void bold()
+    {
+        write( "begin:bold" );
+    }
+
+    /** {@inheritDoc} */
+    public void bold_()
+    {
+        writeln( "end:bold" );
+    }
+
+    /** {@inheritDoc} */
+    public void monospaced()
+    {
+        write( "begin:monospaced" );
+    }
+
+    /** {@inheritDoc} */
+    public void monospaced_()
+    {
+        writeln( "end:monospaced" );
+    }
+
+    /** {@inheritDoc} */
+    public void lineBreak()
+    {
+        write( "lineBreak" );
+    }
+
+    /** {@inheritDoc} */
+    public void nonBreakingSpace()
+    {
+        write( "nonBreakingSpace" );
+    }
+
+    /** {@inheritDoc} */
+    public void text( String text )
+    {
+        write( "text: " + text );
+    }
+
+    /** {@inheritDoc} */
+    public void rawText( String text )
+    {
+        write( "rawText: " + text );
+    }
+
+    /** {@inheritDoc} */
+    public void flush()
+    {
+        try
+        {
+            out.flush();
+        }
+        catch ( IOException e )
+        {
+            // TODO: log
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void close()
+    {
+        try
+        {
+            out.close();
+        }
+        catch ( IOException e )
+        {
+            // TODO: log
+        }
+    }
+
+
+    /**
+     * Writes the given string + EOL.
+     *
+     * @param text The text to write.
+     */
+    private void write( String text )
+    {
+        try
+        {
+            out.write( text + EOL );
+        }
+        catch ( IOException e )
+        {
+            // TODO: log
+        }
+    }
+
+    /**
+     * Writes the given string + two EOLs.
+     *
+     * @param text The text to write.
+     */
+    private void writeln( String text )
+    {
+        write( text );
+        write( EOL );
+    }
+
+
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"