mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Attempt to fix CI failures
Attempt to fix CI failures caused by timezone differences and different JDK versions. See gh-37668
This commit is contained in:
parent
560527945b
commit
42f50fa292
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ExplodedArchiveTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getClassPathUrlsWhenNoPredicartesReturnsUrls() throws Exception {
|
||||
void getClassPathUrlsWhenNoPredicatesReturnsUrls() throws Exception {
|
||||
Set<URL> 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<JarEntry> 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();
|
||||
|
@ -35,22 +35,10 @@ import java.util.zip.ZipEntry;
|
||||
*/
|
||||
public abstract class TestJar {
|
||||
|
||||
public static final int MULTI_JAR_VERSION = Runtime.version().feature();
|
||||
|
||||
private static final int BASE_VERSION = 8;
|
||||
|
||||
private static final int RUNTIME_VERSION;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user