maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r735471 - in /maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia: module/AbstractIdentityTest.java sink/AbstractSinkTest.java
Date Sun, 18 Jan 2009 15:21:28 GMT
Author: vsiveton
Date: Sun Jan 18 07:21:28 2009
New Revision: 735471

URL: http://svn.apache.org/viewvc?rev=735471&view=rev
Log:
o Fixed Sink leaks about close()

Modified:
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java?rev=735471&r1=735470&r2=735471&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
Sun Jan 18 07:21:28 2009
@@ -20,7 +20,6 @@
  */
 
 import java.io.IOException;
-import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
@@ -85,56 +84,43 @@
     public void testIdentity()
         throws IOException, ParseException
     {
-        Writer writer = null;
+        // generate the expected model
+        StringWriter writer = new StringWriter();
+        Sink sink = new TextSink( writer );
+        SinkTestDocument.generate( sink );
+        sink.close();
+        expected = writer.toString();
+
+        // write to file for comparison
+        Writer fileWriter = getTestWriter( "expected" );
+        fileWriter.write( expected );
+        IOUtil.close( fileWriter );
+
+        // generate the actual model
+        writer = new StringWriter();
+        sink = createSink( writer );
+        SinkTestDocument.generate( sink );
+        sink.close();
+        StringReader reader = new StringReader( writer.toString() );
+
+        writer = new StringWriter();
+        sink = new TextSink( writer );
+        createParser().parse( reader, sink );
+        String actual = writer.toString();
+
+        // write to file for comparison
+        fileWriter = getTestWriter( "actual" );
+        fileWriter.write( actual );
+        IOUtil.close( fileWriter );
+
+        // Disabled by default, it's unlikely that all our modules
+        // will pass this test any time soon, but the generated
+        // output files can still be compared.
 
-        Writer fileWriter = null;
-
-        Reader reader = null;
-
-        try
+        if ( assertIdentity )
         {
-            // generate the expected model
-            writer = new StringWriter();
-            SinkTestDocument.generate( new TextSink( writer ) );
-            expected = writer.toString();
-
-            // write to file for comparison
-            fileWriter = getTestWriter( "expected" );
-            fileWriter.write( expected );
-            fileWriter.close();
-
-            // generate the actual model
-            writer = new StringWriter();
-            SinkTestDocument.generate( createSink( writer ) );
-            reader = new StringReader( writer.toString() );
-
-            writer = new StringWriter();
-            createParser().parse( reader, new TextSink( writer ) );
-            String actual = writer.toString();
-
-            // write to file for comparison
-            fileWriter = getTestWriter( "actual" );
-            fileWriter.write( actual );
-            fileWriter.close();
-
-            // Disabled by default, it's unlikely that all our modules
-            // will pass this test any time soon, but the generated
-            // output files can still be compared.
-
-            if ( assertIdentity )
-            {
-                // TODO: make this work for at least apt and xdoc modules?
-                assertEquals( "Identity test failed!", getExpected(), actual );
-            }
-
-        }
-        finally
-        {
-            IOUtil.close( writer );
-
-            IOUtil.close( fileWriter );
-
-            IOUtil.close( reader );
+            // TODO: make this work for at least apt and xdoc modules?
+            assertEquals( "Identity test failed!", getExpected(), actual );
         }
     }
 

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java?rev=735471&r1=735470&r2=735471&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractSinkTest.java
Sun Jan 18 07:21:28 2009
@@ -71,9 +71,14 @@
         Writer writer = ( isXmlSink() ? getXmlTestWriter( "testDocument" ) : getTestWriter(
"testDocument" ) );
         Sink testSink = createSink( writer );
 
-        SinkTestDocument.generate( testSink );
-
-        testSink.close();
+        try
+        {
+            SinkTestDocument.generate( testSink );
+        }
+        finally
+        {
+            testSink.close();
+        }
     }
 
     /**
@@ -88,6 +93,7 @@
         sink.text( title );
         sink.title_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getTitleBlock( title );
@@ -107,6 +113,7 @@
         sink.text( author );
         sink.author_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getAuthorBlock( author );
@@ -126,6 +133,7 @@
         sink.text( date );
         sink.date_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getDateBlock( date );
@@ -143,6 +151,7 @@
         sink.head();
         sink.head_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getHeadBlock();
@@ -160,6 +169,7 @@
         sink.body();
         sink.body_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getBodyBlock();
@@ -180,6 +190,7 @@
         sink.text( title );
         sink.sectionTitle_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getSectionTitleBlock( title );
@@ -202,6 +213,7 @@
         sink.sectionTitle1_();
         sink.section1_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getSection1Block( title );
@@ -224,6 +236,7 @@
         sink.sectionTitle2_();
         sink.section2_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getSection2Block( title );
@@ -246,6 +259,7 @@
         sink.sectionTitle3_();
         sink.section3_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getSection3Block( title );
@@ -269,6 +283,7 @@
         sink.sectionTitle4_();
         sink.section4_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getSection4Block( title );
@@ -291,6 +306,7 @@
         sink.sectionTitle5_();
         sink.section5_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getSection5Block( title );
@@ -313,6 +329,7 @@
         sink.listItem_();
         sink.list_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getListBlock( item );
@@ -336,6 +353,7 @@
         sink.numberedListItem_();
         sink.numberedList_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getNumberedListBlock( item );
@@ -366,6 +384,7 @@
         sink.definitionListItem_();
         sink.definitionList_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getDefinitionListBlock( definum, definition );
@@ -390,6 +409,7 @@
         sink.figureCaption_();
         sink.figure_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getFigureBlock( source, caption );
@@ -423,6 +443,7 @@
         sink.tableCaption_();
         sink.table_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getTableBlock( cell, caption );
@@ -442,6 +463,7 @@
         sink.text( text );
         sink.paragraph_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getParagraphBlock( text );
@@ -461,6 +483,7 @@
         sink.text( text );
         sink.verbatim_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getVerbatimBlock( text );
@@ -477,6 +500,7 @@
     {
         sink.horizontalRule();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getHorizontalRuleBlock();
@@ -493,6 +517,7 @@
     {
         sink.pageBreak();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getPageBreakBlock();
@@ -512,6 +537,7 @@
         sink.text( anchor );
         sink.anchor_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getAnchorBlock( anchor );
@@ -532,6 +558,7 @@
         sink.text( text );
         sink.link_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getLinkBlock( link, text );
@@ -551,6 +578,7 @@
         sink.text( text );
         sink.italic_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getItalicBlock( text );
@@ -570,6 +598,7 @@
         sink.text( text );
         sink.bold_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getBoldBlock( text );
@@ -589,6 +618,7 @@
         sink.text( text );
         sink.monospaced_();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getMonospacedBlock( text );
@@ -605,6 +635,7 @@
     {
         sink.lineBreak();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getLineBreakBlock();
@@ -621,6 +652,7 @@
     {
         sink.nonBreakingSpace();
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getNonBreakingSpaceBlock();
@@ -638,6 +670,7 @@
         String text = "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\";
         sink.text( text );
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getTextBlock( text );
@@ -655,6 +688,7 @@
         String text = "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\";
         sink.rawText( text );
         sink.flush();
+        sink.close();
 
         String actual = writer.toString();
         String expected = getRawTextBlock( text );



Mime
View raw message