From 8f78c6f0fa721ec5e9b67e8b1ff8edfe64a0e0f0 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 25 Jul 2023 15:07:08 -0700 Subject: [PATCH] Split/fork test class for #3906: still failing for 3.0 for now --- .../RecordDeserialization3906Test.java | 63 +++++++++++++++++++ .../RecordDeserialization3906Test.java | 26 +------- 2 files changed, 65 insertions(+), 24 deletions(-) create mode 100644 src/test-jdk14/java/tools/jackson/databind/failing/RecordDeserialization3906Test.java diff --git a/src/test-jdk14/java/tools/jackson/databind/failing/RecordDeserialization3906Test.java b/src/test-jdk14/java/tools/jackson/databind/failing/RecordDeserialization3906Test.java new file mode 100644 index 0000000000..3c2ab79c03 --- /dev/null +++ b/src/test-jdk14/java/tools/jackson/databind/failing/RecordDeserialization3906Test.java @@ -0,0 +1,63 @@ +package tools.jackson.databind.failing; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.PropertyAccessor; + +import tools.jackson.databind.BaseMapTest; +import tools.jackson.databind.ObjectMapper; + +/** + * Test case that covers both failing-by-regression tests and passing tests. + *

For more details, refer to + * + * [databind#3906]: Regression: 2.15.0 breaks deserialization for records when mapper.setVisibility(ALL, NONE); + *

+ * NOTE: fixed for 2.x in 2.16; 2 failing cases still for 3.0. + */ +public class RecordDeserialization3906Test extends BaseMapTest +{ + record Record3906(String string, int integer) { + } + + @JsonAutoDetect(creatorVisibility = Visibility.NON_PRIVATE) + record Record3906Annotated(String string, int integer) { + } + + record Record3906Creator(String string, int integer) { + @JsonCreator + Record3906Creator { + } + } + + /* + /********************************************************** + /* Failing tests that pass in 2.14, fixed in 2.16 but not 3.x + /********************************************************** + */ + + // minimal config for reproduction + public void testEmptyJsonToRecordMiminal() throws Exception { + ObjectMapper mapper = jsonMapperBuilder() + .changeDefaultVisibility(vc -> + vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE)) + .build(); + + Record3906 recordDeser = mapper.readValue("{}", Record3906.class); + + assertEquals(new Record3906(null, 0), recordDeser); + } + + // actual config used reproduction + public void testEmptyJsonToRecordActualImpl() throws Exception { + ObjectMapper mapper = jsonMapperBuilder() + .changeDefaultVisibility(vc -> + vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE) + .withVisibility(PropertyAccessor.FIELD, Visibility.ANY)) + .build(); + Record3906 recordDeser = mapper.readValue("{}", Record3906.class); + + assertEquals(new Record3906(null, 0), recordDeser); + } +} diff --git a/src/test-jdk14/java/tools/jackson/databind/records/RecordDeserialization3906Test.java b/src/test-jdk14/java/tools/jackson/databind/records/RecordDeserialization3906Test.java index 27fadf4fcf..604565443b 100644 --- a/src/test-jdk14/java/tools/jackson/databind/records/RecordDeserialization3906Test.java +++ b/src/test-jdk14/java/tools/jackson/databind/records/RecordDeserialization3906Test.java @@ -40,33 +40,11 @@ private record PrivateRecord3906(String string, int integer) { /* /********************************************************** - /* Failing tests that pass in 2.14 (regression) + /* Failing tests that pass in 2.x /********************************************************** */ - // minimal config for reproduction - public void testEmptyJsonToRecordMiminal() throws Exception { - ObjectMapper mapper = jsonMapperBuilder() - .changeDefaultVisibility(vc -> - vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE)) - .build(); - - Record3906 recordDeser = mapper.readValue("{}", Record3906.class); - - assertEquals(new Record3906(null, 0), recordDeser); - } - - // actual config used reproduction - public void testEmptyJsonToRecordActualImpl() throws Exception { - ObjectMapper mapper = jsonMapperBuilder() - .changeDefaultVisibility(vc -> - vc.withVisibility(PropertyAccessor.ALL, Visibility.NONE) - .withVisibility(PropertyAccessor.FIELD, Visibility.ANY)) - .build(); - Record3906 recordDeser = mapper.readValue("{}", Record3906.class); - - assertEquals(new Record3906(null, 0), recordDeser); - } + // Forked to test class under "failing/" for 3.0 /* /**********************************************************