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/08/17 14:03:10 UTC

svn commit: r567030 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test: java/org/apache/maven/doxia/module/xdoc/ resources/

Author: ltheussl
Date: Fri Aug 17 05:03:09 2007
New Revision: 567030

URL: http://svn.apache.org/viewvc?view=rev&rev=567030
Log:
Use new test classes in xdoc module

Added:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java   (with props)
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml   (with props)
Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java

Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java?view=auto&rev=567030
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java Fri Aug 17 05:03:09 2007
@@ -0,0 +1,46 @@
+package org.apache.maven.doxia.module.xdoc;
+
+/*
+ * 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.
+ */
+public class XdocIdentityTest extends AbstractIdentityTest
+{
+    /** {@inheritDoc} */
+    protected Sink createSink( Writer writer )
+    {
+        return new XdocSink( writer );
+    }
+
+    /** {@inheritDoc} */
+    protected Parser createParser()
+    {
+        return new XdocParser();
+    }
+}

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

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

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java?view=diff&rev=567030&r1=567029&r2=567030
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java Fri Aug 17 05:03:09 2007
@@ -21,11 +21,11 @@
 
 import java.io.File;
 import java.io.FileReader;
-import java.io.FileWriter;
 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.sink.Sink;
 import org.codehaus.plexus.util.IOUtil;
@@ -36,7 +36,7 @@
  * @version $Id:XdocParserTest.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
  */
 public class XdocParserTest
-    extends AbstractParserTestCase
+    extends AbstractParserTest
 {
     private XdocParser parser;
 
@@ -49,33 +49,32 @@
         parser = (XdocParser) lookup( Parser.ROLE, "xdoc" );
     }
 
-    /** @see org.apache.maven.doxia.parser.AbstractParserTestCase#getParser() */
-    protected Parser getParser()
+    /** {@inheritDoc} */
+    protected String outputExtension()
     {
-        return parser;
+        return "xml";
     }
 
