Skip to content

Commit

Permalink
Merge branch '2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 8, 2024
2 parents f3ecae0 + 66abd8b commit d6e9abf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public class ColletionFormatShapeTest extends AfterburnerTestBase
// [databind#40]: Allow serialization 'as POJO' (resulting in JSON Object)
@JsonPropertyOrder({ "size", "value" })
@JsonFormat(shape=Shape.POJO)
@JsonIgnoreProperties({ "empty" }) // from 'isEmpty()'
@JsonIgnoreProperties({
"empty", // from 'isEmpty()'
"first", "last" // JDK 21 additions
})
static class CollectionAsPOJO
extends ArrayList<String>
{
Expand Down Expand Up @@ -50,7 +53,14 @@ public void testListAsObjectRoundtrip() throws Exception
list.add("a");
list.add("b");
String json = MAPPER.writeValueAsString(list);
assertEquals("{\"size\":2,\"values\":[\"a\",\"b\"]}", json);

// 2023-10-17, tatu: JDK 21 introduced new properties, so check
// just that we have certain things, ignore extra
JsonNode doc = MAPPER.readTree(json);
//assertEquals("{\"size\":2,\"values\":[\"a\",\"b\"]}", json);

assertEquals(2, doc.path("size").intValue());
assertEquals("[\"a\",\"b\"]", doc.path("values").toString());

// and then bring it back!
CollectionAsPOJO result = MAPPER.readValue(json, CollectionAsPOJO.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public class ColletionFormatShapeTest extends BlackbirdTestBase
// [databind#40]: Allow serialization 'as POJO' (resulting in JSON Object)
@JsonPropertyOrder({ "size", "value" })
@JsonFormat(shape=Shape.POJO)
@JsonIgnoreProperties({ "empty" }) // from 'isEmpty()'
@JsonIgnoreProperties({
"empty", // from 'isEmpty()'
"first", "last" // JDK 21 additions
})
static class CollectionAsPOJO
extends ArrayList<String>
{
Expand Down Expand Up @@ -50,7 +53,14 @@ public void testListAsObjectRoundtrip() throws Exception
list.add("a");
list.add("b");
String json = MAPPER.writeValueAsString(list);
assertEquals("{\"size\":2,\"values\":[\"a\",\"b\"]}", json);

// 2023-10-17, tatu: JDK 21 introduced new properties, so check
// just that we have certain things, ignore extra
JsonNode doc = MAPPER.readTree(json);
//assertEquals("{\"size\":2,\"values\":[\"a\",\"b\"]}", json);

assertEquals(2, doc.path("size").intValue());
assertEquals("[\"a\",\"b\"]", doc.path("values").toString());

// and then bring it back!
CollectionAsPOJO result = MAPPER.readValue(json, CollectionAsPOJO.class);
Expand Down

0 comments on commit d6e9abf

Please sign in to comment.