Skip to content

Commit 13637cc

Browse files
committed
Add a (passing) test for #330
1 parent 870f868 commit 13637cc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/deser/NullReadTest.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ public Pojo83(String a, String b, int c) {
2323
prop3 = c;
2424
}
2525
}
26-
26+
27+
// [dataformats-text#330]: empty String as null
28+
static class Row330 {
29+
public Integer id;
30+
public String value = "default";
31+
}
32+
2733
/*
2834
/**********************************************************************
2935
/* Test methods
@@ -135,4 +141,22 @@ public void testReadNullValueFromEmptyString() throws Exception
135141
assertEquals("id", result.id);
136142
assertEquals("", result.desc);
137143
}
144+
145+
// [dataformats-text#330]: empty String as null
146+
public void testEmptyStringAsNull330() throws Exception
147+
{
148+
CsvSchema headerSchema = CsvSchema.emptySchema().withHeader();
149+
final String DOC = "id,value\n"
150+
+ "1,\n";
151+
152+
MappingIterator<Row330> iterator = MAPPER
153+
.readerFor(Row330.class)
154+
.with(CsvParser.Feature.EMPTY_STRING_AS_NULL)
155+
.with(headerSchema)
156+
.readValues(DOC);
157+
Row330 row = iterator.next();
158+
159+
assertEquals(Integer.valueOf(1), row.id);
160+
assertNull(row.value);
161+
}
138162
}

0 commit comments

Comments
 (0)