Author: ltheussl
Date: Fri Aug 17 05:08:17 2007
New Revision: 567032
URL: http://svn.apache.org/viewvc?view=rev&rev=567032
Log:
Use new test classes. The IdentityTest fails with a parsing error (probably
MSITE-194, not sure), to be done later.
Added:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/resources/test.xhtml
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java?view=diff&rev=567032&r1=567031&r2=567032
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
Fri Aug 17 05:08:17 2007
@@ -20,7 +20,7 @@
*/
import org.apache.maven.doxia.WellformednessCheckingSink;
-import org.apache.maven.doxia.parser.AbstractParserTestCase;
+import org.apache.maven.doxia.parser.AbstractParserTest;
import org.apache.maven.doxia.parser.Parser;
import java.io.FileReader;
@@ -31,28 +31,16 @@
* @version $Id$
*/
public class XhtmlParserTest
- extends AbstractParserTestCase
+ extends AbstractParserTest
{
- protected Parser getParser()
+ protected Parser createParser()
{
return new XhtmlParser();
}
- protected String getDocument()
+ protected String outputExtension()
{
- return "src/test/resources/fun.html";
+ return "xhtml";
}
- public void testParser()
- throws Exception
- {
- //use the new wellformedness checking sink.
- WellformednessCheckingSink sink = new WellformednessCheckingSink();
-
- Reader reader = new FileReader( getTestFile( getBasedir(),
getDocument() ) );
-
- getParser().parse( reader, sink );
-
- assertTrue( "Input not wellformed, offending element: " +
sink.getOffender(), sink.isWellformed() );
- }
}
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java?view=diff&rev=567032&r1=567031&r2=567032
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
(original)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Fri Aug 17 05:08:17 2007
@@ -20,14 +20,14 @@
*/
import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
-import org.apache.maven.doxia.sink.AbstractSinkTestCase;
+import org.apache.maven.doxia.sink.AbstractSinkTest;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.parser.Parser;
import java.io.File;
import java.io.Reader;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.Writer;
import java.util.HashMap;
/**
@@ -35,22 +35,14 @@
* @version $Id:XhtmlSinkTest.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24
Nov 2005) brett $
*/
public class XhtmlSinkTest
- extends AbstractSinkTestCase
+ extends AbstractSinkTest
{
protected String outputExtension()
{
return "xhtml";
}
- // START SNIPPET: foo
-
- protected Parser createParser()
- {
- return new XhtmlParser();
- }
-
- protected Sink createSink()
- throws Exception
+ protected Sink createSink( Writer writer )
{
String apt = "test.apt";
@@ -60,20 +52,201 @@
//PLXAPI: This horrible fake map is being used because someone
neutered the directives approach in the
// site renderer so that it half worked. Put it back and make it work
properly.
- return new XhtmlSink( getTestWriter(), renderingContext, new FakeMap() );
+ return new XhtmlSink( writer, renderingContext, new FakeMap() );
}
- protected Reader getTestReader()
+ public void testLinks()
throws Exception
{
- InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream( "fun.html"
);
+ Writer writer = getTestWriter( "links" );
+ XhtmlSink sink = (XhtmlSink) createSink( writer );
+ sink.link( "http:/www.xdoc.com" );
+ sink.link_();
+ sink.link( "./index.html#anchor" );
+ sink.link_();
+ sink.link( "../index.html#anchor" );
+ sink.link_();
+ sink.link( "index.html" );
+ sink.link_();
+ sink.close();
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getTitleBlock( String title )
+ {
+ return "<title>" + title + "</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 "";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getBodyBlock()
+ {
+ return "";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getSectionTitleBlock( String title )
+ {
+ return title;
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getSection1Block( String title )
+ {
+ return "<div class=\"section\"><h2>" + title + "</h2></div>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getSection2Block( String title )
+ {
+ return "<div class=\"section\"><h3>" + title + "</h3></div>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getSection3Block( String title )
+ {
+ return "<div class=\"section\"><h4>" + title + "</h4></div>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getSection4Block( String title )
+ {
+ return "<div class=\"section\"><h5>" + title + "</h5></div>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getSection5Block( String title )
+ {
+ return "<div class=\"section\"><h6>" + title + "</h6></div>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getListBlock( String item )
+ {
+ return "<ul><li>" + item + "</li></ul>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getNumberedListBlock( String item )
+ {
+ return "<ol type=\"i\"><li>" + item + "</li></ol>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getDefinitionListBlock( String definum, String definition
)
+ {
+ return "<dl><dt>" + definum + "</dt><dd>" + definition + "</dd></dl>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getFigureBlock( String source, String caption )
+ {
+ return "<img src=\"" + source + "\" alt=\"" + caption + "\" />";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getTableBlock( String cell, String caption )
+ {
+ return "<table class=\"bodyTable\"><tbody><tr class=\"a\"><td
align=\"center\">"
+ + cell + "</td></tr></tbody><caption>" + caption +
"</caption></table>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getParagraphBlock( String text )
+ {
+ return "<p>" + text + "</p>";
+ }
- InputStreamReader reader = new InputStreamReader( is );
+ /** [EMAIL PROTECTED] */
+ protected String getVerbatimBlock( String text )
+ {
+ return "<div class=\"source\"><pre>" + text + "</pre></div>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getHorizontalRuleBlock()
+ {
+ return "<hr />";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getPageBreakBlock()
+ {
+ return "";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getAnchorBlock( String anchor )
+ {
+ return "<a name=\"" + anchor + "\">" + anchor + "</a>";
+ }
- return reader;
+ /** [EMAIL PROTECTED] */
+ protected String getLinkBlock( String link, String text )
+ {
+ return "<a href=\"#" + link + "\">" + text + "</a>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getItalicBlock( String text )
+ {
+ return "<i>" + text + "</i>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getBoldBlock( String text )
+ {
+ return "<b>" + text + "</b>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getMonospacedBlock( String text )
+ {
+ return "<tt>" + text + "</tt>";
+ }
+
+ /** [EMAIL PROTECTED] */
+ protected String getLineBreakBlock()
+ {
+ return "<br />";
+ }
+
+ /** [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;
}
- // END SNIPPET: foo
class FakeMap
extends HashMap
Added:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/resources/test.xhtml
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/resources/test.xhtml?view=auto&rev=567032
==============================================================================
---
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/resources/test.xhtml
(added)
+++
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/resources/test.xhtml
Fri Aug 17 05:08:17 2007
@@ -0,0 +1,113 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+ <title>Title</title>
+ <meta name="author" content="Author" />
+ <meta name="date" content="Date" />
+</head>
+
+<body>
+
+<p>Paragraph 1, line 1. Paragraph 1, line 2.</p>
+<p>Paragraph 2, line 1. Paragraph 2, line 2.</p>
+
+<div class="section"><h2>Section title</h2>
+<div class="section"><h3>Sub-section title</h3>
+<div class="section"><h4>Sub-sub-section title</h4>
+<div class="section"><h5>Sub-sub-sub-section title</h5>
+<div class="section"><h6>Sub-sub-sub-sub-section title</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>
+
+<div class="source"><pre>Verbatim text not contained in list item 3</pre></div>
+
+<ol type="1">
+ <li>Numbered item 1.
+ <ol type="A">
+ <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>
+ <dt>Defined term 1</dt>
+ <dd>of definition list.</dd>
+ <dt>Defined term 2</dt>
+ <dd>of definition list.<div class="source"><pre>Verbatim text
+ in a box </pre></div></dd>
+</dl>
+
+<p>--- instead of +-- suppresses the box around verbatim text.</p>
+
+<img src="figure" alt="Figure caption" />
+
+<table class="bodyTable">
+ <tbody>
+ <tr class="a">
+ <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 class="b">
+ <td align="center">cell 2,1</td>
+ <td align="left">cell 2,2</td>
+ <td align="right">cell 2,3</td>
+ </tr>
+ </tbody>
+ <caption>Table caption</caption>
+</table>
+
+<p>No grid, no caption:</p>
+
+<table class="bodyTable">
+ <tbody>
+ <tr class="a">
+ <td align="center">cell</td>
+ <td align="center">cell</td>
+ </tr>
+ <tr class="b">
+ <td align="center">cell</td>
+ <td align="center">cell</td>
+ </tr>
+ </tbody>
+</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 name="anchor">Anchor</a>.
+ Link to <a href="#Anchor">Anchor</a>.
+ Link to <a href="http://www.pixware.fr"
class="externalLink">http://www.pixware.fr</a>.
+ Link to <a href="#Anchor">showing alternate text</a>.
+ Link to <a href="http://www.pixware.fr" class="externalLink">Pixware home
page</a>.
+</p>
+
+<p>Force line<br />break.</p>
+
+<p>Non breaking space.</p>
+
+<p>Escaped special characters: ~, =, -, +, *, [, ], <, >, {, }, \.</p>
+
+<p>Copyright symbol: ©, ©, ©.</p>
+
+</div></div></div></div></div>
+
+</body>
+
+</html>
\ No newline at end of file