-
-
Notifications
You must be signed in to change notification settings - Fork 797
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
9bf8284
commit fde2133
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/test/java/com/fasterxml/jackson/core/failing/TestJsonParserSymbols.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,43 @@ | ||
package com.fasterxml.jackson.core.failing; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
import com.fasterxml.jackson.core.json.ReaderBasedJsonParser; | ||
import com.fasterxml.jackson.core.json.UTF8StreamJsonParser; | ||
|
||
@SuppressWarnings("serial") | ||
public class TestJsonParserSymbols | ||
extends com.fasterxml.jackson.test.BaseTest | ||
{ | ||
public void testSymbolsWithNullBytes() throws Exception { | ||
_testSymbolsWithNull(true); | ||
} | ||
|
||
public void testSymbolsWithNullChars() throws Exception { | ||
_testSymbolsWithNull(false); | ||
} | ||
|
||
private void _testSymbolsWithNull(boolean useBytes) throws Exception | ||
{ | ||
final JsonFactory f = new JsonFactory(); | ||
final String INPUT = "{\"\\u0000abc\" : 1, \"abc\" : 2}"; | ||
JsonParser parser = useBytes ? f.createParser(INPUT.getBytes("UTF-8")) | ||
: f.createParser(INPUT); | ||
|
||
assertToken(JsonToken.START_OBJECT, parser.nextToken()); | ||
|
||
assertToken(JsonToken.FIELD_NAME, parser.nextToken()); | ||
assertEquals("\u0000abc", parser.getCurrentName()); | ||
assertToken(JsonToken.VALUE_NUMBER_INT, parser.nextToken()); | ||
assertEquals(1, parser.getIntValue()); | ||
|
||
assertToken(JsonToken.FIELD_NAME, parser.nextToken()); | ||
assertEquals("abc", parser.getCurrentName()); | ||
assertToken(JsonToken.VALUE_NUMBER_INT, parser.nextToken()); | ||
assertEquals(2, parser.getIntValue()); | ||
|
||
assertToken(JsonToken.END_OBJECT, parser.nextToken()); | ||
parser.close(); | ||
} | ||
} |