Skip to content

Commit

Permalink
(v2.17.4) Add test against #124 (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
JooHyukKim authored Nov 20, 2024
1 parent d9b51aa commit 1dd9e69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,29 @@ public void testStrictCustomFormatForValidDateAndTimeWithoutEra() throws Excepti
assertEquals(w.value, LocalDateTime.of(2019, 11, 30, 20, 45));
}

// [datatype-jsr310#124] Issue serializing and deserializing LocalDateTime.MAX and LocalDateTime.MIN
@Test
public void testDeserializationOfLocalDateTimeMax() throws Exception
{
ObjectMapper enabledMapper = mapperBuilder()
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
_testLocalDateTimeRoundTrip(enabledMapper, LocalDateTime.MAX);
_testLocalDateTimeRoundTrip(enabledMapper, LocalDateTime.MIN);

ObjectMapper disabledMapper = mapperBuilder()
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
_testLocalDateTimeRoundTrip(disabledMapper, LocalDateTime.MAX);
_testLocalDateTimeRoundTrip(disabledMapper, LocalDateTime.MIN);
}

private void _testLocalDateTimeRoundTrip(ObjectMapper mapper, LocalDateTime localDateTime)
throws Exception
{
String ser = mapper.writeValueAsString(localDateTime);
LocalDateTime result = mapper.readValue(ser, LocalDateTime.class);
assertEquals(localDateTime, result);
}

private void expectSuccess(ObjectReader reader, Object exp, String json) throws IOException {
final LocalDateTime value = reader.readValue(a2q(json));
assertNotNull("The value should not be null.", value);
Expand Down
6 changes: 5 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ Modules:

2.18.0 (not yet released)

No changes since 2.17
2.17.4 (not yet released)

#124 Issue serializing and deserializing `LocalDateTime.MAX` and `LocalDateTime.MIN`
(reported by @bachilast)
(fix verified by Joo-Hyuk K)

2.17.3 (01-Nov-2024)
2.17.2 (05-Jul-2024)
Expand Down

0 comments on commit 1dd9e69

Please sign in to comment.