Search in sources :

Example 6 with HazelcastSqlException

use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.

the class SqlErrorClientTest method testMemberDisconnect_execute.

/**
 * Test proper handling of member disconnect while waiting for execute result.
 */
@Test
public void testMemberDisconnect_execute() {
    instance1 = newHazelcastInstance(true);
    client = newClient();
    SqlStatement streamingQuery = new SqlStatement("SELECT * FROM TABLE(GENERATE_STREAM(5000))");
    HazelcastSqlException error = assertSqlExceptionWithShutdown(client, streamingQuery);
    assertErrorCode(SqlErrorCode.CONNECTION_PROBLEM, error);
}
Also used : SqlStatement(com.hazelcast.sql.SqlStatement) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with HazelcastSqlException

use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.

the class SqlErrorClientTest method testMemberDisconnect_fetch.

@Test
public void testMemberDisconnect_fetch() {
    instance1 = newHazelcastInstance(true);
    client = newClient();
    createMapping(instance1, MAP_NAME, long.class, long.class);
    populate(instance1, DEFAULT_CURSOR_BUFFER_SIZE + 1);
    // Get the first row.
    boolean shutdown = true;
    try {
        for (SqlRow ignore : client.getSql().execute(query())) {
            // Shutdown the member
            if (shutdown) {
                instance1.shutdown();
                shutdown = false;
            }
        }
        fail("Should fail");
    } catch (HazelcastSqlException e) {
        assertErrorCode(SqlErrorCode.CONNECTION_PROBLEM, e);
    }
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with HazelcastSqlException

use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.

the class SqlErrorClientTest method testParameterError_deserialization.

@Test
public void testParameterError_deserialization() {
    instance1 = newHazelcastInstance(true);
    client = newClient();
    SqlStatement query = new SqlStatement("SELECT * FROM map").addParameter(new BadParameter(false, true));
    HazelcastSqlException error = assertSqlException(client, query);
    assertErrorCode(SqlErrorCode.GENERIC, error);
    assertTrue(error.getMessage().contains("Read error"));
}
Also used : SqlStatement(com.hazelcast.sql.SqlStatement) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with HazelcastSqlException

use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.

the class SqlErrorClientTest method testClientConnectedToLiteMember.

@Test
public void testClientConnectedToLiteMember() {
    factory.newHazelcastInstance(getConfig().setLiteMember(true));
    client = factory.newHazelcastClient(null);
    HazelcastSqlException error = assertSqlException(client, query());
    assertErrorCode(SqlErrorCode.GENERIC, error);
    assertEquals("SQL queries cannot be executed on lite members", error.getMessage());
}
Also used : HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with HazelcastSqlException

use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.

the class SqlErrorAbstractTest method checkTimeout.

protected void checkTimeout(boolean useClient) {
    // Start two instances and fill them with data
    instance1 = newHazelcastInstance(false);
    instance2 = newHazelcastInstance(true);
    client = newClient();
    // Execute query on the instance1.
    SqlStatement query = new SqlStatement("select v from table(generate_stream(1))").setTimeoutMillis(1L);
    HazelcastSqlException error = assertSqlException(useClient ? client : instance1, query);
    assertTrue(error.getMessage().contains("CANCEL_FORCEFUL"));
}
Also used : SqlStatement(com.hazelcast.sql.SqlStatement) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException)

Aggregations

HazelcastSqlException (com.hazelcast.sql.HazelcastSqlException)23 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 Test (org.junit.Test)11 SqlRow (com.hazelcast.sql.SqlRow)8 SqlStatement (com.hazelcast.sql.SqlStatement)7 SqlResult (com.hazelcast.sql.SqlResult)6 ArrayList (java.util.ArrayList)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ExpressionBiValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)3 List (java.util.List)3 SqlColumnType (com.hazelcast.sql.SqlColumnType)2 QueryException (com.hazelcast.sql.impl.QueryException)2 SqlFetchCodec (com.hazelcast.client.impl.protocol.codec.SqlFetchCodec)1 Config (com.hazelcast.config.Config)1 IndexConfig (com.hazelcast.config.IndexConfig)1 IndexType (com.hazelcast.config.IndexType)1 MapConfig (com.hazelcast.config.MapConfig)1 IMap (com.hazelcast.map.IMap)1 SqlColumnMetadata (com.hazelcast.sql.SqlColumnMetadata)1