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/08/01 20:04:36 UTC
svn commit: r1509356 -
/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
Author: bodewig
Date: Thu Aug 1 18:04:36 2013
New Revision: 1509356
URL: http://svn.apache.org/r1509356
Log:
buffer input and add a test that skips a large amount of bytes by winding forward to the end of the archive
Modified:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java?rev=1509356&r1=1509355&r2=1509356&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java Thu Aug 1 18:04:36 2013
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
import java.util.Random;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
@@ -39,14 +41,42 @@ public class BigFilesIT {
readFileBiggerThan8GByte("/8.posix.tar.gz");
}
+ @Test
+ public void readFileHeadersOfArchiveBiggerThan8GByte() throws Exception {
+ InputStream in = null;
+ GzipCompressorInputStream gzin = null;
+ TarArchiveInputStream tin = null;
+ try {
+ in = new BufferedInputStream(BigFilesIT.class
+ .getResourceAsStream("/8.posix.tar.gz")
+ );
+ gzin = new GzipCompressorInputStream(in);
+ tin = new TarArchiveInputStream(gzin);
+ TarArchiveEntry e = tin.getNextTarEntry();
+ assertNotNull(e);
+ assertNull(tin.getNextTarEntry());
+ } finally {
+ if (tin != null) {
+ tin.close();
+ }
+ if (gzin != null) {
+ gzin.close();
+ }
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+
private void readFileBiggerThan8GByte(String name) throws Exception {
- GzipCompressorInputStream in = null;
+ InputStream in = null;
+ GzipCompressorInputStream gzin = null;
TarArchiveInputStream tin = null;
try {
- in =
- new GzipCompressorInputStream(BigFilesIT.class
- .getResourceAsStream(name));
- tin = new TarArchiveInputStream(in);
+ in = new BufferedInputStream(BigFilesIT.class
+ .getResourceAsStream(name));
+ gzin = new GzipCompressorInputStream(in);
+ tin = new TarArchiveInputStream(gzin);
TarArchiveEntry e = tin.getNextTarEntry();
assertNotNull(e);
assertEquals(8200l * 1024 * 1024, e.getSize());
@@ -70,6 +100,9 @@ public class BigFilesIT {
if (tin != null) {
tin.close();
}
+ if (gzin != null) {
+ gzin.close();
+ }
if (in != null) {
in.close();
}