Author: hboutemy
Date: Sun Jan 31 10:28:56 2010
New Revision: 904995
URL: http://svn.apache.org/viewvc?rev=904995&view=rev
Log:
code factorization
Modified:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
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?rev=904995&r1=904994&r2=904995&view=diff
==============================================================================
---
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
Sun Jan 31 10:28:56 2010
@@ -61,16 +61,15 @@
return parser;
}
- /** @throws Exception */
- public void testLineBreak()
- throws Exception
+ protected String parseFileToAptSink( String file )
+ throws ParseException
{
StringWriter output = null;
Reader reader = null;
try
{
output = new StringWriter();
- reader = getTestReader( "test/linebreak", "apt" );
+ reader = getTestReader( file );
Sink sink = new AptSink( output );
createParser().parse( reader, sink );
@@ -81,30 +80,25 @@
IOUtil.close( reader );
}
- assertTrue( output.toString().indexOf( "Line\\" + EOL + "break." ) !=
-1 );
+ return output.toString();
}
/** @throws Exception */
- public void testSnippetMacro()
+ public void testLineBreak()
throws Exception
{
- StringWriter output = null;
- Reader reader = null;
- try
- {
- output = new StringWriter();
- reader = getTestReader( "test/macro", "apt" );
+ String linebreak = parseFileToAptSink( "test/linebreak" );
- Sink sink = new AptSink( output );
- createParser().parse( reader, sink );
- }
- finally
- {
- IOUtil.close( output );
- IOUtil.close( reader );
- }
+ assertTrue( linebreak.indexOf( "Line\\" + EOL + "break." ) != -1 );
+ }
- assertTrue( output.toString().indexOf(
"<modelVersion\\>4.0.0\\</modelVersion\\>" ) != -1 );
+ /** @throws Exception */
+ public void testSnippetMacro()
+ throws Exception
+ {
+ String macro = parseFileToAptSink( "test/macro" );
+
+ assertTrue( macro.indexOf( "<modelVersion\\>4.0.0\\</modelVersion\\>"
) != -1 );
}
/** @throws Exception */
@@ -118,7 +112,7 @@
try
{
- reader = getTestReader( "test/snippet", "apt" );
+ reader = getTestReader( "test/snippet" );
createParser().parse( reader, sink );
}
@@ -161,25 +155,11 @@
public void testTocMacro()
throws Exception
{
- StringWriter output = null;
- Reader reader = null;
- try
- {
- output = new StringWriter();
- reader = getTestReader( "test/toc", "apt" );
-
- Sink sink = new AptSink( output );
- createParser().parse( reader, sink );
- }
- finally
- {
- IOUtil.close( output );
- IOUtil.close( reader );
- }
+ String toc = parseFileToAptSink( "test/toc" );
// No section, only subsection 1 and 2
- assertTrue( output.toString().indexOf( "* {{{SubSection_1.1}SubSection
1.1}}" ) != -1 );
- assertTrue( output.toString().indexOf( "*
{{{SubSection_1.1.2.1.1}SubSection 1.1.2.1.1}}" ) == -1 );
+ assertTrue( toc.indexOf( "* {{{SubSection_1.1}SubSection 1.1}}" ) !=
-1 );
+ assertTrue( toc.indexOf( "* {{{SubSection_1.1.2.1.1}SubSection
1.1.2.1.1}}" ) == -1 );
}
/**