Author: ltheussl
Date: Wed Jul 25 14:50:52 2007
New Revision: 559624

URL: http://svn.apache.org/viewvc?view=rev&rev=559624
Log:
Use the new test classes.

Added:
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptIdentityTest.java
   (with props)
Modified:
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java

Added: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptIdentityTest.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptIdentityTest.java?view=auto&rev=559624
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptIdentityTest.java
 (added)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptIdentityTest.java
 Wed Jul 25 14:50:52 2007
@@ -0,0 +1,46 @@
+package org.apache.maven.doxia.module.apt;
+
+/*
+ * 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.Writer;
+
+import org.apache.maven.doxia.module.AbstractIdentityTest;
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+
+
+/**
+ * Check that piping a full model through an AptParser and an AptSink
+ * leaves the model unchanged. The test is done in AbstractIdentityTest.
+ */
+public class AptIdentityTest extends AbstractIdentityTest
+{
+    /** [EMAIL PROTECTED] */
+    protected Sink createSink( Writer writer )
+    {
+        return new AptSink( writer );
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected Parser createParser()
+    {
+        return new AptParser();
+    }
+}

Propchange: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptIdentityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java?view=diff&rev=559624&r1=559623&r2=559624
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
 Wed Jul 25 14:50:52 2007
@@ -19,12 +19,15 @@
  * under the License.
  */
 
-import java.io.FileReader;
+import java.io.IOException;
 import java.io.Reader;
 import java.io.StringWriter;
+import java.io.Writer;
 
-import org.apache.maven.doxia.parser.AbstractParserTestCase;
+import org.apache.maven.doxia.parser.AbstractParserTest;
 import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.parser.ParseException;
+
 import org.apache.maven.doxia.sink.Sink;
 
 /**
@@ -32,7 +35,7 @@
  * @version $Id$
  */
 public class AptParserTest
-    extends AbstractParserTestCase
+    extends AbstractParserTest
 {
     private static final String EOL = System.getProperty( "line.separator" );
 
@@ -47,18 +50,12 @@
         parser = (AptParser) lookup( Parser.ROLE, "apt" );
     }
 
-    /** @see org.apache.maven.doxia.parser.AbstractParserTestCase#getParser() 
*/
-    protected Parser getParser()
+    /** @see org.apache.maven.doxia.parser.AbstractParserTest#createParser() */
+    protected Parser createParser()
     {
         return parser;
     }
 
-    /** @see 
org.apache.maven.doxia.parser.AbstractParserTestCase#getDocument() */
-    protected String getDocument()
-    {
-        return "src/test/resources/test/linebreak.apt";
-    }
-
     /** @throws Exception  */
     public void testLineBreak()
         throws Exception
@@ -69,10 +66,10 @@
         try
         {
             output = new StringWriter();
-            reader = new FileReader( getTestFile( getBasedir(), getDocument() 
) );
+            reader = getTestReader( "test/linebreak", "apt" );
 
             Sink sink = new AptSink( output );
-            getParser().parse( reader, sink );
+            createParser().parse( reader, sink );
 
             assertTrue( output.toString().indexOf( "Line\\" + EOL + "break." ) 
!= -1 );
         }
@@ -93,10 +90,10 @@
         try
         {
             output = new StringWriter();
-            reader = new FileReader( getTestFile( getBasedir(), 
"src/test/resources/test/macro.apt" ) );
+            reader = getTestReader( "test/macro", "apt" );
 
             Sink sink = new AptSink( output );
-            getParser().parse( reader, sink );
+            createParser().parse( reader, sink );
 
             assertTrue( output.toString().indexOf( 
"<modelVersion\\>4.0.0\\</modelVersion\\>" ) != -1 );
         }
@@ -117,10 +114,10 @@
         try
         {
             output = new StringWriter();
-            reader = new FileReader( getTestFile( getBasedir(), 
"src/test/resources/test/toc.apt" ) );
+            reader = getTestReader( "test/toc", "apt" );
 
             Sink sink = new AptSink( output );
-            getParser().parse( reader, sink );
+            createParser().parse( reader, sink );
 
             // No section, only subsection 1 and 2
             assertTrue( output.toString().indexOf( "* 
{{{#subsection_1}SubSection 1}}" ) != -1 );
@@ -139,4 +136,45 @@
             }
         }
     }
+
+    /**
+     * Parses the test document test.apt and re-emits
+     * it into parser/test.apt.
+     */
+    public void testTestDocument()
+        throws IOException, ParseException
+    {
+        Writer writer = null;
+
+        Reader reader = null;
+
+        try
+        {
+            writer = getTestWriter( "test" );
+            reader = getTestReader( "test" );
+
+            Sink sink = new AptSink( writer );
+
+            createParser().parse( reader, sink );
+        }
+        finally
+        {
+            if ( writer  != null )
+            {
+                writer.close();
+            }
+
+            if ( reader != null )
+            {
+                reader.close();
+            }
+        }
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String outputExtension()
+    {
+        return "apt";
+    }
+
 }

Modified: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java?view=diff&rev=559624&r1=559623&r2=559624
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java
 Wed Jul 25 14:50:52 2007
@@ -19,36 +19,199 @@
  * under the License.
  */
 
-import org.apache.maven.doxia.sink.AbstractSinkTestCase;
+import java.io.Writer;
+
+import org.apache.maven.doxia.sink.AbstractSinkTest;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.parser.Parser;
 
-public class AptSinkTest
-       extends AbstractSinkTestCase
+public class AptSinkTest extends AbstractSinkTest
 {
+    /** [EMAIL PROTECTED] */
     protected String outputExtension()
     {
         return "apt";
     }
 
-    public void testApt()
-           throws Exception
-       {
-           Sink sink = createSink();
+    /** [EMAIL PROTECTED] */
+    protected Sink createSink( Writer writer )
+    {
+        return new AptSink( writer );
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getTitleBlock( String title )
+    {
+        return title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getAuthorBlock( String author )
+    {
+        return author;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getDateBlock( String date )
+    {
+        return date;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getHeadBlock()
+    {
+        return " ----- null ----- null ----- null -----";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getBodyBlock()
+    {
+        return "";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getSectionTitleBlock( String title )
+    {
+        return title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getSection1Block( String title )
+    {
+        return title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getSection2Block( String title )
+    {
+        return "*" + title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getSection3Block( String title )
+    {
+        return "**" + title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getSection4Block( String title )
+    {
+        return "***" + title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getSection5Block( String title )
+    {
+        return "****" + title;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getListBlock( String item )
+    {
+        return " * " + item + " []";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getNumberedListBlock( String item )
+    {
+        return " [[i]] " + item + " []";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getDefinitionListBlock( String definum, String definition 
)
+    {
+        return " [" + definum + "]" + definition;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getFigureBlock( String source, String caption )
+    {
+        return "[" + source + "] " + caption;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getTableBlock( String cell, String caption )
+    {
+        return "*----*" + cell + "|*----*" + caption;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getParagraphBlock( String text )
+    {
+        return " " + text;
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getVerbatimBlock( String text )
+    {
+        return "+------+" + text + "+------+";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getHorizontalRuleBlock()
+    {
+        return "========";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getPageBreakBlock()
+    {
+        return "\f";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getAnchorBlock( String anchor )
+    {
+        return "{" + anchor + "}";
+    }
 
-           new AptParser().parse( getTestReader(), createSink() );
+    /** [EMAIL PROTECTED] */
+    protected String getLinkBlock( String link, String text )
+    {
+        return "{{{" + link + "}" + text + "}}";
+    }
 
-           sink.flush();
-       }
+    /** [EMAIL PROTECTED] */
+    protected String getItalicBlock( String text )
+    {
+        return "<" + text + ">";
+    }
 
-    protected Parser createParser()
+    /** [EMAIL PROTECTED] */
+    protected String getBoldBlock( String text )
     {
-        return new AptParser();
+        return "<<" + text + ">>";
     }
 
-    protected Sink createSink()
-        throws Exception
+    /** [EMAIL PROTECTED] */
+    protected String getMonospacedBlock( String text )
     {
-        return new AptSink( getTestWriter() );
+        return "<<<" + text + ">>>";
     }
+
+    /** [EMAIL PROTECTED] */
+    protected String getLineBreakBlock()
+    {
+        return "\\";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getNonBreakingSpaceBlock()
+    {
+        return "\\ ";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getTextBlock( String text )
+    {
+        // TODO: need to be able to retreive those from outside the sink
+        return "\\~, \\=, \\-, \\+, \\*, \\[, \\], \\<, \\>, \\{, \\}, \\\\";
+    }
+
+    /** [EMAIL PROTECTED] */
+    protected String getRawTextBlock( String text )
+    {
+        return text;
+    }
+
+
 }


Reply via email to