From fde213324199fedadd52651c779f5bef139a18a4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 11 Aug 2014 22:07:34 -0700 Subject: [PATCH] Add a (failing) unit test for #148 --- .../core/failing/TestJsonParserSymbols.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test/java/com/fasterxml/jackson/core/failing/TestJsonParserSymbols.java diff --git a/src/test/java/com/fasterxml/jackson/core/failing/TestJsonParserSymbols.java b/src/test/java/com/fasterxml/jackson/core/failing/TestJsonParserSymbols.java new file mode 100644 index 0000000000..97c9ea33e9 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/core/failing/TestJsonParserSymbols.java @@ -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(); + } +}