Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.GridTestUtils.RunnableX;

/**
* Test that checks indexes handling with JDBC.
Expand Down Expand Up @@ -170,7 +171,7 @@ public void testCreateIndexWithDuplicateName() throws SQLException {

assertSqlException(new RunnableX() {
/** {@inheritDoc} */
@Override public void run() throws Exception {
@Override public void runx() throws Exception {
jdbcRun(CREATE_INDEX);
}
});
Expand Down Expand Up @@ -221,7 +222,7 @@ public void testDropIndex() throws SQLException {
public void testDropMissingIndex() {
assertSqlException(new RunnableX() {
/** {@inheritDoc} */
@Override public void run() throws Exception {
@Override public void runx() throws Exception {
jdbcRun(DROP_INDEX);
}
});
Expand Down Expand Up @@ -314,7 +315,7 @@ private static void assertSqlException(RunnableX r) {
// We expect IgniteSQLException with given code inside CacheException inside JDBC SQLException.

try {
r.run();
r.runx();
}
catch (SQLException e) {
return;
Expand All @@ -325,16 +326,4 @@ private static void assertSqlException(RunnableX r) {

fail(SQLException.class.getSimpleName() + " is not thrown.");
}

/**
* Runnable which can throw checked exceptions.
*/
private interface RunnableX {
/**
* Do run.
*
* @throws Exception If failed.
*/
public void run() throws Exception;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
import org.apache.ignite.internal.processors.port.GridPortRecord;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.GridTestUtils.RunnableX;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;

/**
Expand All @@ -45,68 +45,45 @@ public class JdbcThinAbstractSelfTest extends GridCommonAbstractTest {
* @param r Runnable to check support.
*/
protected void checkNotSupported(final RunnableX r) {
GridTestUtils.assertThrows(log,
new Callable<Object>() {
@Override public Object call() throws Exception {
r.run();

return null;
}
}, SQLFeatureNotSupportedException.class, null);
GridTestUtils.assertThrowsWithCause(r, SQLFeatureNotSupportedException.class);
}

/**
* @param r Runnable to check on closed connection.
*/
protected void checkConnectionClosed(final RunnableX r) {
GridTestUtils.assertThrows(log,
new Callable<Object>() {
@Override public Object call() throws Exception {
r.run();
GridTestUtils.assertThrowsAnyCause(log,
() -> {
r.run();

return null;
}
return null;
}, SQLException.class, "Connection is closed");
}

/**
* @param r Runnable to check on closed statement.
*/
protected void checkStatementClosed(final RunnableX r) {
GridTestUtils.assertThrows(log,
new Callable<Object>() {
@Override public Object call() throws Exception {
r.run();
GridTestUtils.assertThrowsAnyCause(log,
() -> {
r.run();

return null;
}
return null;
}, SQLException.class, "Statement is closed");
}

/**
* @param r Runnable to check on closed result set.
*/
protected void checkResultSetClosed(final RunnableX r) {
GridTestUtils.assertThrows(log,
new Callable<Object>() {
@Override public Object call() throws Exception {
r.run();
GridTestUtils.assertThrowsAnyCause(log,
() -> {
r.run();

return null;
}
return null;
}, SQLException.class, "Result set is closed");
}

/**
* Runnable that can throw an exception.
*/
interface RunnableX {
/**
* @throws Exception On error.
*/
void run() throws Exception;
}

/**
* @param node Node to connect to.
* @param params Connection parameters.
Expand Down
Loading