Skip to content

Commit 760cf8f

Browse files
committed
Merge some more parts of #4759
1 parent 77d71c7 commit 760cf8f

File tree

7 files changed

+23
-52
lines changed

7 files changed

+23
-52
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

@@ -188,12 +187,7 @@ public void testWithCtorAndDelegate() throws Exception
188187
mapper.setInjectableValues(new InjectableValues.Std()
189188
.addValue(String.class, "Pooka")
190189
);
191-
CtorBean711 bean = null;
192-
try {
193-
bean = mapper.readValue("38", CtorBean711.class);
194-
} catch (JacksonException e) {
195-
fail("Did not expect problems, got: "+e.getMessage());
196-
}
190+
CtorBean711 bean = mapper.readValue("38", CtorBean711.class);
197191
assertEquals(38, bean.age);
198192
assertEquals("Pooka", bean.name);
199193
}
@@ -205,12 +199,7 @@ public void testWithFactoryAndDelegate() throws Exception
205199
mapper.setInjectableValues(new InjectableValues.Std()
206200
.addValue(String.class, "Fygar")
207201
);
208-
FactoryBean711 bean = null;
209-
try {
210-
bean = mapper.readValue("38", FactoryBean711.class);
211-
} catch (JacksonException e) {
212-
fail("Did not expect problems, got: "+e.getMessage());
213-
}
202+
FactoryBean711 bean = mapper.readValue("38", FactoryBean711.class);
214203
assertEquals(38, bean.age);
215204
assertEquals("Fygar", bean.name1);
216205
assertEquals("Fygar", bean.name2);

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

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

88
import com.fasterxml.jackson.annotation.*;
9-
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.JsonParser;
1010
import com.fasterxml.jackson.core.type.TypeReference;
1111
import com.fasterxml.jackson.databind.*;
1212
import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
@@ -212,12 +212,7 @@ public void testUnknownHandlingIgnoreWithFeature() throws Exception
212212
{
213213
ObjectMapper mapper = newJsonMapper();
214214
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
215-
TestBean result = null;
216-
try {
217-
result = mapper.readValue(new StringReader(JSON_UNKNOWN_FIELD), TestBean.class);
218-
} catch (JacksonException jex) {
219-
fail("Did not expect a problem, got: "+jex.getMessage());
220-
}
215+
TestBean result = mapper.readValue(new StringReader(JSON_UNKNOWN_FIELD), TestBean.class);
221216
assertNotNull(result);
222217
assertEquals(1, result._a);
223218
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
@@ -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#4584]: extension point for discovering "Default"
1818
// 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
@@ -11,7 +11,7 @@
1111
import com.fasterxml.jackson.databind.json.JsonMapper;
1212
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
1313

14-
import static org.junit.Assert.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
1515

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

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
@@ -95,7 +95,7 @@ public MultipleTheoreticalGetters(@JsonProperty("a") int foo) {
9595
@Test
9696
public void testIssue193() throws Exception
9797
{
98-
String json = objectWriter().writeValueAsString(new Bean193(1, 2));
98+
String json = MAPPER.writeValueAsString(new Bean193(1, 2));
9999
assertNotNull(json);
100100
}
101101

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

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

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

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
@@ -13,6 +13,8 @@
1313
import java.util.Collection;
1414
import java.util.List;
1515

16+
import org.junit.jupiter.api.Test;
17+
1618
import static org.junit.jupiter.api.Assertions.*;
1719

1820
// Tests for [databind#3505] causing a NPE when setting a DefaultTypeResolverBuilder
@@ -59,24 +61,21 @@ public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, Java
5961
}
6062
}
6163

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

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

0 commit comments

Comments
 (0)