diff --git a/datetime/src/test/java/tools/jackson/datatype/jsr310/ser/DurationSerTest.java b/datetime/src/test/java/tools/jackson/datatype/jsr310/ser/DurationSerTest.java index f7dbdae9..e47d4042 100644 --- a/datetime/src/test/java/tools/jackson/datatype/jsr310/ser/DurationSerTest.java +++ b/datetime/src/test/java/tools/jackson/datatype/jsr310/ser/DurationSerTest.java @@ -41,6 +41,14 @@ static class MyDto224 { public Duration getDuration() { return duration; } } + // [datetime#282] + static class Bean282 { + @JsonFormat(pattern = "SECONDS") + public Duration duration; + + public Bean282(Duration d) { duration = d; } + } + @Test public void testSerializationAsTimestampNanoseconds01() throws Exception { @@ -362,9 +370,19 @@ protected ObjectMapper _mapperForPatternOverride(String pattern) { // [datetime#224] @Test - public void testDurationFormatOverride() throws Exception + public void testDurationFormatOverrideMinutes() throws Exception { assertEquals(a2q("{'mins':120}"), WRITER.writeValueAsString(new MyDto224(Duration.ofHours(2)))); } + + // [datetime#282] + @Test + public void testDurationFormatOverrideSeconds() throws Exception + { + final Duration maxDuration = Duration.ofSeconds(Long.MIN_VALUE); + assertEquals(a2q("{'duration':"+Long.MIN_VALUE+"}"), + WRITER.writeValueAsString(new Bean282(maxDuration))); + } + }