cleanup in tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/compress/trunk@1654149 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
index a512e36..416f90a 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
@@ -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.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 @@
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 @@
@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 @@
za.setUnixMode(UnixStat.FILE_FLAG | 0664);
return za;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
index dcbd143..6c76d56 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
@@ -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 @@
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 @@
}
};
}
-}
\ No newline at end of file
+}