|
6 | 6 | import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
7 | 7 |
|
8 | 8 | import com.fasterxml.jackson.databind.*;
|
| 9 | +import com.fasterxml.jackson.databind.exc.MismatchedInputException; |
9 | 10 |
|
10 |
| -import org.junit.Rule; |
11 | 11 | import org.junit.Test;
|
12 |
| -import org.junit.rules.ExpectedException; |
13 |
| - |
14 |
| -import static org.junit.Assert.assertEquals; |
15 |
| -import static org.junit.Assert.assertNull; |
16 |
| -import static org.junit.Assert.assertSame; |
17 | 12 |
|
18 | 13 | // for [databind#1341]
|
19 |
| -public class TestSubtypesExternalPropertyMissingProperty |
| 14 | +public class TestSubtypesExternalPropertyMissingProperty extends BaseMapTest |
20 | 15 | {
|
21 |
| - @Rule |
22 |
| - public ExpectedException thrown = ExpectedException.none(); |
23 |
| - |
24 | 16 | /**
|
25 | 17 | * Base class - external property for Fruit subclasses.
|
26 | 18 | */
|
@@ -95,7 +87,7 @@ public Orange(String name, String c) {
|
95 | 87 | }
|
96 | 88 | }
|
97 | 89 |
|
98 |
| - private final ObjectMapper MAPPER = new ObjectMapper(); |
| 90 | + private final ObjectMapper MAPPER = newJsonMapper(); |
99 | 91 |
|
100 | 92 | /*
|
101 | 93 | /**********************************************************
|
@@ -246,14 +238,20 @@ private void checkAppleBoxNull(String json) throws Exception {
|
246 | 238 | }
|
247 | 239 |
|
248 | 240 | private void checkBoxJsonMappingException(String json) throws Exception {
|
249 |
| - thrown.expect(JsonMappingException.class); |
250 |
| - thrown.expectMessage("Missing property 'fruit' for external type id 'type'"); |
251 |
| - MAPPER.readValue(json, Box.class); |
| 241 | + try { |
| 242 | + MAPPER.readValue(json, Box.class); |
| 243 | + fail("Should not pass"); |
| 244 | + } catch (MismatchedInputException e) { |
| 245 | + BaseMapTest.verifyException(e, "Missing property 'fruit' for external type id 'type'"); |
| 246 | + } |
252 | 247 | }
|
253 | 248 |
|
254 | 249 | private void checkReqBoxJsonMappingException(String json) throws Exception {
|
255 |
| - thrown.expect(JsonMappingException.class); |
256 |
| - thrown.expectMessage("Missing property 'fruit' for external type id 'type'"); |
257 |
| - MAPPER.readValue(json, ReqBox.class); |
| 250 | + try { |
| 251 | + MAPPER.readValue(json, ReqBox.class); |
| 252 | + fail("Should not pass"); |
| 253 | + } catch (MismatchedInputException e) { |
| 254 | + BaseMapTest.verifyException(e, "Missing property 'fruit' for external type id 'type'"); |
| 255 | + } |
258 | 256 | }
|
259 | 257 | }
|
0 commit comments