|
7 | 7 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
8 | 8 | import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
|
9 | 9 | import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
10 |
| - |
| 10 | +import com.fasterxml.jackson.databind.BaseMapTest; |
11 | 11 | import com.fasterxml.jackson.databind.DeserializationFeature;
|
12 | 12 | import com.fasterxml.jackson.databind.JsonMappingException;
|
13 | 13 | import com.fasterxml.jackson.databind.ObjectMapper;
|
14 | 14 | import com.fasterxml.jackson.databind.ObjectReader;
|
| 15 | +import com.fasterxml.jackson.databind.exc.MismatchedInputException; |
15 | 16 |
|
16 | 17 | import org.junit.Rule;
|
17 | 18 | import org.junit.Test;
|
|
20 | 21 | import static org.junit.Assert.assertEquals;
|
21 | 22 | import static org.junit.Assert.assertNull;
|
22 | 23 | import static org.junit.Assert.assertSame;
|
| 24 | +import static org.junit.Assert.fail; |
23 | 25 |
|
24 | 26 | // for [databind#2404]
|
25 | 27 | public class TestPropertyCreatorSubtypesExternalPropertyMissingProperty
|
26 | 28 | {
|
27 |
| - @Rule |
28 |
| - public ExpectedException thrown = ExpectedException.none(); |
29 |
| - |
30 | 29 | /**
|
31 | 30 | * Base class - external property for Fruit subclasses.
|
32 | 31 | */
|
@@ -243,8 +242,11 @@ private void checkAppleBoxNull(ObjectReader reader, String json) throws Exceptio
|
243 | 242 | }
|
244 | 243 |
|
245 | 244 | private void checkBoxJsonMappingException(ObjectReader reader, String json) throws Exception {
|
246 |
| - thrown.expect(JsonMappingException.class); |
247 |
| - thrown.expectMessage("Missing property 'fruit' for external type id 'type'"); |
248 |
| - reader.readValue(json); |
| 245 | + try { |
| 246 | + reader.readValue(json); |
| 247 | + fail("Should not pass"); |
| 248 | + } catch (MismatchedInputException e) { |
| 249 | + BaseMapTest.verifyException(e, "Missing property 'fruit' for external type id 'type'"); |
| 250 | + } |
249 | 251 | }
|
250 | 252 | }
|
0 commit comments