Skip to content

Commit 5fd8744

Browse files
committed
Test refactoring (remove warning)
1 parent 4663696 commit 5fd8744

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ protected void assertValidLocation(JsonLocation location) {
344344
assertTrue("Should have positive line number", location.getLineNr() > 0);
345345
}
346346

347-
protected void verifyException(Throwable e, String... matches)
347+
public static void verifyException(Throwable e, String... matches)
348348
{
349349
String msg = e.getMessage();
350350
String lmsg = (msg == null) ? "" : msg.toLowerCase();

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
import com.fasterxml.jackson.annotation.JsonTypeInfo;
88
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
99
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
10-
10+
import com.fasterxml.jackson.databind.BaseMapTest;
1111
import com.fasterxml.jackson.databind.DeserializationFeature;
1212
import com.fasterxml.jackson.databind.JsonMappingException;
1313
import com.fasterxml.jackson.databind.ObjectMapper;
1414
import com.fasterxml.jackson.databind.ObjectReader;
15+
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
1516

1617
import org.junit.Rule;
1718
import org.junit.Test;
@@ -20,13 +21,11 @@
2021
import static org.junit.Assert.assertEquals;
2122
import static org.junit.Assert.assertNull;
2223
import static org.junit.Assert.assertSame;
24+
import static org.junit.Assert.fail;
2325

2426
// for [databind#2404]
2527
public class TestPropertyCreatorSubtypesExternalPropertyMissingProperty
2628
{
27-
@Rule
28-
public ExpectedException thrown = ExpectedException.none();
29-
3029
/**
3130
* Base class - external property for Fruit subclasses.
3231
*/
@@ -243,8 +242,11 @@ private void checkAppleBoxNull(ObjectReader reader, String json) throws Exceptio
243242
}
244243

245244
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+
}
249251
}
250252
}

0 commit comments

Comments
 (0)