maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r735472 - in /maven/doxia/doxia/trunk/doxia-modules: doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/ doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ doxia-module-fml/src/test/java/org/apache...
Date Sun, 18 Jan 2009 15:30:54 GMT
Author: vsiveton
Date: Sun Jan 18 07:30:54 2009
New Revision: 735472

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

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.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=735472&r1=735471&r2=735472&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 18 07:30:54 2009
@@ -29,6 +29,7 @@
 import org.apache.maven.doxia.parser.ParseException;
 
 import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.util.IOUtil;
 
 /**
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
@@ -61,7 +62,6 @@
     {
         StringWriter output = null;
         Reader reader = null;
-
         try
         {
             output = new StringWriter();
@@ -69,14 +69,14 @@
 
             Sink sink = new AptSink( output );
             createParser().parse( reader, sink );
-
-            assertTrue( output.toString().indexOf( "Line\\" + EOL + "break." ) != -1 );
         }
         finally
         {
-            output.close();
-            reader.close();
+            IOUtil.close( output );
+            IOUtil.close( reader );
         }
+
+        assertTrue( output.toString().indexOf( "Line\\" + EOL + "break." ) != -1 );
     }
 
     /** @throws Exception  */
@@ -85,7 +85,6 @@
     {
         StringWriter output = null;
         Reader reader = null;
-
         try
         {
             output = new StringWriter();
@@ -93,14 +92,14 @@
 
             Sink sink = new AptSink( output );
             createParser().parse( reader, sink );
-
-            assertTrue( output.toString().indexOf( "<modelVersion\\>4.0.0\\</modelVersion\\>"
) != -1 );
         }
         finally
         {
-            output.close();
-            reader.close();
+            IOUtil.close( output );
+            IOUtil.close( reader );
         }
+
+        assertTrue( output.toString().indexOf( "<modelVersion\\>4.0.0\\</modelVersion\\>"
) != -1 );
     }
 
     /** @throws Exception  */
@@ -109,7 +108,6 @@
     {
         StringWriter output = null;
         Reader reader = null;
-
         try
         {
             output = new StringWriter();
@@ -117,23 +115,16 @@
 
             Sink sink = new AptSink( output );
             createParser().parse( reader, sink );
-
-            // No section, only subsection 1 and 2
-            assertTrue( output.toString().indexOf( "* {{{SubSection_1}SubSection 1}}" ) !=
-1 );
-            assertTrue( output.toString().indexOf( "* {{{SubSection_1211}SubSection 1211}}"
) == -1 );
         }
         finally
         {
-            if ( output != null )
-            {
-                output.close();
-            }
-
-            if ( reader != null )
-            {
-                reader.close();
-            }
+            IOUtil.close( output );
+            IOUtil.close( reader );
         }
+
+        // No section, only subsection 1 and 2
+        assertTrue( output.toString().indexOf( "* {{{SubSection_1}SubSection 1}}" ) != -1
);
+        assertTrue( output.toString().indexOf( "* {{{SubSection_1211}SubSection 1211}}" )
== -1 );
     }
 
     /**
@@ -146,9 +137,7 @@
         throws IOException, ParseException
     {
         Writer writer = null;
-
         Reader reader = null;
-
         try
         {
             writer = getTestWriter( "test" );
@@ -160,15 +149,8 @@
         }
         finally
         {
-            if ( writer  != null )
-            {
-                writer.close();
-            }
-
-            if ( reader != null )
-            {
-                reader.close();
-            }
+            IOUtil.close( writer );
+            IOUtil.close( reader );
         }
     }
 
@@ -177,5 +159,4 @@
     {
         return "apt";
     }
-
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java?rev=735472&r1=735471&r2=735472&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
Sun Jan 18 07:30:54 2009
@@ -31,6 +31,7 @@
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.TextSink;
 
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -64,18 +65,9 @@
     protected void tearDown()
         throws Exception
     {
-        if ( output != null )
-        {
-            output.close();
-        }
-        if ( reader != null )
-        {
-            reader.close();
-        }
-        if ( writer != null )
-        {
-            writer.close();
-        }
+        IOUtil.close( output );
+        IOUtil.close( reader );
+        IOUtil.close( writer );
 
         super.tearDown();
     }
@@ -304,7 +296,7 @@
         throws Exception
     {
         String result = locateAndParseTestSourceFile( "nested-format" );
-        
+
         assertContainsLines( result, "begin:bold\nbegin:italic\ntext: bold italic\nend:italic"
);
         assertContainsLines( result, "begin:italic\nbegin:bold\ntext: italic bold\nend:bold"
);
         assertContainsLines( result, "begin:bold\nbegin:monospaced\ntext: bold monospaced\nend:monospaced"
);
@@ -380,7 +372,7 @@
     /**
      * DOXIA-247
      *
-     * @throws ParseException 
+     * @throws ParseException
      */
     public void testEndBracketInList()
         throws ParseException
@@ -395,8 +387,8 @@
             + "\n\n* list1"
             + "\n\n* list2"
             + "\n\n* list2{pre}123{/pre}"
-            + "\n123";    
-            
+            + "\n123";
+
         output = new StringWriter();
         Sink sink = new TextSink( output );
 

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java?rev=735472&r1=735471&r2=735472&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
Sun Jan 18 07:30:54 2009
@@ -27,6 +27,7 @@
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.sink.SinkEventElement;
 import org.apache.maven.doxia.sink.SinkEventTestingSink;
+import org.codehaus.plexus.util.IOUtil;
 
 /**
  * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
@@ -64,7 +65,7 @@
         }
         finally
         {
-            reader.close();
+            IOUtil.close( reader );
         }
 
         Iterator it = sink.getEventList().iterator();

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java?rev=735472&r1=735471&r2=735472&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java
Sun Jan 18 07:30:54 2009
@@ -24,6 +24,7 @@
 import org.apache.maven.doxia.sink.SinkTestDocument;
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.module.apt.AptParser;
+import org.codehaus.plexus.util.IOUtil;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -79,8 +80,14 @@
         OutputStream out = new FileOutputStream( outputFile );
 
         Sink sink = new RtfSink( out );
-        SinkTestDocument.generate( sink );
-
-        out.close();
+        try
+        {
+            SinkTestDocument.generate( sink );
+        }
+        finally
+        {
+            sink.close();
+            IOUtil.close( out );
+        }
     }
 }



Mime
View raw message