diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/net/protocol/jar/JarUrlTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/net/protocol/jar/JarUrlTests.java index 082550058e6..e35db7f04f0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/net/protocol/jar/JarUrlTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/net/protocol/jar/JarUrlTests.java @@ -44,43 +44,43 @@ class JarUrlTests { @BeforeEach void setup() throws MalformedURLException { this.jarFile = new File(this.temp, "my.jar"); - this.jarFileUrlPath = this.temp.toURI().toURL().toString().substring("file:".length()); + this.jarFileUrlPath = this.jarFile.toURI().toURL().toString().substring("file:".length()).replace("!", "%21"); } @Test void createWithFileReturnsUrl() { - URL url = JarUrl.create(this.temp); + URL url = JarUrl.create(this.jarFile); assertThat(url).hasToString("jar:file:%s!/".formatted(this.jarFileUrlPath)); } @Test void createWithFileAndEntryReturnsUrl() { JarEntry entry = new JarEntry("lib.jar"); - URL url = JarUrl.create(this.temp, entry); + URL url = JarUrl.create(this.jarFile, entry); assertThat(url).hasToString("jar:nested:%s/!lib.jar!/".formatted(this.jarFileUrlPath)); } @Test void createWithFileAndNullEntryReturnsUrl() { - URL url = JarUrl.create(this.temp, (JarEntry) null); + URL url = JarUrl.create(this.jarFile, (JarEntry) null); assertThat(url).hasToString("jar:file:%s!/".formatted(this.jarFileUrlPath)); } @Test void createWithFileAndNameReturnsUrl() { - URL url = JarUrl.create(this.temp, "lib.jar"); + URL url = JarUrl.create(this.jarFile, "lib.jar"); assertThat(url).hasToString("jar:nested:%s/!lib.jar!/".formatted(this.jarFileUrlPath)); } @Test void createWithFileAndNullNameReturnsUrl() { - URL url = JarUrl.create(this.temp, (String) null); + URL url = JarUrl.create(this.jarFile, (String) null); assertThat(url).hasToString("jar:file:%s!/".formatted(this.jarFileUrlPath)); } @Test void createWithFileNameAndPathReturnsUrl() { - URL url = JarUrl.create(this.temp, "lib.jar", "com/example/My.class"); + URL url = JarUrl.create(this.jarFile, "lib.jar", "com/example/My.class"); assertThat(url).hasToString("jar:nested:%s/!lib.jar!/com/example/My.class".formatted(this.jarFileUrlPath)); }