forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#24690 from Postremus/issues/24686
Fix Banner check on filesystem containing special chars
- Loading branch information
Showing
2 changed files
with
67 additions
and
12 deletions.
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
55 changes: 55 additions & 0 deletions
55
core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/BannerProcessorTest.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,55 @@ | ||
package io.quarkus.deployment.pkg.steps; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.FileSystem; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.deployment.steps.BannerProcessor; | ||
import io.quarkus.fs.util.ZipUtils; | ||
|
||
public class BannerProcessorTest { | ||
|
||
class MyBannerProcessor extends BannerProcessor { | ||
public boolean test(Path path) throws Exception { | ||
return this.isQuarkusCoreBanner(path.toUri().toURL()); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkQuarkusCoreBannerOnFilesystemWithSpecialCharacters() throws Exception { | ||
MyBannerProcessor processor = new MyBannerProcessor(); | ||
|
||
assertFalse(processor.test(Paths.get("tmp", "Descărcări", "test", "something!"))); | ||
|
||
final Path tmpDir = Files.createTempDirectory("Descărcări"); | ||
final Path zipPath = tmpDir.resolve("BannerProcessorTest.jar"); | ||
|
||
try { | ||
try (FileSystem ignored = ZipUtils.newZip(zipPath)) { | ||
} | ||
|
||
try (FileSystem fs = ZipUtils.newFileSystem(zipPath)) { | ||
assertFalse(processor.test(fs.getPath("/"))); | ||
} | ||
|
||
try (final FileSystem fs = ZipUtils.newFileSystem(zipPath)) { | ||
Path classFile = fs.getPath(MyBannerProcessor.class.getName().replace('.', '/') + ".class"); | ||
Files.createDirectories(classFile.getParent()); | ||
Files.write(classFile, "".getBytes(StandardCharsets.UTF_8)); | ||
} | ||
|
||
try (FileSystem fs = ZipUtils.newFileSystem(zipPath)) { | ||
assertTrue(processor.test(fs.getPath("/"))); | ||
} | ||
} finally { | ||
Files.deleteIfExists(zipPath); | ||
} | ||
} | ||
} |