-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for JarResultBuildStep#filterJarFile
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/JarResultBuildStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.deployment.pkg.steps; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Set; | ||
import java.util.jar.JarEntry; | ||
import java.util.jar.JarFile; | ||
import java.util.jar.Manifest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class JarResultBuildStepTest { | ||
|
||
@Test | ||
void should_unsign_jar_when_filtered(@TempDir Path tempDir) throws Exception { | ||
Path signedJarFilePath = Path.of(getClass().getClassLoader().getResource("signed.jar").toURI()); | ||
Path jarFilePath = tempDir.resolve("unsigned.jar"); | ||
JarResultBuildStep.filterJarFile(signedJarFilePath, jarFilePath, Set.of("org/eclipse/jgit/transport/sshd/SshdSessionFactory.class")); | ||
try (JarFile jarFile = new JarFile(jarFilePath.toFile())) { | ||
assertThat(jarFile.stream().map(JarEntry::getName)).doesNotContain("META-INF/ECLIPSE_.RSA", "META-INF/ECLIPSE_.SF"); | ||
// Check that the manifest is still present | ||
Manifest manifest = jarFile.getManifest(); | ||
assertThat(manifest.getMainAttributes()).isNotEmpty(); | ||
assertThat(manifest.getEntries()).isEmpty(); | ||
} | ||
} | ||
} |
Binary file not shown.