use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionMvccEnabledSelfTest method testRollback.
/**
* @throws Exception If failed.
*/
@Test
public void testRollback() throws Exception {
try (Connection conn = DriverManager.getConnection(URL)) {
assertTrue(conn.getMetaData().supportsTransactions());
// Should not be called in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.rollback();
return null;
}
}, SQLException.class, "Transaction cannot be rolled back explicitly in auto-commit mode.");
conn.setAutoCommit(false);
conn.rollback();
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.rollback();
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionMvccEnabledSelfTest method testRollbackSavePoint.
/**
* @throws Exception If failed.
*/
@Test
public void testRollbackSavePoint() throws Exception {
try (Connection conn = DriverManager.getConnection(URL)) {
assert !conn.getMetaData().supportsSavepoints();
// Invalid arg
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.rollback(null);
return null;
}
}, SQLException.class, "Invalid savepoint");
final Savepoint savepoint = getFakeSavepoint();
// Disallowed in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.rollback(savepoint);
return null;
}
}, SQLException.class, "Auto-commit mode");
conn.setAutoCommit(false);
// Unsupported
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
conn.rollback(savepoint);
}
});
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.rollback(savepoint);
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionMvccEnabledSelfTest method testGetSetAutoCommit.
/**
* @throws Exception If failed.
*/
@Test
public void testGetSetAutoCommit() throws Exception {
try (Connection conn = DriverManager.getConnection(URL)) {
assertTrue(conn.getMetaData().supportsTransactions());
assertTrue(conn.getAutoCommit());
conn.setAutoCommit(false);
assertFalse(conn.getAutoCommit());
conn.setAutoCommit(true);
assertTrue(conn.getAutoCommit());
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.setAutoCommit(true);
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class DynamicColumnsAbstractConcurrentSelfTest method checkClientReconnect.
/**
* Make sure that client receives schema changes made while it was disconnected, optionally with cache restart
* in the interim.
*
* @param restartCache Whether cache needs to be recreated during client's absence.
* @param dynamicCache Whether recreate, if needed, should be done on dynamic or static cache.
* @throws Exception If failed.
*/
private void checkClientReconnect(final boolean restartCache, boolean dynamicCache) throws Exception {
// Start complex topology.
final IgniteEx srv = ignitionStart(serverConfiguration(1));
ignitionStart(serverConfiguration(2));
ignitionStart(serverConfiguration(3, true));
final Ignite cli = ignitionStart(clientConfiguration(4));
if (dynamicCache) {
createSqlCache(cli);
run(cli, createSql);
}
final String schemaName = dynamicCache ? QueryUtils.DFLT_SCHEMA : "idx";
final QueryField[] cols = new QueryField[] { c("age", Integer.class.getName()), c("city", String.class.getName()) };
// Check index create.
reconnectClientNode(srv, cli, restartCache, dynamicCache, new RunnableX() {
@Override
public void runx() throws Exception {
addCols(srv, schemaName, cols).get();
dropCols(srv, schemaName, "NAME").get();
}
});
checkTableState(srv, schemaName, TBL_NAME, cols);
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class DynamicIndexAbstractBasicSelfTest method checkDropNoIndex.
/**
* Check drop when there is no index.
*
* @param mode Mode.
* @param atomicityMode Atomicity mode.
* @param near Near flag.
* @throws Exception If failed.
*/
private void checkDropNoIndex(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
initialize(mode, atomicityMode, near);
assertIgniteSqlException(new RunnableX() {
@Override
public void runx() throws Exception {
dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
}
}, IgniteQueryErrorCode.INDEX_NOT_FOUND);
dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, true);
assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
}
Aggregations