use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class BetweenOperatorIntegrationTest method betweenSymmetricPredicateTypeCheckTest.
@Test
public void betweenSymmetricPredicateTypeCheckTest() {
int cycleCounter = 0;
for (ExpressionType<?> fieldType : TESTED_TYPES) {
putAll(fieldType.nonNullValues().toArray());
for (ExpressionType<?> lowerBoundType : TESTED_TYPES) {
for (ExpressionType<?> upperBoundType : TESTED_TYPES) {
++cycleCounter;
ExpressionBiValue biValue = ExpressionBiValue.createBiValue(lowerBoundType.valueFrom(), upperBoundType.valueTo());
Tuple2<List<SqlRow>, HazelcastSqlException> comparisonEquivalentResult = executePossiblyFailingQuery(// the queries have extra spaces so that the errors are on the same positions
"SELECT this FROM map WHERE (this >= ? AND this <= ?) OR (this >= ? AND this <= ?) ORDER BY this", fieldType.getFieldConverterType().getTypeFamily().getPublicType(), biValue.field1(), biValue.field2(), biValue.field2(), biValue.field1());
try {
checkSuccessOrFailure("SELECT this FROM map WHERE this BETWEEN SYMMETRIC ? AND ? ORDER BY this", comparisonEquivalentResult, biValue.field1(), biValue.field2());
} catch (Throwable e) {
throw new AssertionError("For [" + fieldType + ", " + lowerBoundType + ", " + upperBoundType + "]: " + e, e);
}
}
}
}
assertEquals(TESTED_TYPES.length * TESTED_TYPES.length * TESTED_TYPES.length, cycleCounter);
}
use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class BetweenOperatorIntegrationTest method betweenAsymmetricPredicateTypeCheckTest.
@Test
public void betweenAsymmetricPredicateTypeCheckTest() {
for (ExpressionType<?> fieldType : TESTED_TYPES) {
putAll(fieldType.nonNullValues().toArray());
for (ExpressionType<?> lowerBoundType : TESTED_TYPES) {
for (ExpressionType<?> upperBoundType : TESTED_TYPES) {
ExpressionBiValue biValue = ExpressionBiValue.createBiValue(lowerBoundType.valueFrom(), upperBoundType.valueTo());
Tuple2<List<SqlRow>, HazelcastSqlException> comparisonEquivalentResult = executePossiblyFailingQuery(// the queries have extra spaces so that the errors are on the same positions
"SELECT this FROM map WHERE this >= ? AND this <= ? ORDER BY this", fieldType.getFieldConverterType().getTypeFamily().getPublicType(), biValue.field1(), biValue.field2());
try {
checkSuccessOrFailure("SELECT this FROM map WHERE this BETWEEN ? AND ? ORDER BY this", comparisonEquivalentResult, biValue.field1(), biValue.field2());
} catch (Throwable e) {
throw new AssertionError("For [" + fieldType + ", " + lowerBoundType + ", " + upperBoundType + "]: " + e, e);
}
}
}
}
}
use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class BetweenOperatorIntegrationTest method executePossiblyFailingQuery.
/**
* Execute a query and return either the result, or the exception it threw.
*/
protected Tuple2<List<SqlRow>, HazelcastSqlException> executePossiblyFailingQuery(String sql, SqlColumnType firstColumnExpectedType, Object... params) {
try {
SqlResult result = instance().getSql().execute(sql, params);
List<SqlRow> rows = new ArrayList<>();
for (SqlRow row : result) {
assertEquals(firstColumnExpectedType, row.getMetadata().getColumn(0).getType());
rows.add(row);
}
return tuple2(rows, null);
} catch (HazelcastSqlException e) {
return tuple2(Collections.emptyList(), e);
}
}
use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class SqlClientResultTest method checkSqlException.
private void checkSqlException(Runnable task, int expectedCode, String expectedMessage) {
HazelcastSqlException err = assertThrows(HazelcastSqlException.class, task);
assertEquals(expectedCode, err.getCode());
assertTrue(err.getMessage(), err.getMessage().contains(expectedMessage));
}
use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class SqlErrorClientTest method testMemberDisconnect_close.
@Test
public void testMemberDisconnect_close() {
instance1 = newHazelcastInstance(true);
client = newClient();
createMapping(instance1, MAP_NAME, long.class, long.class);
populate(instance1, DEFAULT_CURSOR_BUFFER_SIZE + 1);
try {
SqlResult result = client.getSql().execute(query());
instance1.shutdown();
for (SqlRow ignore : result) {
// No-op.
}
result.close();
fail("Should fail");
} catch (HazelcastSqlException e) {
assertErrorCode(SqlErrorCode.CONNECTION_PROBLEM, e);
}
}
Aggregations