Search in sources :

Example 6 with RunnableEx

use of com.hazelcast.internal.json.TestUtil.RunnableEx 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());
}
Also used : StringReader(java.io.StringReader) RunnableEx(com.hazelcast.internal.json.TestUtil.RunnableEx) ParseException(com.hazelcast.internal.json.ParseException) IOException(java.io.IOException) Location(com.hazelcast.internal.json.Location) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with RunnableEx

use of com.hazelcast.internal.json.TestUtil.RunnableEx in project hazelcast by hazelcast.

the class JsonValue_Test method writeTo_failsWithNullConfig.

@Test
public void writeTo_failsWithNullConfig() {
    final JsonValue value = new JsonObject();
    assertException(NullPointerException.class, "config is null", new RunnableEx() {

        public void run() throws IOException {
            value.writeTo(new StringWriter(), null);
        }
    });
}
Also used : StringWriter(java.io.StringWriter) RunnableEx(com.hazelcast.internal.json.TestUtil.RunnableEx) IOException(java.io.IOException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with RunnableEx

use of com.hazelcast.internal.json.TestUtil.RunnableEx in project hazelcast by hazelcast.

the class JsonValue_Test method toString_failsWithNullConfig.

@Test
public void toString_failsWithNullConfig() {
    final JsonValue value = new JsonObject();
    assertException(NullPointerException.class, "config is null", new RunnableEx() {

        public void run() throws IOException {
            value.toString(null);
        }
    });
}
Also used : RunnableEx(com.hazelcast.internal.json.TestUtil.RunnableEx) IOException(java.io.IOException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RunnableEx (com.hazelcast.internal.json.TestUtil.RunnableEx)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 IOException (java.io.IOException)8 Test (org.junit.Test)8 ParseException (com.hazelcast.internal.json.ParseException)5 JsonArray (com.hazelcast.internal.json.JsonArray)2 JsonObject (com.hazelcast.internal.json.JsonObject)2 StringReader (java.io.StringReader)2 JsonValue (com.hazelcast.internal.json.JsonValue)1 Location (com.hazelcast.internal.json.Location)1 StringWriter (java.io.StringWriter)1