Skip to content

Commit

Permalink
Add unit tests to try to reproduce #349 (but without success yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 19, 2013
1 parent b4232dd commit 68f2a77
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,16 @@ public void prop(String name, Base value) {
public void testSimpleMapImitation() throws Exception
{
MapImitator mapHolder = MAPPER.readValue
("{ \"a\" : 3, \"b\" : true }", MapImitator.class);
("{ \"a\" : 3, \"b\" : true, \"c\":[1,2,3] }", MapImitator.class);
Map<String,Object> result = mapHolder._map;
assertEquals(2, result.size());
assertEquals(3, result.size());
assertEquals(Integer.valueOf(3), result.get("a"));
assertEquals(Boolean.TRUE, result.get("b"));
Object ob = result.get("c");
assertTrue(ob instanceof List<?>);
List<?> l = (List<?>)ob;
assertEquals(3, l.size());
assertEquals(Integer.valueOf(3), l.get(2));
}

public void testSimpleTyped() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

import com.fasterxml.jackson.core.*;

import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
Expand All @@ -20,7 +18,7 @@
* one that only uses core JDK types; wrappers, Maps and Lists.
*/
public class TestUntypedDeserialization
extends com.fasterxml.jackson.test.BaseTest
extends BaseMapTest
{
@SuppressWarnings("serial")
static class UCStringDeserializer
Expand Down Expand Up @@ -151,6 +149,22 @@ public void testSampleDoc() throws Exception
// and that's all folks!
}

public void testNestedUntypes() throws IOException
{
ObjectMapper mapper = objectMapper();
Object root = mapper.readValue(aposToQuotes("{'a':3,'b':[1,2]}"),
Object.class);
assertTrue(root instanceof Map<?,?>);
Map<?,?> map = (Map<?,?>) root;
assertEquals(2, map.size());
assertEquals(Integer.valueOf(3), map.get("a"));
Object ob = map.get("b");
assertTrue(ob instanceof List<?>);
List<?> l = (List<?>) ob;
assertEquals(2, l.size());
assertEquals(Integer.valueOf(2), l.get(1));
}

// [JACKSON-839]: allow 'upgrade' of big integers into Long, BigInteger
public void testObjectSerializeWithLong() throws IOException
{
Expand Down

0 comments on commit 68f2a77

Please sign in to comment.