use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testCreateStatement3.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateStatement3() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
int[] rsTypes = new int[] { TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE };
int[] rsConcurs = new int[] { CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE };
int[] rsHoldabilities = new int[] { HOLD_CURSORS_OVER_COMMIT, CLOSE_CURSORS_AT_COMMIT };
DatabaseMetaData meta = conn.getMetaData();
for (final int type : rsTypes) {
for (final int concur : rsConcurs) {
for (final int holdabililty : rsHoldabilities) {
if (meta.supportsResultSetConcurrency(type, concur)) {
assert type == TYPE_FORWARD_ONLY;
assert concur == CONCUR_READ_ONLY;
try (Statement stmt = conn.createStatement(type, concur, holdabililty)) {
assertNotNull(stmt);
assertEquals(type, stmt.getResultSetType());
assertEquals(concur, stmt.getResultSetConcurrency());
assertEquals(holdabililty, stmt.getResultSetHoldability());
}
continue;
}
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
return conn.createStatement(type, concur, holdabililty);
}
}, SQLFeatureNotSupportedException.class, null);
}
}
}
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT);
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testReleaseSavepoint.
/**
* @throws Exception If failed.
*/
@Test
public void testReleaseSavepoint() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
assert !conn.getMetaData().supportsSavepoints();
// Invalid arg
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.releaseSavepoint(null);
return null;
}
}, SQLException.class, "Savepoint cannot be null");
final Savepoint savepoint = getFakeSavepoint();
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
conn.releaseSavepoint(savepoint);
}
});
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.releaseSavepoint(savepoint);
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testSetSavepointName.
/**
* @throws Exception If failed.
*/
@Test
public void testSetSavepointName() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
assert !conn.getMetaData().supportsSavepoints();
// Invalid arg
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.setSavepoint(null);
return null;
}
}, SQLException.class, "Savepoint name cannot be null");
final String name = "savepoint";
// Disallowed in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.setSavepoint(name);
return null;
}
}, SQLException.class, "Savepoint cannot be set in auto-commit mode");
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.setSavepoint(name);
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testCursorName.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testCursorName() throws Exception {
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setCursorName("test");
}
});
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setCursorName("test");
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testGetMoreResultsKeepCurrent.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testGetMoreResultsKeepCurrent() 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.KEEP_CURRENT_RESULT));
assertFalse(rs.isClosed());
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT);
}
});
}
Aggregations