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 JdbcThinConnectionMvccEnabledSelfTest method testCommit.
/**
* @throws Exception If failed.
*/
@Test
public void testCommit() 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.commit();
return null;
}
}, SQLException.class, "Transaction cannot be committed explicitly in auto-commit mode");
conn.setAutoCommit(false);
conn.commit();
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 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);
}
});
}
}
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 JdbcThinStatementSelfTest method testGetSetMaxFieldSizeUnsupported.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testGetSetMaxFieldSizeUnsupported() throws Exception {
assertEquals(0, stmt.getMaxFieldSize());
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.setMaxFieldSize(100);
return null;
}
}, SQLFeatureNotSupportedException.class, "Field size limitation is not supported");
assertEquals(0, stmt.getMaxFieldSize());
stmt.close();
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getMaxFieldSize();
}
});
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setMaxFieldSize(100);
}
});
}
Aggregations