-    /** @see org.apache.maven.doxia.parser.AbstractParserTestCase#getDocument() */
-    protected String getDocument()
+    /** {@inheritDoc} */
+    protected Parser createParser()
     {
-        return "src/test/resources/report.xml";
+        return parser;
     }
 
     /** @throws Exception  */
     public void testSnippetMacro()
         throws Exception
     {
-        FileWriter output = null;
+        Writer output = null;
         Reader reader = null;
-        File f = getTestFile( getBasedir(), "target/output/macro.xml" );
 
         try
         {
-            output = new FileWriter( f );
-            reader = new FileReader( getTestFile( getBasedir(), "src/test/resources/macro.xml" ) );
+            output = getTestWriter( "macro" );
+            reader = getTestReader( "macro" );
 
             Sink sink = new XdocSink( output );
-            getParser().parse( reader, sink );
+            createParser().parse( reader, sink );
         }
         finally
         {
@@ -83,6 +82,7 @@
             IOUtil.close( reader );
         }
 
+        File f = getTestFile( getBasedir(), outputBaseDir() + getOutputDir() + "macro.xml" );
         assertTrue( "The file " + f.getAbsolutePath() + " was not created", f.exists() );
 
         String content;
@@ -103,17 +103,16 @@
     public void testTocMacro()
         throws Exception
     {
-        FileWriter output = null;
+        Writer output = null;
         Reader reader = null;
-        File f = getTestFile( getBasedir(), "target/output/toc.xml" );
 
         try
         {
-            output = new FileWriter( getTestFile( getBasedir(), "target/output/toc.xml" ) );
-            reader = new FileReader( getTestFile( getBasedir(), "src/test/resources/toc.xml" ) );
+            output = getTestWriter( "toc" );
+            reader = getTestReader( "toc" );
 
             Sink sink = new XdocSink( output );
-            getParser().parse( reader, sink );
+            createParser().parse( reader, sink );
         }
         finally
         {
@@ -121,6 +120,7 @@
             IOUtil.close( reader );
         }
 
+        File f = getTestFile( getBasedir(), outputBaseDir() + getOutputDir() + "toc.xml" );
         assertTrue( "The file " + f.getAbsolutePath() + " was not created", f.exists() );
 
         String content;

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java?view=diff&rev=567030&r1=567029&r2=567030
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java Fri Aug 17 05:03:09 2007
@@ -19,45 +19,208 @@
  * under the License.
  */
 
-import org.apache.maven.doxia.module.xdoc.XdocSink;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.AbstractSinkTestCase;
-import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.AbstractSinkTest;
+import org.apache.maven.doxia.util.HtmlTools;
 
-import java.io.Reader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.Writer;
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id:XdocSinkTest.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
  */
 public class XdocSinkTest
-    extends AbstractSinkTestCase
+    extends AbstractSinkTest
 {
+    /** {@inheritDoc} */
     protected String outputExtension()
     {
         return "xml";
     }
 
-    protected Parser createParser()
+    /** {@inheritDoc} */
+    protected Sink createSink( Writer writer )
     {
-        return new XdocParser();
+        return new XdocSink( writer );
     }
 
-    protected Sink createSink()
-        throws Exception
+    /** {@inheritDoc} */
+    protected String getTitleBlock( String title )
     {
-        return new XdocSink( getTestWriter() );
+        return title;
     }
 
-    protected Reader getTestReader()
-        throws Exception
+    /** {@inheritDoc} */
+    protected String getAuthorBlock( String author )
     {
-        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "report.xml" );
+        return author;
+    }
 
-        InputStreamReader reader = new InputStreamReader( is );
+    /** {@inheritDoc} */
+    protected String getDateBlock( String date )
+    {
+        return date;
+    }
 
-        return reader;
+    /** {@inheritDoc} */
+    protected String getHeadBlock()
+    {
+        return "<?xml version=\"1.0\" ?><document><properties></properties>";
     }
+
+    /** {@inheritDoc} */
+    protected String getBodyBlock()
+    {
+        return "<body></body></document>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSectionTitleBlock( String title )
+    {
+        return title;
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection1Block( String title )
+    {
+        return "<section name=\"" + title + "\"></section>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection2Block( String title )
+    {
+        return "<subsection name=\"" + title + "\"></subsection>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection3Block( String title )
+    {
+        return "<h4>" + title + "</h4>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection4Block( String title )
+    {
+        return "<h5>" + title + "</h5>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection5Block( String title )
+    {
+        return "<h6>" + title + "</h6>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getListBlock( String item )
+    {
+        return "<ul><li>" + item + "</li></ul>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getNumberedListBlock( String item )
+    {
+        return "<ol style=\"list-style-type: lower-roman\"><li>" + item + "</li></ol>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getDefinitionListBlock( String definum, String definition )
+    {
+        return "<dl><dt>" + definum + "</dt><dd>" + definition + "</dd></dl>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getFigureBlock( String source, String caption )
+    {
+        return "<img src=\"" + source + "\" alt=\"" + caption + "\" />";
+    }
+
+    /** {@inheritDoc} */
+    protected String getTableBlock( String cell, String caption )
+    {
+        return "<table align=\"center\"><table align=\"center\" border=\"0\"><tr valign=\"top\"><td>"
+            + cell + "</td></tr></table><p><i>" + caption + "</i></p></table>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getParagraphBlock( String text )
+    {
+        return "<p>" + text + "</p>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getVerbatimBlock( String text )
+    {
+        return "<source>" + text + "</source>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getHorizontalRuleBlock()
+    {
+        return "<hr />";
+    }
+
+    /** {@inheritDoc} */
+    protected String getPageBreakBlock()
+    {
+        return "";
+    }
+
+    /** {@inheritDoc} */
+    protected String getAnchorBlock( String anchor )
+    {
+        return "<a name=\"" + anchor + "\" id=\""
+            + anchor + "\">" + anchor + "</a>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getLinkBlock( String link, String text )
+    {
+        return "<a href=\"" + link + "\">" + text + "</a>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getItalicBlock( String text )
+    {
+        return "<i>" + text + "</i>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getBoldBlock( String text )
+    {
+        return "<b>" + text + "</b>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getMonospacedBlock( String text )
+    {
+        return "<tt>" + text + "</tt>";
+    }
+
+    /** {@inheritDoc} */
+    protected String getLineBreakBlock()
+    {
+        return "<br />";
+    }
+
+    /** {@inheritDoc} */
+    protected String getNonBreakingSpaceBlock()
+    {
+        return "&#160;";
+    }
+
+    /** {@inheritDoc} */
+    protected String getTextBlock( String text )
+    {
+        // TODO: need to be able to retreive those from outside the sink
+        return HtmlTools.escapeHTML( text );
+    }
+
+    /** {@inheritDoc} */
+    protected String getRawTextBlock( String text )
+    {
+        // TODO
+        return "";
+    }
+
+
 }

Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml?view=auto&rev=567030
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml Fri Aug 17 05:03:09 2007
@@ -0,0 +1,121 @@
+<?xml version="1.0" ?>
+
+<document>
+
+<properties>
+    <title>Title</title>
+    <author>Author</author>
+    <date>Date</date>
+</properties>
+
+<body>
+
+  <p>Paragraph 1, line 1. Paragraph 1, line 2.</p>
+  <p>Paragraph 2, line 1. Paragraph 2, line 2.</p>
+
+  <section name="Section title">
+    <subsection name="Sub-section title">
+      <h4>Sub-sub-section title</h4>
+        <h5>Sub-sub-sub-section</h5>
+          <h6>Sub-sub-sub-sub-section</h6>
+
+    <ul>
+      <li>List item 1.</li>
+      <li>List item 2.
+        <p>Paragraph contained in list item 2.</p>
+        <ul>
+          <li>Sub-list item 1.</li>
+          <li>Sub-list item 2.</li>
+        </ul>
+      </li>
+      <li>List item 3. Force end of list:</li>
+    </ul>
+
+    <source>Verbatim text not contained in list item 3</source>
+
+    <ol style="list-style-type: decimal">
+      <li>Numbered item 1.
+        <ol style="list-style-type: upper-alpha">
+          <li>Numbered item A.</li>
+          <li>Numbered item B.</li>
+        </ol>
+      </li>
+      <li>Numbered item 2.</li>
+    </ol>
+
+    <p>List numbering schemes: [[1]], [[a]], [[A]], [[i]], [[I]].</p>
+
+    <dl compact="compact">
+      <dt><b>Defined term 1</b></dt>
+      <dd>of definition list.</dd>
+      <dt><b>Defined term 2</b></dt>
+      <dd>of definition list.
+<source>Verbatim text
+                            in a box        </source>
+      </dd>
+    </dl>
+
+    <p>--- instead of +-- suppresses the box around verbatim text.</p>
+
+    <img src="figure" alt="Figure caption" />
+
+    <table align="center">
+      <table align="center" border="1">
+        <tr valign="top">
+          <th align="center">Centered<br />cell 1,1</th>
+          <th align="left">Left-aligned<br />cell 1,2</th>
+          <th align="right">Right-aligned<br />cell 1,3</th>
+        </tr>
+        <tr valign="top">
+          <td align="center">cell 2,1</td>
+          <td align="left">cell 2,2</td>
+          <td align="right">cell 2,3</td>
+        </tr>
+      </table>
+    <p><i>Table caption</i></p>
+    </table>
+
+    <p>No grid, no caption:</p>
+
+    <table align="center">
+      <table align="center" border="0">
+        <tr valign="top">
+          <td align="center">cell</td>
+          <td align="center">cell</td>
+        </tr>
+        <tr valign="top">
+          <td align="center">cell</td>
+          <td align="center">cell</td>
+        </tr>
+      </table>
+    </table>
+
+    <p>Horizontal line:</p>
+    <hr />
+
+    <p>New page.</p>
+
+    <p><i>Italic</i> font. <b>Bold</b> font. <tt>Monospaced</tt> font.</p>
+
+    <p>
+      <a id="anchor" name="anchor">Anchor</a>.
+      Link to <a href="anchor">Anchor</a>.
+      Link to <a href="http://www.pixware.fr">http://www.pixware.fr</a>.
+      Link to <a href="anchor">showing alternate text</a>.
+      Link to <a href="http://www.pixware.fr">Pixware home page</a>.
+    </p>
+
+    <p>Force line<br />break.</p>
+
+    <p>Non&#160;breaking&#160;space.</p>
+
+    <p>Escaped special characters: ~, =, -, +, *, [, ], &lt;, &gt;, {, }, \.</p>
+
+    <p>Copyright symbol: &#169; &#169; &#169;.</p>
+
+      </subsection>
+    </section>
+
+</body>
+
+</document>

Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"