Skip to content

Commit 7da59ec

Browse files
authored
[master] fix failing tests after FAIL_ON_NULL_FOR_PRIMITIVES to true [databind#4890] (#522)
1 parent b693673 commit 7da59ec

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

csv/src/test/java/tools/jackson/dataformat/csv/deser/BasicCSVParserTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ public void testEmptyHandlingForInteger() throws Exception {
183183
CsvSchema schema = MAPPER.typedSchemaFor(Point.class).withoutHeader();
184184

185185
// First: empty value, to be considered as null
186-
Point result = MAPPER.readerFor(Point.class).with(schema).readValue(",,\n");
186+
Point result = MAPPER.readerFor(Point.class).with(schema)
187+
.without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
188+
.readValue(",,\n");
187189
assertEquals(0, result.x);
188190
assertNull(result.y);
189191
assertNull(result.z);
@@ -193,7 +195,9 @@ public void testStringNullHandlingForInteger() throws Exception {
193195
CsvSchema schema = MAPPER.typedSchemaFor(Point.class).withoutHeader();
194196

195197
// First: empty value, to be considered as null
196-
Point result = MAPPER.readerFor(Point.class).with(schema).readValue("null,null,null\n");
198+
Point result = MAPPER.readerFor(Point.class).with(schema)
199+
.without(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
200+
.readValue("null,null,null\n");
197201
assertEquals(0, result.x);
198202
assertNull(result.y);
199203
assertNull(result.z);

yaml/src/test/java/tools/jackson/dataformat/yaml/deser/NumberDeserWithYAMLTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ public void testTextualNullAsNumber() throws Exception
121121
assertNull(MAPPER.readValue(NULL_JSON, Float.class));
122122
assertNull(MAPPER.readValue(NULL_JSON, Double.class));
123123

124-
assertEquals(Byte.valueOf((byte) 0), MAPPER.readValue(NULL_JSON, Byte.TYPE));
125-
assertEquals(Short.valueOf((short) 0), MAPPER.readValue(NULL_JSON, Short.TYPE));
124+
final YAMLMapper nullsOkMapper = mapperBuilder()
125+
.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
126+
.build();
127+
128+
assertEquals(Byte.valueOf((byte) 0), nullsOkMapper.readValue(NULL_JSON, Byte.TYPE));
129+
assertEquals(Short.valueOf((short) 0), nullsOkMapper.readValue(NULL_JSON, Short.TYPE));
126130

127131
// assertEquals(Character.valueOf((char) 0), MAPPER.readValue(JSON, Character.TYPE));
128-
assertEquals(Integer.valueOf(0), MAPPER.readValue(NULL_JSON, Integer.TYPE));
129-
assertEquals(Long.valueOf(0L), MAPPER.readValue(NULL_JSON, Long.TYPE));
130-
assertEquals(Float.valueOf(0f), MAPPER.readValue(NULL_JSON, Float.TYPE));
131-
assertEquals(Double.valueOf(0d), MAPPER.readValue(NULL_JSON, Double.TYPE));
132+
assertEquals(Integer.valueOf(0), nullsOkMapper.readValue(NULL_JSON, Integer.TYPE));
133+
assertEquals(Long.valueOf(0L), nullsOkMapper.readValue(NULL_JSON, Long.TYPE));
134+
assertEquals(Float.valueOf(0f), nullsOkMapper.readValue(NULL_JSON, Float.TYPE));
135+
assertEquals(Double.valueOf(0d), nullsOkMapper.readValue(NULL_JSON, Double.TYPE));
132136

133137
assertNull(MAPPER.readValue(NULL_JSON, BigInteger.class));
134138
assertNull(MAPPER.readValue(NULL_JSON, BigDecimal.class));

0 commit comments

Comments
 (0)