From e72baae40fdae39bb8e678c69145ab4ddb74ca04 Mon Sep 17 00:00:00 2001 From: Samantha Williamson Date: Wed, 30 Oct 2019 16:12:01 -0500 Subject: [PATCH] Add failing test to cover #148 --- .../jsr310/failing/LocalDateDeserTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/LocalDateDeserTest.java diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/LocalDateDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/LocalDateDeserTest.java new file mode 100644 index 00000000..a1342543 --- /dev/null +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/failing/LocalDateDeserTest.java @@ -0,0 +1,32 @@ +package com.fasterxml.jackson.datatype.jsr310.failing; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.OptBoolean; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.exc.InvalidFormatException; +import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; +import org.junit.Test; + +import java.time.LocalDate; + +/** + * + */ +public class LocalDateDeserTest extends ModuleTestBase { + private final ObjectMapper MAPPER = newMapper(); + + final static class StrictWrapper { + @JsonFormat(pattern="yyyy-MM-dd", + lenient = OptBoolean.FALSE) + public LocalDate value; + + public StrictWrapper() { } + public StrictWrapper(LocalDate v) { value = v; } + } + + @Test(expected = InvalidFormatException.class) + public void testStrictCustomFormat() throws Exception + { + StrictWrapper w = MAPPER.readValue("{\"value\":\"2019-11-31\"}", StrictWrapper.class); + } +}