diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/NestedJarFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/NestedJarFileTests.java index 1944f30b9f..59b3e7cc8f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/NestedJarFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/NestedJarFileTests.java @@ -352,7 +352,8 @@ class NestedJarFileTests { assertThat(jar.stream().map((entry) -> entry.getName() + ":" + entry.getRealName())).containsExactly( "META-INF/:META-INF/", "META-INF/MANIFEST.MF:META-INF/MANIFEST.MF", "multi-release.dat:multi-release.dat", - "META-INF/versions/17/multi-release.dat:META-INF/versions/17/multi-release.dat"); + "META-INF/versions/%1$d/multi-release.dat:META-INF/versions/%1$d/multi-release.dat" + .formatted(TestJar.MULTI_JAR_VERSION)); } } @@ -361,7 +362,8 @@ class NestedJarFileTests { try (NestedJarFile jar = new NestedJarFile(this.file, "multi-release.jar", Runtime.version())) { assertThat(jar.versionedStream().map((entry) -> entry.getName() + ":" + entry.getRealName())) .containsExactly("META-INF/:META-INF/", "META-INF/MANIFEST.MF:META-INF/MANIFEST.MF", - "multi-release.dat:META-INF/versions/17/multi-release.dat"); + "multi-release.dat:META-INF/versions/%1$d/multi-release.dat" + .formatted(TestJar.MULTI_JAR_VERSION)); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/launch/ExplodedArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/launch/ExplodedArchiveTests.java index 96107512a3..b18164f751 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/launch/ExplodedArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/launch/ExplodedArchiveTests.java @@ -85,7 +85,7 @@ class ExplodedArchiveTests { } @Test - void getClassPathUrlsWhenNoPredicartesReturnsUrls() throws Exception { + void getClassPathUrlsWhenNoPredicatesReturnsUrls() throws Exception { Set urls = this.archive.getClassPathUrls(Archive.ALL_ENTRIES); URL[] expectedUrls = TestJar.expectedEntries().stream().map(this::toUrl).toArray(URL[]::new); assertThat(urls).containsExactlyInAnyOrder(expectedUrls); @@ -123,7 +123,7 @@ class ExplodedArchiveTests { Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); - File destination = new File(this.rootDirectory.getAbsolutePath() + File.separator + entry.getName()); + File destination = new File(this.rootDirectory, entry.getName()); destination.getParentFile().mkdirs(); if (entry.isDirectory()) { destination.mkdir(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/testsupport/TestJar.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/testsupport/TestJar.java index 292fd44b66..efa625e59c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/testsupport/TestJar.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/testsupport/TestJar.java @@ -35,21 +35,9 @@ import java.util.zip.ZipEntry; */ public abstract class TestJar { - private static final int BASE_VERSION = 8; - - private static final int RUNTIME_VERSION; + public static final int MULTI_JAR_VERSION = Runtime.version().feature(); - static { - int version; - try { - Object runtimeVersion = Runtime.class.getMethod("version").invoke(null); - version = (int) runtimeVersion.getClass().getMethod("major").invoke(runtimeVersion); - } - catch (Throwable ex) { - version = BASE_VERSION; - } - RUNTIME_VERSION = version; - } + private static final int BASE_VERSION = 8; public static void create(File file) throws Exception { create(file, false); @@ -120,8 +108,9 @@ public abstract class TestJar { writeManifest(jarOutputStream, "j2", multiRelease); if (multiRelease) { writeEntry(jarOutputStream, "multi-release.dat", BASE_VERSION); - writeEntry(jarOutputStream, String.format("META-INF/versions/%d/multi-release.dat", RUNTIME_VERSION), - RUNTIME_VERSION); + writeEntry(jarOutputStream, + String.format("META-INF/versions/%d/multi-release.dat", MULTI_JAR_VERSION), + MULTI_JAR_VERSION); } else { writeEntry(jarOutputStream, "3.dat", 3); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/zip/ZipCentralDirectoryFileHeaderRecordTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/zip/ZipCentralDirectoryFileHeaderRecordTests.java index a0a8645e9c..5fe7e9ee88 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/zip/ZipCentralDirectoryFileHeaderRecordTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/zip/ZipCentralDirectoryFileHeaderRecordTests.java @@ -16,6 +16,8 @@ package org.springframework.boot.loader.zip; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.zip.ZipEntry; import org.junit.jupiter.api.Test; @@ -129,7 +131,8 @@ class ZipCentralDirectoryFileHeaderRecordTests { record.copyTo(dataBlock, 0, entry); assertThat(entry.getMethod()).isEqualTo(ZipEntry.DEFLATED); assertThat(entry.getTimeLocal()).hasYear(2007); - assertThat(entry.getTime()).isEqualTo(1172356386000L); + ZonedDateTime expectedTime = ZonedDateTime.of(2007, 02, 24, 14, 33, 06, 0, ZoneId.systemDefault()); + assertThat(entry.getTime()).isEqualTo(expectedTime.toEpochSecond() * 1000); assertThat(entry.getCrc()).isEqualTo(0xFFFFFFFFL); assertThat(entry.getCompressedSize()).isEqualTo(1); assertThat(entry.getSize()).isEqualTo(2);