|
| 1 | +package com.fasterxml.jackson.dataformat.ion.failing; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | + |
| 5 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 6 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 7 | +import com.fasterxml.jackson.databind.DeserializationFeature; |
| 8 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 9 | +import com.fasterxml.jackson.dataformat.ion.IonObjectMapper; |
| 10 | +import com.fasterxml.jackson.dataformat.ion.ionvalue.IonValueModule; |
| 11 | + |
| 12 | +import static org.junit.Assert.assertEquals; |
| 13 | +import static org.junit.Assert.assertNotNull; |
| 14 | + |
| 15 | +// For [dataformats-binary#251] |
| 16 | +public class IonTimestampDeser251Test |
| 17 | +{ |
| 18 | + static class Message { |
| 19 | + final String message; |
| 20 | + final Integer count; |
| 21 | + |
| 22 | + @JsonCreator |
| 23 | + public Message(@JsonProperty("message") String message, |
| 24 | + @JsonProperty("count") Integer count) { |
| 25 | + this.message = message; |
| 26 | + this.count = count; |
| 27 | + } |
| 28 | + |
| 29 | + public String getMessage() { |
| 30 | + return message; |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + private final ObjectMapper ION_MAPPER = IonObjectMapper.builder() |
| 35 | + .addModule(new IonValueModule()) |
| 36 | + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
| 37 | + .build(); |
| 38 | + |
| 39 | + // [dataformats-binary#251] |
| 40 | + @Test |
| 41 | + public void testTimestampDeserWithBuffering() throws Exception { |
| 42 | + String ion = "{message: \"Hello, world\", timestamp:2021-03-10T01:49:30.242-00:00}"; |
| 43 | + Message message = ION_MAPPER.readValue(ion, Message.class); |
| 44 | + assertNotNull(message); |
| 45 | + assertEquals("Hello, world", message.message); |
| 46 | + } |
| 47 | +} |
0 commit comments