Skip to content

Commit e69a17a

Browse files
committed
feat: Add test cases of bug FasterXML#19
1 parent 86ca36c commit e69a17a

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

jakarta-jsonp/src/test/java/com/fasterxml/jackson/datatype/jsonp/JsonValueDeserializationTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.fasterxml.jackson.databind.node.ObjectNode;
88

9+
import java.beans.ConstructorProperties;
10+
911
public class JsonValueDeserializationTest extends TestBase
1012
{
1113
private final ObjectMapper MAPPER = newMapper();
@@ -109,4 +111,24 @@ public void testNullNode() throws Exception
109111
final JsonValue deserializedNull = MAPPER.readValue(serializedNull, JsonValue.class);
110112
assertEquals(JsonValue.NULL, deserializedNull);
111113
}
114+
115+
// for [datatype-jsr353#19]
116+
public void testConstructorProperties() throws Exception
117+
{
118+
final String JSON = "{\"obj1\":{}}";
119+
ObjectImpl ob = MAPPER.readValue(JSON, ObjectImpl.class);
120+
assertTrue(ob.obj1 instanceof JsonObject);
121+
assertNull(ob.obj2);
122+
}
123+
124+
static class ObjectImpl {
125+
JsonValue obj1;
126+
JsonValue obj2;
127+
128+
@ConstructorProperties({"obj1", "obj2"})
129+
public ObjectImpl(JsonValue obj1, JsonValue obj2) {
130+
this.obj1 = obj1;
131+
this.obj2 = obj2;
132+
}
133+
}
112134
}

jsr-353/src/test/java/com/fasterxml/jackson/datatype/jsr353/JsonValueDeserializationTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.fasterxml.jackson.databind.node.ObjectNode;
88

9+
import java.beans.ConstructorProperties;
10+
911
public class JsonValueDeserializationTest extends TestBase
1012
{
1113
private final ObjectMapper MAPPER = newMapper();
@@ -109,4 +111,24 @@ public void testNullNode() throws Exception
109111
final JsonValue deserializedNull = MAPPER.readValue(serializedNull, JsonValue.class);
110112
assertEquals(JsonValue.NULL, deserializedNull);
111113
}
114+
115+
// for [datatype-jsr353#19]
116+
public void testConstructorProperties() throws Exception
117+
{
118+
final String JSON = "{\"obj1\":{}}";
119+
ObjectImpl ob = MAPPER.readValue(JSON, ObjectImpl.class);
120+
assertTrue(ob.obj1 instanceof JsonObject);
121+
assertNull(ob.obj2);
122+
}
123+
124+
static class ObjectImpl {
125+
JsonValue obj1;
126+
JsonValue obj2;
127+
128+
@ConstructorProperties({"obj1", "obj2"})
129+
public ObjectImpl(JsonValue obj1, JsonValue obj2) {
130+
this.obj1 = obj1;
131+
this.obj2 = obj2;
132+
}
133+
}
112134
}

0 commit comments

Comments
 (0)