Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also use tempDir and file will be deleted by JUnit

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