use of com.hazelcast.internal.json.TestUtil.RunnableEx in project hazelcast by hazelcast.
the class JsonParser_Test method parse_failsOnTooDeeplyNestedObject.
@Test
public void parse_failsOnTooDeeplyNestedObject() {
JsonObject object = new JsonObject();
for (int i = 0; i < 1001; i++) {
object = new JsonObject().add("foo", object);
}
final String input = object.toString();
ParseException exception = assertException(ParseException.class, new RunnableEx() {
public void run() throws IOException {
parser.parse(input);
}
});
assertEquals("Nesting too deep at 1:7002", exception.getMessage());
}
use of com.hazelcast.internal.json.TestUtil.RunnableEx in project hazelcast by hazelcast.
the class JsonParser_Test method parse_failsOnTooDeeplyNestedMixedObject.
@Test
public void parse_failsOnTooDeeplyNestedMixedObject() {
JsonValue value = new JsonObject();
for (int i = 0; i < 1001; i++) {
value = i % 2 == 0 ? new JsonArray().add(value) : new JsonObject().add("foo", value);
}
final String input = value.toString();
ParseException exception = assertException(ParseException.class, new RunnableEx() {
public void run() throws IOException {
parser.parse(input);
}
});
assertEquals("Nesting too deep at 1:4002", exception.getMessage());
}
use of com.hazelcast.internal.json.TestUtil.RunnableEx in project hazelcast by hazelcast.
the class JsonValue_Test method writeTo_failsWithNullWriter.
@Test
public void writeTo_failsWithNullWriter() {
final JsonValue value = new JsonObject();
assertException(NullPointerException.class, "writer is null", new RunnableEx() {
public void run() throws IOException {
value.writeTo(null, WriterConfig.MINIMAL);
}
});
}
use of com.hazelcast.internal.json.TestUtil.RunnableEx in project hazelcast by hazelcast.
the class JsonParser_Test method parse_reader_rejectsEmpty.
@Test
public void parse_reader_rejectsEmpty() {
ParseException exception = assertException(ParseException.class, new RunnableEx() {
public void run() throws IOException {
parser.parse(new StringReader(""));
}
});
assertEquals(0, exception.getLocation().offset);
assertThat(exception.getMessage(), startsWith("Unexpected end of input at"));
}
use of com.hazelcast.internal.json.TestUtil.RunnableEx 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());
}
Aggregations