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 testCommit.
/**
* @throws Exception If failed.
*/
@Test
public void testCommit() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
// Should not be called in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.commit();
return null;
}
}, SQLException.class, "Transaction cannot be committed explicitly in auto-commit mode");
assertTrue(conn.getAutoCommit());
// Should not be called in auto-commit mode
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.commit();
return null;
}
}, SQLException.class, "Transaction cannot be committed explicitly in auto-commit mode.");
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.commit();
}
});
}
}
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 testGetSetClientInfoProperties.
/**
* @throws Exception If failed.
*/
@Test
public void testGetSetClientInfoProperties() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
final String name = "ApplicationName";
final String val = "SelfTest";
final Properties props = new Properties();
props.setProperty(name, val);
conn.setClientInfo(props);
Properties propsResult = conn.getClientInfo();
assertNotNull(propsResult);
assertTrue(propsResult.isEmpty());
conn.close();
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.getClientInfo();
}
});
assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.setClientInfo(props);
return null;
}
}, SQLClientInfoException.class, "Connection is closed");
}
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinConnectionSelfTest method testCreateStatement.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateStatement() throws Exception {
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
try (Statement stmt = conn.createStatement()) {
assertNotNull(stmt);
stmt.close();
conn.close();
// Exception when called on closed connection
checkConnectionClosed(new RunnableX() {
@Override
public void runx() throws Exception {
conn.createStatement();
}
});
}
}
}
Aggregations