From commits-return-3577-apmail-commons-commits-archive=commons.apache.org@commons.apache.org Sat Jun 21 17:32:32 2008 Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 22686 invoked from network); 21 Jun 2008 17:32:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Jun 2008 17:32:32 -0000 Received: (qmail 4430 invoked by uid 500); 21 Jun 2008 17:32:32 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 4362 invoked by uid 500); 21 Jun 2008 17:32:32 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 4348 invoked by uid 99); 21 Jun 2008 17:32:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Jun 2008 10:32:31 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Jun 2008 17:31:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F415E23889BA; Sat, 21 Jun 2008 10:31:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r670235 - in /commons/sandbox/compress/trunk: pom.xml src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java Date: Sat, 21 Jun 2008 17:31:49 -0000 To: commits@commons.apache.org From: ebourg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080621173149.F415E23889BA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ebourg Date: Sat Jun 21 10:31:49 2008 New Revision: 670235 URL: http://svn.apache.org/viewvc?rev=670235&view=rev Log: Replaced the shutdownStream() methods with IOUtils.closeQuietly() in the test cases Modified: commons/sandbox/compress/trunk/pom.xml commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java Modified: commons/sandbox/compress/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/pom.xml?rev=670235&r1=670234&r2=670235&view=diff ============================================================================== --- commons/sandbox/compress/trunk/pom.xml (original) +++ commons/sandbox/compress/trunk/pom.xml Sat Jun 21 10:31:49 2008 @@ -20,6 +20,12 @@ 3.8.1 test + + commons-io + commons-io + 1.4 + test + Modified: commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java?rev=670235&r1=670234&r2=670235&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java Sat Jun 21 10:31:49 2008 @@ -25,7 +25,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; + +import org.apache.commons.io.IOUtils; import junit.framework.TestCase; @@ -92,9 +93,9 @@ final FileInputStream fileInput = new FileInputStream( DATA_FILE1 ); output.copyEntryContents( fileInput ); output.closeEntry(); - shutdownStream( fileInput ); - shutdownStream( output ); - shutdownStream( fileOutput ); + IOUtils.closeQuietly( fileInput ); + IOUtils.closeQuietly( output ); + IOUtils.closeQuietly( fileOutput ); assertTrue( "Tar files Equal", contentEquals( temp, POSIX_TAR_FILE ) ); temp.delete(); @@ -115,9 +116,9 @@ final FileInputStream fileInput = new FileInputStream( DATA_FILE1 ); output.copyEntryContents( fileInput ); output.closeEntry(); - shutdownStream( fileInput ); - shutdownStream( output ); - shutdownStream( fileOutput ); + IOUtils.closeQuietly( fileInput ); + IOUtils.closeQuietly( output ); + IOUtils.closeQuietly( fileOutput ); //Have to compare it this way as the contents will differ //due to entry created for second part of name @@ -169,11 +170,11 @@ final File temp = new File( BASEDIR_FILE, entryName.length() + "data.txt" );//File.createTempFile( "delete-me", "tar" ); final FileOutputStream output = new FileOutputStream( temp ); input.copyEntryContents( output ); - shutdownStream( output ); + IOUtils.closeQuietly( output ); assertNull( "Next Entry", input.getNextEntry() ); - shutdownStream( input ); + IOUtils.closeQuietly( input ); assertTrue( "Data Equals", contentEquals( temp, DATA_FILE1 ) ); temp.delete(); @@ -218,8 +219,8 @@ } finally { - shutdownStream( input1 ); - shutdownStream( input2 ); + IOUtils.closeQuietly( input1 ); + IOUtils.closeQuietly( input2 ); } } @@ -263,36 +264,4 @@ return true; } } - - private void shutdownStream( final InputStream input ) - { - if( null == input ) - { - return; - } - - try - { - input.close(); - } - catch( final IOException ioe ) - { - } - } - - private void shutdownStream( final OutputStream output ) - { - if( null == output ) - { - return; - } - - try - { - output.close(); - } - catch( final IOException ioe ) - { - } - } } Modified: commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java?rev=670235&r1=670234&r2=670235&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java Sat Jun 21 10:31:49 2008 @@ -28,6 +28,7 @@ import java.io.OutputStream; import org.apache.commons.compress.CompressUtils; +import org.apache.commons.io.IOUtils; import junit.framework.TestCase; @@ -50,9 +51,9 @@ final OutputStream output = new FileOutputStream( outputFile ); final BZip2OutputStream packedOutput = getPackedOutput( output ); CompressUtils.copy( input, packedOutput ); - shutdownStream( input ); - shutdownStream( packedOutput ); - shutdownStream( output ); + IOUtils.closeQuietly( input ); + IOUtils.closeQuietly( packedOutput ); + IOUtils.closeQuietly( output ); compareContents( "asf-logo-huge.tar.bz2", outputFile ); forceDelete( outputFile ); } @@ -74,9 +75,9 @@ final OutputStream output = new FileOutputStream( outputFile ); final BZip2InputStream packedInput = getPackedInput( input ); CompressUtils.copy( packedInput, output ); - shutdownStream( input ); - shutdownStream( packedInput ); - shutdownStream( output ); + IOUtils.closeQuietly( input ); + IOUtils.closeQuietly( packedInput ); + IOUtils.closeQuietly( output ); compareContents( "asf-logo-huge.tar", outputFile ); forceDelete( outputFile ); } @@ -88,12 +89,12 @@ final File outputFile = getOutputFile( ".tar.bz2" ); final OutputStream output = new FileOutputStream( outputFile ); CompressUtils.copy( input, output ); - shutdownStream( input ); - shutdownStream( output ); + IOUtils.closeQuietly( input ); + IOUtils.closeQuietly( output ); assertTrue( "Check output file exists." , outputFile.exists() ); final InputStream input2 = new FileInputStream( outputFile ); final InputStream packedInput = getPackedInput( input2 ); - shutdownStream( packedInput ); + IOUtils.closeQuietly( packedInput ); try { input2.read(); @@ -126,8 +127,8 @@ final InputStream input1 = getInputStream( initial ); final InputStream input2 = new FileInputStream( generated ); final boolean test = contentEquals( input1, input2 ); - shutdownStream( input1 ); - shutdownStream( input2 ); + IOUtils.closeQuietly( input1 ); + IOUtils.closeQuietly( input2 ); assertTrue( "Contents of " + initial + " matches generated version " + generated, test ); } @@ -216,46 +217,4 @@ return filepath.substring( 0, index ); } } - - /** - * Unconditionally close an OutputStream. - * Equivalent to {@link java.io.OutputStream#close()}, except any exceptions will be ignored. - * @param output A (possibly null) OutputStream - */ - private static void shutdownStream( final OutputStream output ) - { - if( null == output ) - { - return; - } - - try - { - output.close(); - } - catch( final IOException ioe ) - { - } - } - - /** - * Unconditionally close an InputStream. - * Equivalent to {@link InputStream#close()}, except any exceptions will be ignored. - * @param input A (possibly null) InputStream - */ - private static void shutdownStream( final InputStream input ) - { - if( null == input ) - { - return; - } - - try - { - input.close(); - } - catch( final IOException ioe ) - { - } - } }