Search in sources :

Example 1 with SqlClientService

use of com.hazelcast.sql.impl.client.SqlClientService in project hazelcast by hazelcast.

the class SqlErrorClientTest method testMissingHandler.

@Test
public void testMissingHandler() {
    instance1 = newHazelcastInstance(true);
    client = newClient();
    try {
        ClientMessage message = SqlExecute_reservedCodec.encodeRequest("SELECT * FROM table", Collections.emptyList(), 100L, 100);
        SqlClientService clientService = ((SqlClientService) client.getSql());
        Connection connection = clientService.getQueryConnection();
        clientService.invokeOnConnection(connection, message);
        fail("Must fail");
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("Unrecognized client message received"));
    }
}
Also used : Connection(com.hazelcast.internal.nio.Connection) SqlClientService(com.hazelcast.sql.impl.client.SqlClientService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) IOException(java.io.IOException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with SqlClientService

use of com.hazelcast.sql.impl.client.SqlClientService in project hazelcast by hazelcast.

the class SqlNoDeserializationTest method testClient.

@Test
public void testClient() {
    int pageSize = KEY_COUNT / 2;
    SqlClientService clientService = (SqlClientService) client().getSql();
    ClientConnection connection = clientService.getQueryConnection();
    // Get the first page through the "execute" request
    QueryId queryId = QueryId.create(connection.getRemoteUuid());
    ClientMessage executeRequest = SqlExecuteCodec.encodeRequest(SQL, Collections.emptyList(), Long.MAX_VALUE, pageSize, null, SqlExpectedResultType.ROWS.getId(), queryId, false);
    SqlExecuteCodec.ResponseParameters executeResponse = SqlExecuteCodec.decodeResponse(clientService.invokeOnConnection(connection, executeRequest));
    if (executeResponse.error != null) {
        fail(executeResponse.error.getMessage());
    }
    assertNotNull(executeResponse.rowPage);
    assertEquals(pageSize, executeResponse.rowPage.getRowCount());
    // Get the second page through the "execute" request
    ClientMessage fetchRequest = SqlFetchCodec.encodeRequest(queryId, pageSize);
    SqlFetchCodec.ResponseParameters fetchResponse = SqlFetchCodec.decodeResponse(clientService.invokeOnConnection(connection, fetchRequest));
    if (fetchResponse.error != null) {
        fail(fetchResponse.error.getMessage());
    }
    assertNotNull(fetchResponse.rowPage);
    assertEquals(pageSize, fetchResponse.rowPage.getRowCount());
}
Also used : QueryId(com.hazelcast.sql.impl.QueryId) SqlFetchCodec(com.hazelcast.client.impl.protocol.codec.SqlFetchCodec) SqlClientService(com.hazelcast.sql.impl.client.SqlClientService) ClientConnection(com.hazelcast.client.impl.connection.ClientConnection) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) SqlExecuteCodec(com.hazelcast.client.impl.protocol.codec.SqlExecuteCodec) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2 SqlClientService (com.hazelcast.sql.impl.client.SqlClientService)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ClientConnection (com.hazelcast.client.impl.connection.ClientConnection)1 SqlExecuteCodec (com.hazelcast.client.impl.protocol.codec.SqlExecuteCodec)1 SqlFetchCodec (com.hazelcast.client.impl.protocol.codec.SqlFetchCodec)1 Connection (com.hazelcast.internal.nio.Connection)1 HazelcastSerializationException (com.hazelcast.nio.serialization.HazelcastSerializationException)1 HazelcastSqlException (com.hazelcast.sql.HazelcastSqlException)1 QueryId (com.hazelcast.sql.impl.QueryId)1 IOException (java.io.IOException)1