Skip to content

Commit

Permalink
Add failing test for #251
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 1, 2024
1 parent 8c91746 commit 3753cd7
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.fasterxml.jackson.dataformat.ion.failing;

import org.junit.Test;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.ion.IonObjectMapper;
import com.fasterxml.jackson.dataformat.ion.ionvalue.IonValueModule;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

// For [dataformats-binary#251]
public class IonTimestampDeser251Test
{
static class Message {
final String message;
final Integer count;

@JsonCreator
public Message(@JsonProperty("message") String message,
@JsonProperty("count") Integer count) {
this.message = message;
this.count = count;
}

public String getMessage() {
return message;
}
}

private final ObjectMapper ION_MAPPER = IonObjectMapper.builder()
.addModule(new IonValueModule())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.build();

// [dataformats-binary#251]
@Test
public void testTimestampDeserWithBuffering() throws Exception {
String ion = "{message: \"Hello, world\", timestamp:2021-03-10T01:49:30.242-00:00}";
Message message = ION_MAPPER.readValue(ion, Message.class);
assertNotNull(message);
assertEquals("Hello, world", message.message);
}
}

0 comments on commit 3753cd7

Please sign in to comment.