Skip to content

Commit 3049e58

Browse files
committed
Merge branch '2.18' into 2.19
2 parents 682fd2f + 760cf8f commit 3049e58

File tree

7 files changed

+23
-53
lines changed

7 files changed

+23
-53
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/creators/TestCreatorsDelegating.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.fasterxml.jackson.annotation.JsonCreator;
99
import com.fasterxml.jackson.annotation.JsonProperty;
1010

11-
import com.fasterxml.jackson.core.JacksonException;
1211
import com.fasterxml.jackson.core.JsonParser;
1312
import com.fasterxml.jackson.core.JsonToken;
1413
import com.fasterxml.jackson.databind.*;
@@ -187,12 +186,7 @@ public void testWithCtorAndDelegate() throws Exception
187186
mapper.setInjectableValues(new InjectableValues.Std()
188187
.addValue(String.class, "Pooka")
189188
);
190-
CtorBean711 bean = null;
191-
try {
192-
bean = mapper.readValue("38", CtorBean711.class);
193-
} catch (JacksonException e) {
194-
fail("Did not expect problems, got: "+e.getMessage());
195-
}
189+
CtorBean711 bean = mapper.readValue("38", CtorBean711.class);
196190
assertEquals(38, bean.age);
197191
assertEquals("Pooka", bean.name);
198192
}
@@ -204,12 +198,7 @@ public void testWithFactoryAndDelegate() throws Exception
204198
mapper.setInjectableValues(new InjectableValues.Std()
205199
.addValue(String.class, "Fygar")
206200
);
207-
FactoryBean711 bean = null;
208-
try {
209-
bean = mapper.readValue("38", FactoryBean711.class);
210-
} catch (JacksonException e) {
211-
fail("Did not expect problems, got: "+e.getMessage());
212-
}
201+
FactoryBean711 bean = mapper.readValue("38", FactoryBean711.class);
213202
assertEquals(38, bean.age);
214203
assertEquals("Fygar", bean.name1);
215204
assertEquals("Fygar", bean.name2);

src/test/java/com/fasterxml/jackson/databind/deser/filter/TestUnknownPropertyDeserialization.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import org.junit.jupiter.api.Test;
77

