Skip to content

Commit 68f2a77

Browse files
committed
Add unit tests to try to reproduce #349 (but without success yet)
1 parent b4232dd commit 68f2a77

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/TestAnyProperties.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,16 @@ public void prop(String name, Base value) {
146146
public void testSimpleMapImitation() throws Exception
147147
{
148148
MapImitator mapHolder = MAPPER.readValue
149-
("{ \"a\" : 3, \"b\" : true }", MapImitator.class);
149+
("{ \"a\" : 3, \"b\" : true, \"c\":[1,2,3] }", MapImitator.class);
150150
Map<String,Object> result = mapHolder._map;
151-
assertEquals(2, result.size());
151+
assertEquals(3, result.size());
152152
assertEquals(Integer.valueOf(3), result.get("a"));
153153
assertEquals(Boolean.TRUE, result.get("b"));
154+
Object ob = result.get("c");
155+
assertTrue(ob instanceof List<?>);
156+
List<?> l = (List<?>)ob;
157+
assertEquals(3, l.size());
158+
assertEquals(Integer.valueOf(3), l.get(2));
154159
}
155160

156161
public void testSimpleTyped() throws Exception

src/test/java/com/fasterxml/jackson/databind/deser/TestUntypedDeserialization.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
import com.fasterxml.jackson.core.*;
99

10-
import com.fasterxml.jackson.databind.DeserializationContext;
11-
import com.fasterxml.jackson.databind.JsonNode;
12-
import com.fasterxml.jackson.databind.ObjectMapper;
10+
import com.fasterxml.jackson.databind.*;
1311
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
1412
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
1513
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
@@ -20,7 +18,7 @@
2018
* one that only uses core JDK types; wrappers, Maps and Lists.
2119
*/
2220
public class TestUntypedDeserialization
23-
extends com.fasterxml.jackson.test.BaseTest
21+
extends BaseMapTest
2422
{
2523
@SuppressWarnings("serial")
2624
static class UCStringDeserializer
@@ -151,6 +149,22 @@ public void testSampleDoc() throws Exception
151149
// and that's all folks!
152150
}
153151

152+
public void testNestedUntypes() throws IOException
153+
{
154+
ObjectMapper mapper = objectMapper();
155+
Object root = mapper.readValue(aposToQuotes("{'a':3,'b':[1,2]}"),
156+
Object.class);
157+
assertTrue(root instanceof Map<?,?>);
158+
Map<?,?> map = (Map<?,?>) root;
159+
assertEquals(2, map.size());
160+
assertEquals(Integer.valueOf(3), map.get("a"));
161+
Object ob = map.get("b");
162+
assertTrue(ob instanceof List<?>);
163+
List<?> l = (List<?>) ob;
164+
assertEquals(2, l.size());
165+
assertEquals(Integer.valueOf(2), l.get(1));
166+
}
167+
154168
// [JACKSON-839]: allow 'upgrade' of big integers into Long, BigInteger
155169
public void testObjectSerializeWithLong() throws IOException
156170
{

0 commit comments

Comments
 (0)