Skip to content

Commit

Permalink
4 more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 5, 2025
1 parent 528a1f3 commit c380926
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ public void setContext(SerializationContext ctxt) {
}
}

private final ObjectMapper MAPPER = newMapper();
// 05-Feb-2025, tatu: Change defaults to Jackson 2.x wrt serialization
// shape (as Timestamps vs Strings)
private final ObjectMapper MAPPER = mapperBuilder()
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();

// // // Local date/time types

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ static class Pojo1 {

@Test
public void testShapeInt() throws Exception {
String json1 = newMapper().writeValueAsString(new Pojo1());
String json1 = MAPPER.writer()
.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.writeValueAsString(new Pojo1());
assertEquals("{\"t1\":1651060800000,\"t2\":1651060800.000000000}", json1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ public void testSerializationWithTypeInfo01() throws Exception
@Test
public void testSerializationWithTypeInfo02() throws Exception
{
ObjectMapper mapper = newMapper();
final LocalDate localDate = LocalDate.of(2017, 12, 5);
String json = mapper.writeValueAsString(new Holder46(localDate, localDate));
String json = MAPPER.writer()
.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.writeValueAsString(new Holder46(localDate, localDate));
assertEquals(a2q("{\"localDate\":[2017,12,5],\"object\":{\"java.time.LocalDate\":[2017,12,5]}}"),
json);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ static class Pojo1 {

@Test
public void testShapeInt() throws Exception {
String json1 = newMapper().writeValueAsString(new Pojo1());
String json1 = MAPPER.writer()
.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.writeValueAsString(new Pojo1());
assertEquals("{\"t1\":1651053600000,\"t2\":1651053600.000000000}", json1);
}
}

0 comments on commit c380926

Please sign in to comment.