From 9b6a2a59a1b6b9df4de442866cba7713408b14b3 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 12 Apr 2023 22:13:08 -0700 Subject: [PATCH] Set offset when checking date in tests Update integration tests that check the current date so that the offset is set for the current time before comparing results. See gh-34786 --- .../gradle/tasks/bundling/BootBuildImageIntegrationTests.java | 2 +- .../java/org/springframework/boot/maven/BuildImageTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java index 3bd9edf96d..97bf53cc31 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java @@ -322,7 +322,7 @@ class BootBuildImageIntegrationTests { assertThat(result.getOutput()).contains("---> Test Info buildpack done"); Image image = new DockerApi().image().inspect(ImageReference.of("docker.io/library/" + projectName)); OffsetDateTime createdDateTime = OffsetDateTime.parse(image.getCreated()); - OffsetDateTime current = OffsetDateTime.now(); + OffsetDateTime current = OffsetDateTime.now().withOffsetSameInstant(createdDateTime.getOffset()); assertThat(createdDateTime.getYear()).isEqualTo(current.getYear()); assertThat(createdDateTime.getMonth()).isEqualTo(current.getMonth()); assertThat(createdDateTime.getDayOfMonth()).isEqualTo(current.getDayOfMonth()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java index 546134c112..2b67f1035e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java @@ -427,7 +427,7 @@ class BuildImageTests extends AbstractArchiveIntegrationTests { .inspect(ImageReference .of("docker.io/library/build-image-current-created-date:0.0.1.BUILD-SNAPSHOT")); OffsetDateTime createdDateTime = OffsetDateTime.parse(image.getCreated()); - OffsetDateTime current = OffsetDateTime.now(); + OffsetDateTime current = OffsetDateTime.now().withOffsetSameInstant(createdDateTime.getOffset()); assertThat(createdDateTime.getYear()).isEqualTo(current.getYear()); assertThat(createdDateTime.getMonth()).isEqualTo(current.getMonth()); assertThat(createdDateTime.getDayOfMonth()).isEqualTo(current.getDayOfMonth());