Skip to content

Commit 74dc786

Browse files
committed
More test fixes
1 parent cd20d1e commit 74dc786

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/test/java/com/fasterxml/jackson/databind/convert/CoerceEmptyToInt3234Test.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
import org.junit.jupiter.api.Test;
44

55
import com.fasterxml.jackson.databind.*;
6+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
67

78
import static org.junit.jupiter.api.Assertions.assertEquals;
89

9-
import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.a2q;
10-
import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.newJsonMapper;
11-
1210
// [databind#3234]
1311
public class CoerceEmptyToInt3234Test
12+
extends DatabindTestUtil
1413
{
1514
static class BasicIntWrapper {
1615
public int value = 13;
@@ -24,7 +23,10 @@ static class BasicDoubleWrapper {
2423
public double value = -1.25;
2524
}
2625

27-
private final ObjectMapper MAPPER = newJsonMapper();
26+
private final ObjectMapper MAPPER = jsonMapperBuilder()
27+
// 08-Jan-2025, tatu: Need to allow null-to-int coercion for some tests
28+
.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
29+
.build();
2830
private final ObjectReader READER_INT_BASIC = MAPPER.readerFor(BasicIntWrapper.class);
2931
private final ObjectReader READER_LONG_BASIC = MAPPER.readerFor(BasicLongWrapper.class);
3032
private final ObjectReader READER_DOUBLE_BASIC = MAPPER.readerFor(BasicDoubleWrapper.class);

src/test/java/com/fasterxml/jackson/databind/convert/CoerceJDKScalarsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ private void _verifyNullOkFromEmpty(Class<?> type, Object exp) throws IOExceptio
8686
{
8787
Object result = COERCING_MAPPER.readerFor(type)
8888
.with(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
89+
// 08-Jan-2025, tatu: Need to allow null-to-int coercion here
90+
.without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
8991
.readValue("\"\"");
9092
if (exp == null) {
9193
assertNull(result);

src/test/java/com/fasterxml/jackson/databind/convert/CoerceStringToIntsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class CoerceStringToIntsTest
3434
.build();
3535

3636
private final ObjectMapper MAPPER_TO_NULL = jsonMapperBuilder()
37+
// 08-Jan-2025, tatu: Need to allow null-to-int coercion for some tests
38+
.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
3739
.withCoercionConfig(LogicalType.Integer, cfg ->
3840
cfg.setCoercion(CoercionInputShape.String, CoercionAction.AsNull))
3941
.build();

src/test/java/com/fasterxml/jackson/databind/convert/ScalarConversionTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
public class ScalarConversionTest
1212
{
13-
private final ObjectMapper MAPPER = newJsonMapper();
13+
// 08-Jan-2025, tatu: Need to allow null-to-int coercion here
14+
private final ObjectMapper MAPPER = jsonMapperBuilder()
15+
.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
16+
.build();
1417

1518
// [databind#1433]
1619
@Test

0 commit comments

Comments
 (0)