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"));
}
}
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());
}
Aggregations