mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Fix JarUrlTests
Fix `JarUrlTests` to use the jarFile rather than temp.
This commit is contained in:
parent
fc1a5033e8
commit
847daf484c
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user