Skip to content

Commit b83ab88

Browse files
committed
Add a passing test wrt FasterXML/jackson-core#586
1 parent 275275a commit b83ab88

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testSimpleAltSources() throws Exception
5050
assertEquals(1, ((List<?>) ob).size());
5151
}
5252

53-
public void testParserFeatures() throws Exception
53+
public void testParserFeaturesComments() throws Exception
5454
{
5555
final String JSON = "[ /* foo */ 7 ]";
5656
// default won't accept comments, let's change that:
@@ -71,6 +71,36 @@ public void testParserFeatures() throws Exception
7171
}
7272
}
7373

74+
public void testParserFeaturesCtrlChars() throws Exception
75+
{
76+
String FIELD = "a\tb";
77+
String VALUE = "\t";
78+
String JSON = "{ "+quote(FIELD)+" : "+quote(VALUE)+"}";
79+
Map<?, ?> result;
80+
81+
// First: by default, unescaped control characters should not work
82+
try {
83+
result = MAPPER.readValue(JSON, Map.class);
84+
fail("Should not pass with defaylt settings");
85+
} catch (JsonParseException e) {
86+
verifyException(e, "Illegal unquoted character");
87+
}
88+
89+
// But both ObjectReader:
90+
result = MAPPER.readerFor(Map.class)
91+
.with(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS)
92+
.readValue(JSON);
93+
assertEquals(1, result.size());
94+
95+
// and new mapper should work
96+
ObjectMapper mapper2 = JsonMapper.builder()
97+
.enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS)
98+
.build();
99+
result = mapper2.readerFor(Map.class)
100+
.readValue(JSON);
101+
assertEquals(1, result.size());
102+
}
103+
74104
public void testNodeHandling() throws Exception
75105
{
76106
JsonNodeFactory nodes = new JsonNodeFactory(true);

0 commit comments

Comments
 (0)