This repository has been archived by the owner on Jan 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a (failing for now) unit test for #72, hoping to implement for 2.6.0
- Loading branch information
1 parent
18dd546
commit cd86b3f
Showing
6 changed files
with
93 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/com/fasterxml/jackson/dataformat/csv/failing/NullRead72Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.fasterxml.jackson.dataformat.csv.failing; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.util.*; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.dataformat.csv.*; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
|
||
public class NullRead72Test extends ModuleTestBase | ||
{ | ||
final CsvMapper MAPPER = mapperForCsv(); | ||
|
||
// For [dataformat-csv#72]: recognize "null value" for reading too | ||
public void testReadNullValue() throws Exception | ||
{ | ||
CsvSchema schema = CsvSchema.builder() | ||
.setNullValue("n/a") | ||
.addColumn("id") | ||
.addColumn("desc") | ||
.build(); | ||
|
||
// start by writing, first | ||
String csv = MAPPER.writer(schema).writeValueAsString(new IdDesc("id", null)); | ||
// MUST use doubling for quotes! | ||
assertEquals("id,n/a\n", csv); | ||
|
||
// but read back | ||
|
||
ObjectReader r = MAPPER.readerFor(IdDesc.class) | ||
.with(schema); | ||
|
||
IdDesc result = r.readValue(csv); | ||
assertNotNull(result); | ||
assertEquals("id", result.id); | ||
assertNull(result.desc); | ||
|
||
// also try the other combination | ||
result = r.readValue("n/a,Whatevs\n"); | ||
assertNotNull(result); | ||
assertNull(result.id); | ||
assertEquals("Whatevs", result.desc); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters