Added: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java?rev=349238&view=auto
==============================================================================
--- 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
 (added)
+++ 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
 Sun Nov 27 06:43:10 2005
@@ -0,0 +1,200 @@
+/*
+ *  Copyright 2005 Zauber <info /at/ zauber dot com dot ar>
+ *
+ *  Licensed 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.
+ */
+package org.apache.maven.doxia.module.twiki.parser;
+
+import java.io.StringReader;
+import java.util.Arrays;
+
+import org.apache.maven.doxia.module.common.ByLineReaderSource;
+import org.apache.maven.doxia.parser.ParseException;
+
+
+/**
+ * Tests the [EMAIL PROTECTED] 
org.apache.maven.doxia.module.twiki.parser.ParagraphBlockParser}
+ *
+ * @author Juan F. Codagnone
+ * @since Nov 1, 2005
+ */
+public class ParagraphTest extends AbstractBlockTestCase
+{
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testMultiLines() throws ParseException
+    {
+        final String text = ""
+            + "\n\n\n"
+            + "para1 -> text1\n"
+            + "para1 -> text2\n"
+            + "\n"
+            + "para2 -> text1\n"
+            + "para2 -> text2\n"
+            + "   \n   \n  "
+            + "para2 -> text1\n"
+            + "para2 -> text2\n";
+
+        final ByLineReaderSource source = new ByLineReaderSource(
+            new StringReader( text ) );
+        final ParagraphBlockParser parser = paraParser;
+
+        ParagraphBlock block;
+
+        block = (ParagraphBlock) parser.visit( source
+            .getNextLine(), source );
+        assertNotNull( block );
+        assertEquals( 1, block.getBlocks().length );
+        assertEquals( "para1 -> text1 para1 -> text2", ( (TextBlock) block
+            .getBlocks()[0] ).getText() );
+
+        block = (ParagraphBlock) parser.visit( source
+            .getNextLine(), source );
+        assertNotNull( block );
+        assertEquals( 1, block.getBlocks().length );
+        assertEquals( "para2 -> text1 para2 -> text2", ( (TextBlock) block
+            .getBlocks()[0] ).getText() );
+    }
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testParagraphWithList() throws ParseException
+    {
+        final String text = ""
+            + "Description text:\n"
+            + "   * item1\n"
+            + "   * item2\n"
+            + "This is more text in the same paragraph\n"
+            + "\n"
+            + "Another paragraph";
+
+        final ByLineReaderSource source = new ByLineReaderSource(
+            new StringReader( text ) );
+        final ParagraphBlockParser parser = paraParser;
+
+        ParagraphBlock block;
+
+        block = (ParagraphBlock) parser.visit( source
+            .getNextLine(), source );
+        assertNotNull( block );
+        final Block[] firstLevelChilds = block.getBlocks();
+        final int numberOfChilds = 3;
+        assertEquals( numberOfChilds, firstLevelChilds.length );
+        assertEquals( TextBlock.class, firstLevelChilds[0].getClass() );
+        assertEquals( UnorderedListBlock.class,
+                      firstLevelChilds[1].getClass() );
+        assertEquals( TextBlock.class, firstLevelChilds[2].getClass() );
+
+        final Block [] listChilds = ( (UnorderedListBlock) firstLevelChilds[1] 
)
+            .getBlocks();
+        assertEquals( 2, listChilds.length );
+        assertEquals( 1, ( (ListItemBlock) listChilds[0] ).getBlocks().length 
);
+        assertEquals( "item1", ( (TextBlock) ( (ListItemBlock) listChilds[0] )
+            .getBlocks()[0] ).getText() );
+        assertEquals( "item2", ( (TextBlock) ( (ListItemBlock) listChilds[1] )
+            .getBlocks()[0] ).getText() );
+    }
+
+    /**
+     * tests some valid weired lists
+     *
+     * @throws ParseException on error
+     */
+    public final void testParagraphWithStartingList() throws ParseException
+    {
+        final String text = ""
+            + "   * item1\n"
+            + "   * item2\n"
+            + "This is more text in the same paragraph\n"
+            + "\n"
+            + "Another paragraph";
+
+        final ByLineReaderSource source = new ByLineReaderSource(
+            new StringReader( text ) );
+        final ParagraphBlockParser parser = paraParser;
+
+        ParagraphBlock block;
+
+        block = (ParagraphBlock) parser.visit( source
+            .getNextLine(), source );
+        assertNotNull( block );
+        final Block[] firstLevelChilds = block.getBlocks();
+        assertEquals( 2, firstLevelChilds.length );
+        assertEquals( UnorderedListBlock.class,
+                      firstLevelChilds[0].getClass() );
+        assertEquals( TextBlock.class, firstLevelChilds[1].getClass() );
+
+        final Block [] listChilds = ( (UnorderedListBlock) firstLevelChilds[0] 
)
+            .getBlocks();
+        assertEquals( 2, listChilds.length );
+        assertEquals( 1, ( (ListItemBlock) listChilds[0] ).getBlocks().length 
);
+        assertEquals( "item1", ( (TextBlock) ( (ListItemBlock) listChilds[0] )
+            .getBlocks()[0] ).getText() );
+        assertEquals( "item2", ( (TextBlock) ( (ListItemBlock) listChilds[1] )
+            .getBlocks()[0] ).getText() );
+    }
+
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testHorizontalRule() throws ParseException
+    {
+        Block block, expected;
+        ByLineReaderSource source;
+
+        assertTrue( hruleParser.accept( "---" ) );
+        assertFalse( hruleParser.accept( "---+ asdas" ) );
+
+        source = new ByLineReaderSource( new StringReader( "" ) );
+        expected = new HorizontalRuleBlock();
+        block = hruleParser.visit( "---", source );
+        assertNull( source.getNextLine() );
+        assertEquals( expected, block );
+
+        source = new ByLineReaderSource( new StringReader( "" ) );
+        expected = new HorizontalRuleBlock();
+        block = hruleParser.visit( "--- Some text ---- And some more", source 
);
+        assertEquals( expected, block );
+        expected = new ParagraphBlock( new Block[]{
+            new TextBlock( "Some text ---- And some more" )
+        } );
+        block = paraParser.visit( source.getNextLine(), source );
+        assertEquals( expected, block );
+    }
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testHorizontalRuleAndParagraph() throws ParseException
+    {
+        Block[] blocks, expected;
+        ByLineReaderSource source;
+
+        source = new ByLineReaderSource( new StringReader( ""
+            + "Some text\n"
+            + "-----------\n"
+            + "More text"
+        ) );
+        expected = new Block[]{
+            new ParagraphBlock( new Block[]{new TextBlock( "Some text" )} ),
+            new HorizontalRuleBlock(),
+            new ParagraphBlock( new Block[]{new TextBlock( "More text" )} ),
+        };
+        blocks = twikiParser.parse( source ).toArray( new Block[]{} );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+}

Propchange: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java?rev=349238&view=auto
==============================================================================
--- 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
 (added)
+++ 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
 Sun Nov 27 06:43:10 2005
@@ -0,0 +1,187 @@
+/*
+ *  Copyright 2005 Zauber <info /at/ zauber dot com dot ar>
+ *
+ *  Licensed 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.
+ */
+package org.apache.maven.doxia.module.twiki.parser;
+
+import java.io.StringReader;
+import java.util.Arrays;
+
+import org.apache.maven.doxia.module.common.ByLineReaderSource;
+import org.apache.maven.doxia.parser.ParseException;
+
+
+/**
+ * Tests the [EMAIL PROTECTED] 
org.apache.maven.doxia.module.twiki.parser.SectionBlockParser}
+ *
+ * @author Juan F. Codagnone
+ * @since Nov 1, 2005
+ */
+public class SectionTest extends AbstractBlockTestCase
+{
+
+    /**
+     * @see SectionBlock#SectionBlock(String, int, Block[])
+     */
+    public final void testSectionBlockWrongArgs()
+    {
+        final int maxLevel = 5;
+        new SectionBlock( "hola", 1, new Block[]{} );
+        new SectionBlock( "hola", maxLevel, new Block[]{} );
+
+        try
+        {
+            new SectionBlock( "hola", maxLevel + 1, new Block[]{} );
+            fail();
+        }
+        catch ( final Throwable e )
+        {
+            // ok
+        }
+
+        try
+        {
+            new SectionBlock( "hola", 0, new Block[]{} );
+            fail();
+        }
+        catch ( final Throwable e )
+        {
+            // ok
+        }
+
+        try
+        {
+            new SectionBlock( null, 1, null );
+            fail();
+        }
+        catch ( final Throwable e )
+        {
+            // ok
+        }
+
+        new SectionBlock( "", 1, new Block[]{} );
+    }
+
+    /**
+     * @see SectionBlockParser#getLevel(String)
+     */
+    public final void testSectionParserGetLevel()
+    {
+        assertEquals( 2, SectionBlockParser.getLevel( "++" ) );
+        try
+        {
+            SectionBlockParser.getLevel( "asdasd" );
+            fail( "expected exception was not thrown" );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            // ok
+        }
+    }
+
+    /**
+     * @see SectionBlockParser
+     */
+    public final void testSectionParser() throws Exception
+    {
+        final SectionBlockParser parser = sectionParser;
+        assertTrue( parser.accept( "---+ Title1" ) );
+        assertTrue( parser.accept( "---++ Title2" ) );
+        assertFalse( parser.accept( " ---++ Title3" ) );
+        assertTrue( parser.accept( "---+++ Title4" ) );
+        assertTrue( parser.accept( "---++++ Title5" ) );
+        assertTrue( parser.accept( "---+++++ Title6" ) );
+
+        SectionBlock block;
+        block = (SectionBlock) parser.visit( "---++++ Title4",
+                                             new ByLineReaderSource( new 
StringReader( "" ) ) );
+
+        final int level = 4;
+        assertEquals( "Title4", block.getTitle() );
+        assertEquals( level, block.getLevel() );
+        assertEquals( 0, block.getBlocks().length );
+
+        // ejemplo un poco m�s complejo
+        block = (SectionBlock) parser.visit( "---+++ Title3",
+                                             new ByLineReaderSource( new 
StringReader(
+                                                 "This is *a* parragraph of a 
section.\n"
+                                                     + "Some text.\n"
+                                                     + "---+++ Another Title"
+                                                     + "... and more text" ) ) 
);
+        final SectionBlock expected = new SectionBlock( "Title3", 3, new 
Block[]{
+            new ParagraphBlock( new Block[]{
+                new TextBlock( "This is " ),
+                new BoldBlock( new Block[]{new TextBlock( "a" )} ),
+                new TextBlock( " parragraph of a section. Some text." ),
+            } )
+        } );
+        assertEquals( expected, block );
+    }
+
+    /**
+     * Test section with several paragraphs (the paragraph are plain text)
+     *
+     * @throws Exception on error
+     */
+    public final void testSectionWithParagraphs() throws Exception
+    {
+        final String text = ""
+            + "---++ Title\n"
+            + "\n"
+            + "hey!\n"
+            + "how are\n"
+            + "you?\n"
+            + "  \n  "
+            + "Fine!! thanks";
+
+        final SectionBlockParser parser = sectionParser;
+        final ByLineReaderSource source = new ByLineReaderSource(
+            new StringReader( text ) );
+        final SectionBlock block = (SectionBlock) parser.visit( source
+            .getNextLine(), source );
+        assertEquals( 2, block.getBlocks().length );
+        assertEquals( "hey! how are you?", ( (TextBlock) ( (ParagraphBlock) 
block
+            .getBlocks()[0] ).getBlocks()[0] ).getText() );
+        assertEquals( "Fine!! thanks", ( (TextBlock) ( (ParagraphBlock) block
+            .getBlocks()[1] ).getBlocks()[0] ).getText() );
+    }
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testSectionAndParaAndHrule() throws ParseException
+    {
+        Block[] blocks, expected;
+        ByLineReaderSource source;
+
+        source = new ByLineReaderSource( new StringReader( ""
+            + "---++ Title\n"
+            + "Some text\n"
+            + "----------- More text\n"
+        ) );
+        expected = new Block[]{
+            new SectionBlock( "Title", 1, new Block[]{
+                new ParagraphBlock( new Block[]{
+                    new TextBlock( "Some text" )
+                } ),
+                new HorizontalRuleBlock(),
+                new ParagraphBlock( new Block[]{
+                    new TextBlock( "More text" )
+                } ),
+            } ),
+        };
+        blocks = twikiParser.parse( source ).toArray( new Block[]{} );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+}

Propchange: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java?rev=349238&view=auto
==============================================================================
--- 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
 (added)
+++ 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
 Sun Nov 27 06:43:10 2005
@@ -0,0 +1,92 @@
+/*
+ *  Copyright 2005 Zauber <info /at/ zauber dot com dot ar>
+ *
+ *  Licensed 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.
+ */
+package org.apache.maven.doxia.module.twiki.parser;
+
+import java.io.StringReader;
+
+import org.apache.maven.doxia.module.common.ByLineReaderSource;
+import org.apache.maven.doxia.module.common.ByLineSource;
+import org.apache.maven.doxia.parser.ParseException;
+
+
+/**
+ * Tests the [EMAIL PROTECTED] 
org.apache.maven.doxia.module.twiki.parser.TableBlockParser}
+ *
+ * @author Juan F. Codagnone
+ * @since Nov 9, 2005
+ */
+public class TableTest extends AbstractBlockTestCase
+{
+
+    /**
+     * unit test the regex
+     */
+    public final void testRegex()
+    {
+        assertTrue( tableParser.accept( "  | cell1 | cell2|   " ) );
+        assertFalse( tableParser.accept( "  | cell1 | cell" ) );
+    }
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testTable() throws ParseException
+    {
+        final StringReader sw = new StringReader( ""
+            + "  |cell1|cell2|  \n"
+            + "|cell3|cell4|\n"
+        );
+
+        final ByLineSource source = new ByLineReaderSource( sw );
+
+        Block block, expected;
+        expected = new TableBlock( new Block[]{
+            new TableRowBlock( new Block[]{
+                new TableCellBlock( new Block[]{new TextBlock( "cell1" )} ),
+                new TableCellBlock( new Block[]{new TextBlock( "cell2" )} ),
+            } ),
+            new TableRowBlock( new Block[]{
+                new TableCellBlock( new Block[]{new TextBlock( "cell3" )} ),
+                new TableCellBlock( new Block[]{new TextBlock( "cell4" )} ),
+            } ),
+        } );
+
+        block = tableParser.visit( source.getNextLine(), source );
+        assertEquals( block, expected );
+    }
+
+    /**
+     * @throws ParseException on error
+     */
+    public final void testTableHeader() throws ParseException
+    {
+        final StringReader sw = new StringReader( "|*cell1*|*cell2*|\n"
+        );
+
+        final ByLineSource source = new ByLineReaderSource( sw );
+
+        Block block, expected;
+        expected = new TableBlock( new Block[]{
+            new TableRowBlock( new Block[]{
+                new TableCellHeaderBlock( new Block[]{new TextBlock( "cell1" 
)} ),
+                new TableCellHeaderBlock( new Block[]{new TextBlock( "cell2" 
)} ),
+            } ),
+        } );
+
+        block = tableParser.visit( source.getNextLine(), source );
+        assertEquals( block, expected );
+    }
+}

Propchange: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java?rev=349238&view=auto
==============================================================================
--- 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
 (added)
+++ 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
 Sun Nov 27 06:43:10 2005
@@ -0,0 +1,260 @@
+/*
+ *  Copyright 2005 Zauber <info /at/ zauber dot com dot ar>
+ *
+ *  Licensed 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.
+ */
+package org.apache.maven.doxia.module.twiki.parser;
+
+import java.util.Arrays;
+
+
+/**
+ * tests the WikiWord parsing (and things like that)
+ *
+ * @author Juan F. Codagnone
+ * @since Nov 4, 2005
+ */
+public class WordsTest extends AbstractBlockTestCase
+{
+    /**
+     * used to convert lists to arrays
+     */
+    private static final Block [] TOARRAY = new Block[]{};
+
+    /**
+     * ...
+     */
+    public final void testText()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{new TextBlock( "     Some text    " )};
+        blocks = textParser.parse( "     Some text    " ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ...
+     */
+    public final void testWikiWords()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{new WikiWordBlock( "WikiWord" )};
+        blocks = textParser.parse( "WikiWord" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        // this is not a wiki word
+        expected = new Block[]{new TextBlock( "Wiki" )};
+        blocks = textParser.parse( "Wiki" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{new TextBlock( "Web." )};
+        blocks = textParser.parse( "Web." ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{new TextBlock( "fooWikiBar" )};
+        blocks = textParser.parse( "fooWikiBar" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new WikiWordBlock( "WikiWord" ), new TextBlock( "...." )
+        };
+        blocks = textParser.parse( "WikiWord...." ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ...
+     */
+    public final void testWebWikiWords()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{new WikiWordBlock( "Web.WikiWord" )};
+        blocks = textParser.parse( "Web.WikiWord" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{new WikiWordBlock( "My1Web.WikiWord" )};
+        blocks = textParser.parse( "My1Web.WikiWord" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ...
+     */
+    public final void testWebAnchorWikiWords()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{new WikiWordBlock( "WikiWord#anchor" )};
+        blocks = textParser.parse( "WikiWord#anchor" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{new WikiWordBlock( "MyWeb.WikiWord#anchor" )};
+        blocks = textParser.parse( "MyWeb.WikiWord#anchor" ).toArray( TOARRAY 
);
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+    }
+
+    /**
+     * test Specific Links
+     */
+    public final void testSpecificLinks()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{new LinkBlock( "reference", "text" )};
+        blocks = textParser.parse( "[[reference][text]]" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new TextBlock( "foo" ),
+            new LinkBlock( "reference", "text" ),
+            new TextBlock( "bar" ),
+        };
+        blocks = textParser.parse( "foo[[reference][text]]bar" ).toArray( 
TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new TextBlock( " foo " ),
+            new LinkBlock( "reference", "text" ),
+            new TextBlock( " bar " ),
+        };
+        blocks = textParser.parse( " foo [[reference][text]] bar " )
+            .toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * test Specific Links
+     */
+    public final void testSpecificLinkPrevention()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{new TextBlock( "[[reference][text]]" )};
+        blocks = textParser.parse( "![[reference][text]]" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ...
+     */
+    public final void testPreventLinkingWikiWord()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{
+            new TextBlock( " " ),
+            new TextBlock( "WikiWord" ),
+            new TextBlock( " " ),
+        };
+        blocks = textParser.parse( " !WikiWord " ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{new TextBlock( " !!WikiWord " )};
+        blocks = textParser.parse( " !!WikiWord " ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ej [[Main.TWiki rules]] would be wikiword Main.TWikiRules
+     */
+    public final void testForcedLinks()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{
+            new WikiWordBlock( "WikiSyntax", "wiki syntax" ),
+        };
+        blocks = textParser.parse( "[[wiki syntax]]" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new TextBlock( "[[wiki syntax]]" ),
+        };
+        blocks = textParser.parse( "![[wiki syntax]]" ).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new TextBlock( "foo" ),
+            new WikiWordBlock( "WikiSyntax", "wiki syntax" ),
+            new TextBlock( "bar" ),
+        };
+        blocks = textParser.parse( "foo[[wiki syntax]]bar" ).toArray( TOARRAY 
);
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ...
+     */
+    public final void testMailtoForcedLinks()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{
+            new LinkBlock( "mailto:[EMAIL PROTECTED]", "Mail" ),
+        };
+        blocks = textParser.parse( "[[mailto:[EMAIL PROTECTED] Mail]]" 
).toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * ...
+     */
+    public final void testAnchors()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{
+            new TextBlock( "mary has #anchor a little lamb" ),
+        };
+        blocks = textParser.parse( "mary has #anchor a little lamb" ).toArray(
+            TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new TextBlock( "mary has " ),
+            new AnchorBlock( "AnchorName" ),
+            new TextBlock( " a little lamb" ),
+        };
+        blocks = textParser.parse( "mary has #AnchorName a little lamb" )
+            .toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+
+        expected = new Block[]{
+            new TextBlock( "mary has #AnchorName1233 a little lamb" ),
+        };
+        blocks = textParser.parse( "mary has #AnchorName1233 a little lamb" )
+            .toArray( TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+
+    /**
+     * unit test
+     */
+    public final void testAutomaticLink()
+    {
+        Block [] blocks, expected;
+
+        expected = new Block[]{
+            new TextBlock( "Go to " ),
+            new LinkBlock( "http://twiki.com";, "http://twiki.com"; ),
+            new TextBlock( " and ..." ),
+        };
+        blocks = textParser.parse( "Go to http://twiki.com and ..." ).toArray(
+            TOARRAY );
+        assertTrue( Arrays.equals( expected, blocks ) );
+    }
+}

Propchange: 
maven/doxia/trunk/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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


Reply via email to