mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-19 15:04:01 +00:00
Way too much
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class JarCompactorTest {
|
||||
@Rule
|
||||
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void preservesFilesAndOmitsDirectoryEntries() throws Exception {
|
||||
File artifact = temporaryFolder.newFile("artifact.jar");
|
||||
byte[] content = "Iris artifact content".getBytes(StandardCharsets.UTF_8);
|
||||
try (JarOutputStream output = new JarOutputStream(new FileOutputStream(artifact))) {
|
||||
output.putNextEntry(new JarEntry("example/"));
|
||||
output.closeEntry();
|
||||
output.putNextEntry(new JarEntry("example/value.txt"));
|
||||
output.write(content);
|
||||
output.closeEntry();
|
||||
}
|
||||
|
||||
JarCompactor.compact(artifact);
|
||||
|
||||
try (JarFile jar = new JarFile(artifact)) {
|
||||
assertNull(jar.getJarEntry("example/"));
|
||||
assertArrayEquals(content, jar.getInputStream(
|
||||
jar.getJarEntry("example/value.txt")).readAllBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user