Skip to content

Commit 2ef7c25

Browse files
authored
Merge pull request #149 from samwill/test-for-strict-localdate-jsonformat
Test for strict localdate jsonformat #148
2 parents 7b4d75d + 5cfa43c commit 2ef7c25

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.fasterxml.jackson.datatype.jsr310.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import com.fasterxml.jackson.annotation.OptBoolean;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
7+
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;
8+
import org.junit.Test;
9+
10+
import java.time.LocalDate;
11+
12+
public class LocalDateDeserTest extends ModuleTestBase {
13+
private final ObjectMapper MAPPER = newMapper();
14+
15+
final static class StrictWrapper {
16+
@JsonFormat(pattern="yyyy-MM-dd",
17+
lenient = OptBoolean.FALSE)
18+
public LocalDate value;
19+
20+
public StrictWrapper() { }
21+
public StrictWrapper(LocalDate v) { value = v; }
22+
}
23+
24+
@Test(expected = InvalidFormatException.class)
25+
public void testStrictCustomFormat() throws Exception
26+
{
27+
StrictWrapper w = MAPPER.readValue("{\"value\":\"2019-11-31\"}", StrictWrapper.class);
28+
}
29+
}

0 commit comments

Comments
 (0)