use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testGetMoreResultsCloseAll.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testGetMoreResultsCloseAll() throws Exception {
assertFalse(stmt.getMoreResults(Statement.CLOSE_CURRENT_RESULT));
assertFalse(stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT));
assertFalse(stmt.getMoreResults(Statement.CLOSE_ALL_RESULTS));
stmt.execute("select 1; ");
ResultSet rs = stmt.getResultSet();
assertFalse(stmt.getMoreResults(Statement.CLOSE_ALL_RESULTS));
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT);
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinPreparedStatementSelfTest method testCustomObjectSupportCanBeDisabled.
/**
* Ensure custom object support could be disabled via disabledFeatures connection property
* - start grid and create and fill table such one of the columns was user's object
* - from another connection with disabledFeatures set to {@link JdbcThinFeature#CUSTOM_OBJECT}
* execute query with filter by this object
* - verify that exception is thrown when you try to set custom object as statement param
* @throws SQLException
*/
@Test
public void testCustomObjectSupportCanBeDisabled() throws SQLException {
try (Connection conn = createConnection(JdbcThinFeature.CUSTOM_OBJECT);
PreparedStatement stmt = conn.prepareStatement(SQL_PART + " where objVal is not distinct from ?")) {
Throwable t = GridTestUtils.assertThrowsWithCause(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setObject(1, new TestObjectField(100, "AAAA"));
}
}, SQLException.class);
Assert.assertThat(t.getMessage(), is(containsString("Custom objects are not supported")));
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinResultSetSelfTest method testExceptionOnClosedResultSet.
/**
* @throws Exception If failed.
*/
@Test
public void testExceptionOnClosedResultSet() throws Exception {
final ResultSet rs = stmt.executeQuery(SQL);
rs.close();
// Must do nothing on closed result set
rs.close();
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBoolean(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBoolean("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getByte(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getByte("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getShort(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getShort("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getInt(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getInt("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getLong(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getLong("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getFloat(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getFloat("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getDouble(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getDouble("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getString(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getString("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBytes(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBytes("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getDate(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getDate(1, new GregorianCalendar());
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getDate("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getDate("id", new GregorianCalendar());
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTime(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTime(1, new GregorianCalendar());
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTime("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTime("id", new GregorianCalendar());
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTimestamp(1);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTimestamp(1, new GregorianCalendar());
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTimestamp("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getTimestamp("id", new GregorianCalendar());
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getObject("objVal");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getObject("objVal", TestObjectField.class);
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.wasNull();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getMetaData();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.next();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.last();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.afterLast();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.beforeFirst();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.first();
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.findColumn("id");
}
});
checkResultSetClosed(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getRow();
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinResultSetSelfTest method testNotSupportedTypes.
/**
* @throws Exception If failed.
*/
@Test
public void testNotSupportedTypes() throws Exception {
final ResultSet rs = stmt.executeQuery(SQL);
assert rs.next();
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getArray(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getArray("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getAsciiStream(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getAsciiStream("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBinaryStream(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBinaryStream("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBlob(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getBlob("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getClob(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getClob("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getCharacterStream(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getCharacterStream("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getNCharacterStream(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getNCharacterStream("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getNClob(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getNClob("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getRef(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getRef("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getRowId(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getRowId("id");
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getSQLXML(1);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
rs.getSQLXML("id");
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class DynamicIndexAbstractBasicSelfTest method checkCreate.
/**
* Check normal create operation.
*
* @param mode Mode.
* @param atomicityMode Atomicity mode.
* @param near Near flag.
* @throws Exception If failed.
*/
private void checkCreate(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
initialize(mode, atomicityMode, near);
final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
assertIgniteSqlException(new RunnableX() {
@Override
public void runx() throws Exception {
dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
}
}, IgniteQueryErrorCode.INDEX_ALREADY_EXISTS);
dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
}
Aggregations