File tree Expand file tree Collapse file tree 6 files changed +24
-19
lines changed
src/test/java/com/fasterxml/jackson/databind Expand file tree Collapse file tree 6 files changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ protected ObjectWrapper(final Object object) {
81
81
this .object = object ;
82
82
}
83
83
public Object getObject () { return object ; }
84
- @ JsonCreator
84
+
85
+ @ JsonCreator (mode = JsonCreator .Mode .DELEGATING )
85
86
static ObjectWrapper jsonValue (final Object object ) {
86
87
return new ObjectWrapper (object );
87
88
}
Original file line number Diff line number Diff line change @@ -32,9 +32,8 @@ public AbstractCustomType convert(String arg) {
32
32
public static class AbstractCustomTypeUser {
33
33
@ JsonProperty
34
34
@ JsonDeserialize (converter = AbstractCustomTypeDeserializationConverter .class )
35
- private final AbstractCustomType customField ;
35
+ protected AbstractCustomType customField ;
36
36
37
- @ JsonCreator
38
37
AbstractCustomTypeUser (@ JsonProperty ("customField" ) AbstractCustomType cf ) {
39
38
this .customField = cf ;
40
39
}
@@ -74,13 +73,13 @@ public static class NonAbstractCustomTypeUser {
74
73
private static final ObjectMapper JSON_MAPPER = newObjectMapper ();
75
74
76
75
public void testAbstractTypeDeserialization () throws Exception {
77
- String test = "{ \" customField\" : \" customString\" }" ;
76
+ String test = aposToQuotes ( "{' customField': ' customString'}" ) ;
78
77
AbstractCustomTypeUser cu = JSON_MAPPER .readValue (test , AbstractCustomTypeUser .class );
79
78
assertNotNull (cu );
80
79
}
81
80
82
81
public void testNonAbstractDeserialization () throws Exception {
83
- String test = "{ \" customField\" : \" customString\" }" ;
82
+ String test = aposToQuotes ( "{' customField': ' customString'}" ) ;
84
83
NonAbstractCustomTypeUser cu = JSON_MAPPER .readValue (test , NonAbstractCustomTypeUser .class );
85
84
assertNotNull (cu );
86
85
}
Original file line number Diff line number Diff line change @@ -77,7 +77,9 @@ public static enum ConcreteType implements ITestType {
77
77
}
78
78
79
79
static class ClassStringMap extends HashMap <Class <?>,String > { }
80
-
80
+
81
+ static class ObjectWrapperMap extends HashMap <String , ObjectWrapper > { }
82
+
81
83
/*
82
84
/**********************************************************
83
85
/* Test methods, untyped (Object valued) maps
@@ -151,14 +153,12 @@ public void testUntypedMap3() throws Exception
151
153
"{ \" double\" :42.0, \" string\" :\" string\" ,"
152
154
+"\" boolean\" :true, \" list\" :[\" list0\" ],"
153
155
+"\" null\" :null }" ;
154
-
155
- static class ObjectWrapperMap extends HashMap <String , ObjectWrapper > { }
156
-
156
+
157
157
public void testSpecialMap () throws IOException
158
158
{
159
- final ObjectWrapperMap map = MAPPER .readValue (UNTYPED_MAP_JSON , ObjectWrapperMap .class );
160
- assertNotNull (map );
161
- _doTestUntyped (map );
159
+ final ObjectWrapperMap map = MAPPER .readValue (UNTYPED_MAP_JSON , ObjectWrapperMap .class );
160
+ assertNotNull (map );
161
+ _doTestUntyped (map );
162
162
}
163
163
164
164
public void testGenericMap () throws IOException
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ static class RecursiveHolder2 {
79
79
static class RecursiveHolder3 {
80
80
public int x ;
81
81
82
- @ JsonCreator
82
+ @ JsonCreator ( mode = JsonCreator . Mode . DELEGATING )
83
83
@ HolderA
84
84
public RecursiveHolder3 (int x ) { this .x = x ; }
85
85
}
Original file line number Diff line number Diff line change @@ -26,27 +26,32 @@ static class Character {
26
26
public static abstract class Attack {
27
27
public String side ;
28
28
29
- @ JsonCreator
30
- public Attack (String side ) {
29
+ protected Attack (String side ) {
31
30
this .side = side ;
32
31
}
33
32
}
34
33
35
34
public static class Kick extends Attack {
36
- @ JsonCreator
35
+ @ JsonCreator ( mode = JsonCreator . Mode . DELEGATING )
37
36
public Kick (String side ) {
38
37
super (side );
39
38
}
40
39
}
41
40
42
41
public static class Punch extends Attack {
43
- @ JsonCreator
42
+ @ JsonCreator ( mode = JsonCreator . Mode . DELEGATING )
44
43
public Punch (String side ) {
45
44
super (side );
46
45
}
47
46
}
48
47
49
- final ObjectMapper MAPPER = new ObjectMapper ();
48
+ /*
49
+ /**********************************************************
50
+ /* Test methods
51
+ /**********************************************************
52
+ */
53
+
54
+ final ObjectMapper MAPPER = newObjectMapper ();
50
55
51
56
public void testFails () throws Exception {
52
57
String json = "{ \" name\" : \" foo\" , \" attack\" :\" right\" } }" ;
Original file line number Diff line number Diff line change @@ -399,7 +399,7 @@ public void testIssue798() throws Exception
399
399
Base base = new Derived1 ("derived1 prop val" , "base prop val" );
400
400
BaseContainer baseContainer = new BaseContainer ("bc prop val" , base );
401
401
String generatedJson = MAPPER .writeValueAsString (baseContainer );
402
- BaseContainer baseContainer2 = MAPPER .readValue (generatedJson ,BaseContainer .class );
402
+ BaseContainer baseContainer2 = MAPPER .readValue (generatedJson , BaseContainer .class );
403
403
assertEquals ("bc prop val" , baseContainer .getBaseContainerProperty ());
404
404
405
405
Base b = baseContainer2 .getBase ();
You can’t perform that action at this time.
0 commit comments