Skip to content

Integration test fails on JDK > 8 because of Instant resolution change #571

@fkomauli

Description

@fkomauli

Integration tests failure

Test AbstractCodecIntegrationTests::localDateTime fails because it serializes an Instant.now() value and compares it with the deserialized one without truncating it to microseconds.

The test completes successfully on JDK 8 as the Instant resolution is in milliseconds, but fails on JDK 17.

Truncation to microseconds was already used in the same test for LocalDateTimes, and was forgotten out for the Instant case.

Fix

diff --git a/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java b/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java
index 1cd585a..daf3d64 100644
--- a/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java
+++ b/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java
@@ -435,7 +435,7 @@ abstract class AbstractCodecIntegrationTests extends AbstractIntegrationTests {
         testCodec(LocalDateTime.class, LocalDateTime.now().truncatedTo(ChronoUnit.MICROS), "TIMESTAMP");
         testCodec(LocalDateTime.class, LocalDateTime.now().truncatedTo(ChronoUnit.MICROS), "TIMESTAMPTZ");
 
-        Instant now = Instant.now();
+        Instant now = Instant.now().truncatedTo(ChronoUnit.MICROS);
         LocalDateTime ldt = now.atZone(ZoneId.systemDefault()).toLocalDateTime();
         testCodec(LocalDateTime.class, ldt, Instant.class, (actual, expected) -> {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions