svn commit: r398035 - /maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java
Author: carlos Date: Fri Apr 28 16:24:40 2006 New Revision: 398035 URL: http://svn.apache.org/viewcvs?rev=398035&view=rev Log: Added docs and method getSink() Modified: maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java Modified: maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java?rev=398035&r1=398034&r2=398035&view=diff == --- maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java (original) +++ maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java Fri Apr 28 16:24:40 2006 @@ -1,7 +1,7 @@ package org.apache.maven.doxia.parser; /* - * Copyright 2004-2005 The Apache Software Foundation. + * Copyright 2004-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,23 +24,50 @@ import java.io.Reader; /** + * Test the parsing of sample input files + * + * @author mailto:[EMAIL PROTECTED]">Carlos Sanchez * @author mailto:[EMAIL PROTECTED]">Emmanuel Venisse * @version $Id:AbstractParserTestCase.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $ */ public abstract class AbstractParserTestCase extends PlexusTestCase { +/** + * Parser to use to convert input to sink events + * + * @return the parser to use + */ protected abstract Parser getParser(); +/** + * Path of the document to test, relative to basedir + * + * @return the relative path + */ protected abstract String getDocument(); + +/** + * Sink to write the output of the parsing + * + * @return a SinkAdapter if not overridden + */ +protected Sink getSink() +{ +return new SinkAdapter(); +} +/** + * Parse the document in the path specified by [EMAIL PROTECTED] #getDocument()}, + * with parser from [EMAIL PROTECTED] #getParser()}, and output to sink from [EMAIL PROTECTED] #getSink()} + * + * @throws Exception + */ public void testParser() throws Exception { -Sink sink = new SinkAdapter(); - Reader reader = new FileReader( getTestFile( getBasedir(), getDocument() ) ); -getParser().parse( reader, sink ); +getParser().parse( reader, getSink() ); } }
svn commit: r398037 - /maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java
Author: carlos Date: Fri Apr 28 16:26:14 2006 New Revision: 398037 URL: http://svn.apache.org/viewcvs?rev=398037&view=rev Log: Added javadoc Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java?rev=398037&r1=398036&r2=398037&view=diff == --- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java (original) +++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java Fri Apr 28 16:26:14 2006 @@ -1,5 +1,7 @@ -package org.apache.maven.doxia.sink;/* - * Copyright 2004-2005 The Apache Software Foundation. +package org.apache.maven.doxia.sink; + +/* + * Copyright 2004-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +16,12 @@ * limitations under the License. */ +/** + * Empty implementation of the Sink interface. Useful for testing purposes. + */ public class SinkAdapter implements Sink { -// Not abstract. Useful just to apt a document without converting it. - public void head() { }
svn commit: r398038 - /maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java
Author: carlos Date: Fri Apr 28 16:32:29 2006 New Revision: 398038 URL: http://svn.apache.org/viewcvs?rev=398038&view=rev Log: [DOXIA-59] Doxia creates files with inconsistent new lines. Use system line separator instead of \n Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java?rev=398038&r1=398037&r2=398038&view=diff == --- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java (original) +++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/LineBreaker.java Fri Apr 28 16:32:29 2006 @@ -26,6 +26,8 @@ { public static final int DEFAULT_MAX_LINE_LENGTH = 78; +private static final String EOL = System.getProperty( "line.separator" ); + private Writer destination; private BufferedWriter writer; @@ -88,7 +90,7 @@ case '\n': writeWord(); -writer.write( '\n' ); +writer.write( EOL ); lineLength = 0; break; @@ -126,7 +128,7 @@ { if ( lineLength + 1 + length > maxLineLength ) { -writer.write( '\n' ); +writer.write( EOL ); lineLength = 0; } else