Skip to content

Commit 74e67ce

Browse files
committed
minor test robustification
1 parent 660a429 commit 74e67ce

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ protected ObjectWrapper(final Object object) {
8181
this.object = object;
8282
}
8383
public Object getObject() { return object; }
84-
@JsonCreator
84+
85+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
8586
static ObjectWrapper jsonValue(final Object object) {
8687
return new ObjectWrapper(object);
8788
}

src/test/java/com/fasterxml/jackson/databind/convert/ConvertingAbstractSerializer795Test.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ public AbstractCustomType convert(String arg) {
3232
public static class AbstractCustomTypeUser {
3333
@JsonProperty
3434
@JsonDeserialize(converter = AbstractCustomTypeDeserializationConverter.class)
35-
private final AbstractCustomType customField;
35+
protected AbstractCustomType customField;
3636

37-
@JsonCreator
3837
AbstractCustomTypeUser(@JsonProperty("customField") AbstractCustomType cf) {
3938
this.customField = cf;
4039
}
@@ -74,13 +73,13 @@ public static class NonAbstractCustomTypeUser {
7473
private static final ObjectMapper JSON_MAPPER = newObjectMapper();
7574

7675
public void testAbstractTypeDeserialization() throws Exception {
77-
String test="{\"customField\": \"customString\"}";
76+
String test = aposToQuotes("{'customField': 'customString'}");
7877
AbstractCustomTypeUser cu = JSON_MAPPER.readValue(test, AbstractCustomTypeUser.class);
7978
assertNotNull(cu);
8079
}
8180

8281
public void testNonAbstractDeserialization() throws Exception {
83-
String test="{\"customField\": \"customString\"}";
82+
String test = aposToQuotes("{'customField': 'customString'}");
8483
NonAbstractCustomTypeUser cu = JSON_MAPPER.readValue(test, NonAbstractCustomTypeUser.class);
8584
assertNotNull(cu);
8685
}

src/test/java/com/fasterxml/jackson/databind/deser/jdk/MapDeserializationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public static enum ConcreteType implements ITestType {
7777
}
7878

7979
static class ClassStringMap extends HashMap<Class<?>,String> { }
80-
80+
81+
static class ObjectWrapperMap extends HashMap<String, ObjectWrapper> { }
82+
8183
/*
8284
/**********************************************************
8385
/* Test methods, untyped (Object valued) maps
@@ -151,14 +153,12 @@ public void testUntypedMap3() throws Exception
151153
"{ \"double\":42.0, \"string\":\"string\","
152154
+"\"boolean\":true, \"list\":[\"list0\"],"
153155
+"\"null\":null }";
154-
155-
static class ObjectWrapperMap extends HashMap<String, ObjectWrapper> { }
156-
156+
157157
public void testSpecialMap() throws IOException
158158
{
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);
162162
}
163163

164164
public void testGenericMap() throws IOException

src/test/java/com/fasterxml/jackson/databind/introspect/TestAnnotationBundles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static class RecursiveHolder2 {
7979
static class RecursiveHolder3 {
8080
public int x;
8181

82-
@JsonCreator
82+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
8383
@HolderA
8484
public RecursiveHolder3(int x) { this.x = x; }
8585
}

src/test/java/com/fasterxml/jackson/databind/jsontype/ext/ExternalTypeId198Test.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,32 @@ static class Character {
2626
public static abstract class Attack {
2727
public String side;
2828

29-
@JsonCreator
30-
public Attack(String side) {
29+
protected Attack(String side) {
3130
this.side = side;
3231
}
3332
}
3433

3534
public static class Kick extends Attack {
36-
@JsonCreator
35+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
3736
public Kick(String side) {
3837
super(side);
3938
}
4039
}
4140

4241
public static class Punch extends Attack {
43-
@JsonCreator
42+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
4443
public Punch(String side) {
4544
super(side);
4645
}
4746
}
4847

49-
final ObjectMapper MAPPER = new ObjectMapper();
48+
/*
49+
/**********************************************************
50+
/* Test methods
51+
/**********************************************************
52+
*/
53+
54+
final ObjectMapper MAPPER = newObjectMapper();
5055

5156
public void testFails() throws Exception {
5257
String json = "{ \"name\": \"foo\", \"attack\":\"right\" } }";

src/test/java/com/fasterxml/jackson/databind/jsontype/ext/ExternalTypeIdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public void testIssue798() throws Exception
399399
Base base = new Derived1("derived1 prop val", "base prop val");
400400
BaseContainer baseContainer = new BaseContainer("bc prop val", base);
401401
String generatedJson = MAPPER.writeValueAsString(baseContainer);
402-
BaseContainer baseContainer2 = MAPPER.readValue(generatedJson,BaseContainer.class);
402+
BaseContainer baseContainer2 = MAPPER.readValue(generatedJson, BaseContainer.class);
403403
assertEquals("bc prop val", baseContainer.getBaseContainerProperty());
404404

405405
Base b = baseContainer2.getBase();

0 commit comments

Comments
 (0)