88
import com.fasterxml.jackson.annotation.*;
9-
10-
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.JsonParser;
1110
import com.fasterxml.jackson.core.type.TypeReference;
1211
import com.fasterxml.jackson.databind.*;
1312
import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
@@ -213,12 +212,7 @@ public void testUnknownHandlingIgnoreWithFeature() throws Exception
213212
{
214213
ObjectMapper mapper = newJsonMapper();
215214
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
216-
TestBean result = null;
217-
try {
218-
result = mapper.readValue(new StringReader(JSON_UNKNOWN_FIELD), TestBean.class);
219-
} catch (JacksonException jex) {
220-
fail("Did not expect a problem, got: "+jex.getMessage());
221-
}
215+
TestBean result = mapper.readValue(new StringReader(JSON_UNKNOWN_FIELD), TestBean.class);
222216
assertNotNull(result);
223217
assertEquals(1, result._a);
224218
assertNull(result._unknown);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.fasterxml.jackson.databind.json.JsonMapper;
1414
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
1515

16-
import static org.junit.Assert.assertEquals;
16+
import static org.junit.jupiter.api.Assertions.assertEquals;
1717

1818
// Tests for [databind#4584]: extension point for discovering "Default"
1919
// Creator (primary Creator, usually constructor, used in case no creator

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.fasterxml.jackson.databind.json.JsonMapper;
1313
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
1414

15-
import static org.junit.Assert.assertEquals;
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
1616

1717
// Tests for [databind#4620]:
1818
//

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@ public void testClassIsMissing()
3636
public void testDeserialize() throws Exception
3737
{
3838
ObjectMapper m = new ObjectMapper();
39-
Parent result = null;
40-
41-
try {
42-
result = m.readValue(" { } ", Parent.class);
43-
} catch (Exception e) {
44-
fail("Should not have had issues, got: "+e);
45-
}
39+
Parent result = m.readValue(" { } ", Parent.class);
4640
assertNotNull(result);
4741
}
4842

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public MultipleTheoreticalGetters(@JsonProperty("a") int foo) {
9696
@Test
9797
public void testIssue193() throws Exception
9898
{
99-
String json = objectWriter().writeValueAsString(new Bean193(1, 2));
99+
String json = MAPPER.writeValueAsString(new Bean193(1, 2));
100100
assertNotNull(json);
101101
}
102102

@@ -111,25 +111,19 @@ public void testNonConflict() throws Exception
111111
@Test
112112
public void testHypotheticalGetters() throws Exception
113113
{
114-
String json = objectWriter().writeValueAsString(new MultipleTheoreticalGetters());
114+
String json = MAPPER.writeValueAsString(new MultipleTheoreticalGetters());
115115
assertEquals(a2q("{'a':3}"), json);
116116
}
117117

118118
// for [jackson-core#158]
119119
@Test
120120
public void testOverrideName() throws Exception
121121
{
122-
final ObjectMapper mapper = newJsonMapper();
123-
String json = mapper.writeValueAsString(new CoreBean158());
122+
String json = MAPPER.writeValueAsString(new CoreBean158());
124123
assertEquals(a2q("{'bar':'x'}"), json);
125124

126125
// and back
127-
CoreBean158 result = null;
128-
try {
129-
result = mapper.readValue(a2q("{'bar':'y'}"), CoreBean158.class);
130-
} catch (Exception e) {
131-
fail("Unexpected failure when reading CoreBean158: "+e);
132-
}
126+
CoreBean158 result = MAPPER.readValue(a2q("{'bar':'y'}"), CoreBean158.class);
133127
assertNotNull(result);
134128
assertEquals("y", result.bar);
135129
}

src/test/java/com/fasterxml/jackson/databind/jsontype/deftyping/DefaultTypeResolver3505Test.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.Collection;
55
import java.util.List;
66

7+
import org.junit.jupiter.api.Test;
8+
79
import com.fasterxml.jackson.annotation.JsonTypeInfo;
810

911
import com.fasterxml.jackson.databind.DeserializationConfig;
@@ -60,24 +62,21 @@ public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, Java
6062
}
6163
}
6264

63-
public void testDeductionWithDefaultTypeResolverBuilder() {
65+
@Test
66+
public void testDeductionWithDefaultTypeResolverBuilder() throws Exception {
6467
final ObjectMapper mapper = jsonMapperBuilder()
6568
.registerSubtypes(Parent.ChildOne.class, Parent.ChildTwo.class)
6669
.setDefaultTyping(new AssertingTypeResolverBuilder()
6770
.init(JsonTypeInfo.Id.DEDUCTION, null))
6871
.build();
6972

70-
try {
71-
final Parent firstRead = mapper.readValue("{ \"one\": \"Hello World\" }", Parent.class);
72-
assertNotNull(firstRead);
73-
assertTrue(firstRead instanceof Parent.ChildOne);
74-
assertEquals("Hello World", ((Parent.ChildOne) firstRead).one);
75-
final Parent secondRead = mapper.readValue("{ \"two\": \"Hello World\" }", Parent.class);
76-
assertNotNull(secondRead);
77-
assertTrue(secondRead instanceof Parent.ChildTwo);
78-
assertEquals("Hello World", ((Parent.ChildTwo) secondRead).two);
79-
} catch (Exception e) {
80-
fail("This call should not throw");
81-
}
73+
final Parent firstRead = mapper.readValue("{ \"one\": \"Hello World\" }", Parent.class);
74+
assertNotNull(firstRead);
75+
assertTrue(firstRead instanceof Parent.ChildOne);
76+
assertEquals("Hello World", ((Parent.ChildOne) firstRead).one);
77+
final Parent secondRead = mapper.readValue("{ \"two\": \"Hello World\" }", Parent.class);
78+
assertNotNull(secondRead);
79+
assertTrue(secondRead instanceof Parent.ChildTwo);
80+
assertEquals("Hello World", ((Parent.ChildTwo) secondRead).two);
8281
}
8382
}

0 commit comments

Comments
 (0)