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.
- Loading branch information
1 parent
8479018
commit 579de90
Showing
8 changed files
with
175 additions
and
24 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
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
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
47 changes: 47 additions & 0 deletions
47
src/test/java/com/fasterxml/jackson/dataformat/csv/TestParserStrictQuoting.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,47 @@ | ||
package com.fasterxml.jackson.dataformat.csv; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
// Tests for [Issue#26] | ||
public class TestParserStrictQuoting extends ModuleTestBase | ||
{ | ||
@JsonPropertyOrder({"a", "b"}) | ||
protected static class AB { | ||
public String a, b; | ||
|
||
public AB() { } | ||
public AB(String a, String b) { | ||
this.a = a; | ||
this.b = b; | ||
} | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
public void testStrictQuoting() throws Exception | ||
{ | ||
final String NUMS = "12345 6789"; | ||
final String LONG = NUMS + NUMS + NUMS + NUMS; // 40 chars should do it | ||
|
||
CsvMapper mapper = mapperForCsv(); | ||
|
||
assertFalse(mapper.getFactory().isEnabled(CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING)); | ||
CsvSchema schema = mapper.schemaFor(AB.class).withoutHeader(); | ||
|
||
final AB input = new AB("x", LONG); | ||
|
||
// with non-strict, should quote | ||
String csv = mapper.writer(schema).writeValueAsString(input); | ||
assertEquals(aposToQuotes("x,'"+LONG+"'"), csv.trim()); | ||
|
||
// should be possible to hot-swap | ||
// and with strict/optimal, no quoting | ||
mapper.configure(CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING, true); | ||
csv = mapper.writer(schema).writeValueAsString(input); | ||
assertEquals(aposToQuotes("x,"+LONG), csv.trim()); | ||
} | ||
} |