use of com.hazelcast.internal.json.ParseException in project hazelcast by hazelcast.
the class JsonParser_Test method assertParseException.
private void assertParseException(int offset, String message, final String json) {
ParseException exception = assertException(ParseException.class, new Runnable() {
public void run() {
parser.parse(json);
}
});
assertEquals(offset, exception.getLocation().offset);
assertThat(exception.getMessage(), startsWith(message + " at"));
}
use of com.hazelcast.internal.json.ParseException in project hazelcast by hazelcast.
the class JsonParser_Test method parse_failsOnTooDeeplyNestedArray.
@Test
public void parse_failsOnTooDeeplyNestedArray() {
JsonArray array = new JsonArray();
for (int i = 0; i < 1001; i++) {
array = new JsonArray().add(array);
}
final String input = array.toString();
ParseException exception = assertException(ParseException.class, new RunnableEx() {
public void run() throws IOException {
parser.parse(input);
}
});
assertEquals("Nesting too deep at 1:1002", exception.getMessage());
}
use of com.hazelcast.internal.json.ParseException in project hazelcast by hazelcast.
the class JsonParser_Test method parse_handlesPositionsCorrectlyWhenInputExceedsBufferSize.
@Test
public void parse_handlesPositionsCorrectlyWhenInputExceedsBufferSize() {
final String input = "{\n \"a\": 23,\n \"b\": 42,\n}";
ParseException exception = assertException(ParseException.class, new RunnableEx() {
public void run() throws IOException {
parser.parse(new StringReader(input), 3);
}
});
assertEquals(new Location(24, 4, 1), exception.getLocation());
}
Aggregations