maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r559624 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt: AptIdentityTest.java AptParserTest.java AptSinkTest.java
Date Wed, 25 Jul 2007 21:50:53 GMT
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
+{
+    /** {@inheritDoc} */
+    protected Sink createSink( Writer writer )
+    {
+        return new AptSink( writer );
+    }
+
+    /** {@inheritDoc} */
+    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();
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    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
 {
+    /** {@inheritDoc} */
     protected String outputExtension()
     {
         return "apt";
     }
 
-    public void testApt()
-	    throws Exception
-	{
-	    Sink sink = createSink();
+    /** {@inheritDoc} */
+    protected Sink createSink( Writer writer )
+    {
+        return new AptSink( writer );
+    }
+
+    /** {@inheritDoc} */
+    protected String getTitleBlock( String title )
+    {
+        return title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getAuthorBlock( String author )
+    {
+        return author;
+    }
+
+    /** {@inheritDoc} */
+    protected String getDateBlock( String date )
+    {
+        return date;
+    }
+
+    /** {@inheritDoc} */
+    protected String getHeadBlock()
+    {
+        return " ----- null ----- null ----- null -----";
+    }
+
+    /** {@inheritDoc} */
+    protected String getBodyBlock()
+    {
+        return "";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSectionTitleBlock( String title )
+    {
+        return title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection1Block( String title )
+    {
+        return title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection2Block( String title )
+    {
+        return "*" + title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection3Block( String title )
+    {
+        return "**" + title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection4Block( String title )
+    {
+        return "***" + title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection5Block( String title )
+    {
+        return "****" + title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getListBlock( String item )
+    {
+        return " * " + item + " []";
+    }
+
+    /** {@inheritDoc} */
+    protected String getNumberedListBlock( String item )
+    {
+        return " [[i]] " + item + " []";
+    }
+
+    /** {@inheritDoc} */
+    protected String getDefinitionListBlock( String definum, String definition )
+    {
+        return " [" + definum + "]" + definition;
+    }
+
+    /** {@inheritDoc} */
+    protected String getFigureBlock( String source, String caption )
+    {
+        return "[" + source + "] " + caption;
+    }
+
+    /** {@inheritDoc} */
+    protected String getTableBlock( String cell, String caption )
+    {
+        return "*----*" + cell + "|*----*" + caption;
+    }
+
+    /** {@inheritDoc} */
+    protected String getParagraphBlock( String text )
+    {
+        return " " + text;
+    }
+
+    /** {@inheritDoc} */
+    protected String getVerbatimBlock( String text )
+    {
+        return "+------+" + text + "+------+";
+    }
+
+    /** {@inheritDoc} */
+    protected String getHorizontalRuleBlock()
+    {
+        return "========";
+    }
+
+    /** {@inheritDoc} */
+    protected String getPageBreakBlock()
+    {
+        return "\f";
+    }
+
+    /** {@inheritDoc} */
+    protected String getAnchorBlock( String anchor )
+    {
+        return "{" + anchor + "}";
+    }
 
-	    new AptParser().parse( getTestReader(), createSink() );
+    /** {@inheritDoc} */
+    protected String getLinkBlock( String link, String text )
+    {
+        return "{{{" + link + "}" + text + "}}";
+    }
 
-	    sink.flush();
-	}
+    /** {@inheritDoc} */
+    protected String getItalicBlock( String text )
+    {
+        return "<" + text + ">";
+    }
 
-    protected Parser createParser()
+    /** {@inheritDoc} */
+    protected String getBoldBlock( String text )
     {
-        return new AptParser();
+        return "<<" + text + ">>";
     }
 
-    protected Sink createSink()
-        throws Exception
+    /** {@inheritDoc} */
+    protected String getMonospacedBlock( String text )
     {
-        return new AptSink( getTestWriter() );
+        return "<<<" + text + ">>>";
     }
+
+    /** {@inheritDoc} */
+    protected String getLineBreakBlock()
+    {
+        return "\\";
+    }
+
+    /** {@inheritDoc} */
+    protected String getNonBreakingSpaceBlock()
+    {
+        return "\\ ";
+    }
+
+    /** {@inheritDoc} */
+    protected String getTextBlock( String text )
+    {
+        // TODO: need to be able to retreive those from outside the sink
+        return "\\~, \\=, \\-, \\+, \\*, \\[, \\], \\<, \\>, \\{, \\}, \\\\";
+    }
+
+    /** {@inheritDoc} */
+    protected String getRawTextBlock( String text )
+    {
+        return text;
+    }
+
+
 }



Mime
View raw message