use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionMvccEnabledSelfTest method testSetSavepoint.
/**
* @throws Exception If failed.
*/
@Test
public void testSetSavepoint() throws Exception {
try (Connection conn = DriverManager.getConnection(URL)) {
assert !conn.getMetaData().supportsSavepoints();
// Disallowed in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.setSavepoint();
return null;
}
}, SQLException.class, "Savepoint cannot be set in auto-commit mode");
conn.setAutoCommit(false);
// Unsupported
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
conn.setSavepoint();
}
});
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.setSavepoint();
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testGetSetSchema.
/**
* @throws Exception If failed.
*/
@Test
public void testGetSetSchema() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
assertEquals("PUBLIC", conn.getSchema());
final String schema = "test";
conn.setSchema(schema);
assertEquals(schema.toUpperCase(), conn.getSchema());
conn.setSchema('"' + schema + '"');
assertEquals(schema, conn.getSchema());
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.setSchema(schema);
}
});
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.getSchema();
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testSetSavepoint.
/**
* @throws Exception If failed.
*/
@Test
public void testSetSavepoint() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
assert !conn.getMetaData().supportsSavepoints();
// Disallowed in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.setSavepoint();
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();
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testGetMetaData.
/**
* @throws Exception If failed.
*/
@Test
public void testGetMetaData() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
DatabaseMetaData meta = conn.getMetaData();
assertNotNull(meta);
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.getMetaData();
}
});
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testGetSetTransactionIsolation.
/**
* @throws Exception If failed.
*/
@Test
public void testGetSetTransactionIsolation() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
// Invalid parameter value
assertThrows(log, new Callable<Object>() {
@SuppressWarnings("MagicConstant")
@Override
public Object call() throws Exception {
conn.setTransactionIsolation(-1);
return null;
}
}, SQLException.class, "Invalid transaction isolation level");
// default level
assertEquals(TRANSACTION_NONE, conn.getTransactionIsolation());
int[] levels = { TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE };
for (int level : levels) {
conn.setTransactionIsolation(level);
assertEquals(level, conn.getTransactionIsolation());
}
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.getTransactionIsolation();
}
});
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.setTransactionIsolation(TRANSACTION_SERIALIZABLE);
}
});
}
}
Aggregations