Way too much

This commit is contained in:
Brian Neumann-Fopiano
2026-08-25 12:52:12 -04:00
parent 2797a5bf22
commit 07cc76614f
131 changed files with 6825 additions and 1093 deletions
@@ -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());
}
}
}