Skip to content

Commit

Permalink
Cleanup after "veryLargeJar" test
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed May 27, 2023
1 parent 5888c8e commit b08f77a
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ public void testNonCompressed() throws IOException, ManifestException, ArchiverE
}

@Test
public void testVeryLargeJar() throws IOException, ManifestException, ArchiverException {
public void testVeryLargeJar() throws IOException, ArchiverException {
// Generate some number of random files that is likely to be
// two or three times the number of available file handles
Random rand = new Random();
for (int i = 0; i < 45000; i++) {
Path path = tempDir.resolve("file" + i);
OutputStream out = Files.newOutputStream(path);
byte[] data = new byte[512]; // 512bytes per file
rand.nextBytes(data);
out.write(data);
out.flush();
out.close();
try (OutputStream out = Files.newOutputStream(path)) {
byte[] data = new byte[512]; // 512bytes per file
rand.nextBytes(data);
out.write(data);
out.flush();
}
}

File jarFile = new File("target/output/veryLargeJar.jar");
Expand All @@ -75,6 +75,8 @@ public void testVeryLargeJar() throws IOException, ManifestException, ArchiverEx
archiver.setDestFile(jarFile);
archiver.addDirectory(tempDir.toFile());
archiver.createArchive();
// Clean up
Files.delete(jarFile.toPath());
}

@Test
Expand Down

0 comments on commit b08f77a

Please sign in to comment.