use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncNonStdParsingTest method _testSingleQuotesDefault.
private void _testSingleQuotesDefault(JsonFactory f, int offset, int readSize) {
// First, let's see that by default they are not allowed
String JSON = "[ 'text' ]";
AsyncReaderWrapper p = createParser(f, JSON, offset, readSize);
assertToken(JsonToken.START_ARRAY, p.nextToken());
try {
p.nextToken();
fail("Expected exception");
} catch (StreamReadException e) {
verifyException(e, "Unexpected character ('''");
} finally {
p.close();
}
JSON = "{ 'a':1 }";
p = createParser(f, JSON, offset, readSize);
assertToken(JsonToken.START_OBJECT, p.nextToken());
try {
p.nextToken();
fail("Expected exception");
} catch (StreamReadException e) {
verifyException(e, "Unexpected character ('''");
} finally {
p.close();
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncScopeMatchingTest method testEOFInName.
public void testEOFInName() throws Exception {
final String JSON = "{ \"abcd";
AsyncReaderWrapper p = asyncForBytes(JSON_F, 3, _jsonDoc(JSON), 0);
assertToken(JsonToken.START_OBJECT, p.nextToken());
try {
p.nextToken();
fail("Expected an exception for EOF");
} catch (StreamReadException pe) {
verifyException(pe, "Unexpected end-of-input");
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncScopeMatchingTest method testUnclosedObject.
public void testUnclosedObject() throws Exception {
AsyncReaderWrapper p = asyncForBytes(JSON_F, 3, _jsonDoc("{ \"key\" : 3 "), 0);
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
try {
p.nextToken();
fail("Expected an exception for unclosed OBJECT");
} catch (StreamReadException pe) {
verifyException(pe, "expected an Object property name or END_ARRAY");
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncScopeMatchingTest method testMisssingColon.
public void testMisssingColon() throws Exception {
final String JSON = "{ \"a\" \"b\" }";
AsyncReaderWrapper p = asyncForBytes(JSON_F, 3, _jsonDoc(JSON), 0);
assertToken(JsonToken.START_OBJECT, p.nextToken());
try {
// can be either here, or with next one...
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
p.nextToken();
fail("Expected an exception for missing semicolon");
} catch (StreamReadException pe) {
verifyException(pe, "was expecting a colon");
}
p.close();
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-core by FasterXML.
the class AsyncScopeMatchingTest method testUnclosedArray.
public void testUnclosedArray() throws Exception {
AsyncReaderWrapper p = asyncForBytes(JSON_F, 3, _jsonDoc("[ 1, 2 "), 0);
assertToken(JsonToken.START_ARRAY, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(2, p.getIntValue());
try {
p.nextToken();
fail("Expected an exception for unclosed ARRAY");
} catch (StreamReadException pe) {
verifyException(pe, "expected a value token");
}
}
Aggregations