You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2013/04/25 16:18:18 UTC
svn commit: r1475790 -
/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
Author: bodewig
Date: Thu Apr 25 14:18:18 2013
New Revision: 1475790
URL: http://svn.apache.org/r1475790
Log:
properly close stream, submitted by Andreas Krüger
Modified:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java?rev=1475790&r1=1475789&r2=1475790&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java Thu Apr 25 14:18:18 2013
@@ -50,34 +50,38 @@ public class ArchiveStreamFactoryTest {
*/
@Test
public void aiffFilesAreNoTARs() throws Exception {
- InputStream is = null;
- try {
- is = new BufferedInputStream(new FileInputStream("src/test/resources/testAIFF.aif"));
- new ArchiveStreamFactory().createArchiveInputStream(is);
- fail("created an input stream for a non-archive");
- } catch (ArchiveException ae) {
- assertTrue(ae.getMessage().startsWith("No Archiver found"));
- } finally {
- if (is != null) {
+ FileInputStream fis = new FileInputStream("src/test/resources/testAIFF.aif");
+ try {
+ InputStream is = new BufferedInputStream(fis);
+ try {
+ new ArchiveStreamFactory().createArchiveInputStream(is);
+ fail("created an input stream for a non-archive");
+ } catch (ArchiveException ae) {
+ assertTrue(ae.getMessage().startsWith("No Archiver found"));
+ } finally {
is.close();
}
- }
+ } finally {
+ fis.close();
+ }
}
@Test
public void testCOMPRESS209() throws Exception {
- InputStream is = null;
- try {
- is = new BufferedInputStream(new FileInputStream("src/test/resources/testCompress209.doc"));
- new ArchiveStreamFactory().createArchiveInputStream(is);
- fail("created an input stream for a non-archive");
- } catch (ArchiveException ae) {
- assertTrue(ae.getMessage().startsWith("No Archiver found"));
- } finally {
- if (is != null) {
- is.close();
+ FileInputStream fis = new FileInputStream("src/test/resources/testCompress209.doc");
+ try {
+ InputStream bis = new BufferedInputStream(fis);
+ try {
+ new ArchiveStreamFactory().createArchiveInputStream(bis);
+ fail("created an input stream for a non-archive");
+ } catch (ArchiveException ae) {
+ assertTrue(ae.getMessage().startsWith("No Archiver found"));
+ } finally {
+ bis.close();
}
- }
+ } finally {
+ fis.close();
+ }
}
/**
@@ -87,15 +91,21 @@ public class ArchiveStreamFactoryTest {
*/
@Test
public void skipsPK00Prefix() throws Exception {
- InputStream is = null;
- try {
- is = new BufferedInputStream(new FileInputStream("src/test/resources/COMPRESS-208.zip"));
- ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(is);
- assertTrue(ais instanceof ZipArchiveInputStream);
- } finally {
- if (is != null) {
- is.close();
+ FileInputStream fis = new FileInputStream("src/test/resources/COMPRESS-208.zip");
+ try {
+ InputStream bis = new BufferedInputStream(fis);
+ try {
+ ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(bis);
+ try {
+ assertTrue(ais instanceof ZipArchiveInputStream);
+ } finally {
+ ais.close();
+ }
+ } finally {
+ bis.close();
}
- }
+ } finally {
+ fis.close();
+ }
}
}