-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for #15, as well as tentative feature enum
- Loading branch information
1 parent
d6c0b4c
commit 939c7f9
Showing
2 changed files
with
80 additions
and
0 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
67 changes: 67 additions & 0 deletions
67
csv/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/SkipEmptyLines15Test.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,67 @@ | ||
package com.fasterxml.jackson.dataformat.csv.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.dataformat.csv.*; | ||
|
||
public class SkipEmptyLines15Test extends ModuleTestBase | ||
{ | ||
@JsonPropertyOrder({ "age", "name", "cute" }) | ||
protected static class Entry { | ||
public int age; | ||
public String name; | ||
public boolean cute; | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods, success | ||
/********************************************************************** | ||
*/ | ||
|
||
// for [dataformats-text#15]: Allow skipping of empty lines | ||
public void testSkipEmptyLinesFeature() throws Exception | ||
{ | ||
final String CSV = "1,\"xyz\"\n\ntrue,\n"; | ||
|
||
CsvMapper mapper = mapperForCsv(); | ||
mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY); | ||
|
||
// First, verify default behavior: | ||
|
||
String[][] rows = mapper.readValue(CSV, String[][].class); | ||
assertEquals(3, rows.length); | ||
String[] row; | ||
|
||
row = rows[0]; | ||
assertEquals(2, row.length); | ||
assertEquals("1",row[0]); | ||
assertEquals("xyz", row[1]); | ||
|
||
row = rows[1]; | ||
assertEquals(1, row.length); | ||
assertEquals("", row[0]); | ||
|
||
row = rows[2]; | ||
assertEquals(2, row.length); | ||
assertEquals("true", row[0]); | ||
assertEquals("", row[1]); | ||
|
||
mapper.enable(CsvParser.Feature.SKIP_EMPTY_LINES); | ||
|
||
// when wrapped as an array, we'll get array of Lists: | ||
rows = mapper.readerFor(String[][].class) | ||
.with(CsvParser.Feature.WRAP_AS_ARRAY) | ||
.readValue(CSV); | ||
|
||
assertEquals(2, rows.length); | ||
row = rows[0]; | ||
assertEquals(2, row.length); | ||
assertEquals("1",row[0]); | ||
assertEquals("xyz", row[1]); | ||
|
||
row = rows[1]; | ||
assertEquals(2, row.length); | ||
assertEquals("true", row[0]); | ||
assertEquals("", row[1]); | ||
} | ||
} |