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 2015/01/23 10:07:27 UTC
svn commit: r1654149 - in
/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip:
ParallelScatterZipCreatorTest.java ScatterZipOutputStreamTest.java
Author: bodewig
Date: Fri Jan 23 09:07:27 2015
New Revision: 1654149
URL: http://svn.apache.org/r1654149
Log:
cleanup in tests
Modified:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java?rev=1654149&r1=1654148&r2=1654149&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java Fri Jan 23 09:07:27 2015
@@ -18,6 +18,7 @@
package org.apache.commons.compress.archivers.zip;
import org.apache.commons.compress.utils.IOUtils;
+import org.junit.After;
import org.junit.Test;
import java.io.ByteArrayInputStream;
@@ -31,6 +32,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import static org.apache.commons.compress.AbstractTestCase.tryHardToDelete;
import static org.junit.Assert.*;
@SuppressWarnings("OctalInteger")
@@ -38,10 +40,19 @@ public class ParallelScatterZipCreatorTe
private final int NUMITEMS = 5000;
+ private File result;
+ private File tmp;
+
+ @After
+ public void cleanup() {
+ tryHardToDelete(result);
+ tryHardToDelete(tmp);
+ }
+
@Test
public void concurrent()
throws Exception {
- File result = File.createTempFile("parallelScatterGather1", "");
+ result = File.createTempFile("parallelScatterGather1", "");
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result);
zos.setEncoding("UTF-8");
ParallelScatterZipCreator zipCreator = new ParallelScatterZipCreator();
@@ -57,14 +68,14 @@ public class ParallelScatterZipCreatorTe
@Test
public void callableApi()
throws Exception {
- File result = File.createTempFile("parallelScatterGather2", "");
+ result = File.createTempFile("parallelScatterGather2", "");
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(result);
zos.setEncoding("UTF-8");
ExecutorService es = Executors.newFixedThreadPool(1);
ScatterGatherBackingStoreSupplier supp = new ScatterGatherBackingStoreSupplier() {
public ScatterGatherBackingStore get() throws IOException {
- return new FileBasedScatterGatherBackingStore(File.createTempFile("parallelscatter", "n1"));
+ return new FileBasedScatterGatherBackingStore(tmp = File.createTempFile("parallelscatter", "n1"));
}
};
@@ -129,4 +140,4 @@ public class ParallelScatterZipCreatorTe
za.setUnixMode(UnixStat.FILE_FLAG | 0664);
return za;
}
-}
\ No newline at end of file
+}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java?rev=1654149&r1=1654148&r2=1654149&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java Fri Jan 23 09:07:27 2015
@@ -18,22 +18,33 @@
package org.apache.commons.compress.archivers.zip;
import org.apache.commons.compress.utils.IOUtils;
+import org.junit.After;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
+import static org.apache.commons.compress.AbstractTestCase.tryHardToDelete;
import static org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequest.createZipArchiveEntryRequest;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class ScatterZipOutputStreamTest {
+ private File scatterFile = null;
+ private File target = null;
+
+ @After
+ public void cleanup() {
+ tryHardToDelete(scatterFile);
+ tryHardToDelete(target);
+ }
+
@Test
public void putArchiveEntry() throws Exception {
- File scatteFile = File.createTempFile("scattertest", ".notzip");
- ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.fileBased(scatteFile);
+ scatterFile = File.createTempFile("scattertest", ".notzip");
+ ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.fileBased(scatterFile);
final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
final byte[] A_PAYLOAD = "XAAY".getBytes();
@@ -47,7 +58,7 @@ public class ScatterZipOutputStreamTest
ByteArrayInputStream payload1 = new ByteArrayInputStream(A_PAYLOAD);
scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae, createPayloadSupplier(payload1)));
- File target = File.createTempFile("scattertest", ".zip");
+ target = File.createTempFile("scattertest", ".zip");
ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(target);
scatterZipOutputStream.writeTo( outputStream);
outputStream.close();
@@ -70,4 +81,4 @@ public class ScatterZipOutputStreamTest
}
};
}
-}
\ No newline at end of file
+}