use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testFetchDirection.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testFetchDirection() throws Exception {
assertEquals(ResultSet.FETCH_FORWARD, stmt.getFetchDirection());
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.setFetchDirection(ResultSet.FETCH_REVERSE);
return null;
}
}, SQLFeatureNotSupportedException.class, "Only forward direction is supported.");
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setFetchDirection(-1);
}
});
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getFetchDirection();
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testWarningsOnClosedStatement.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testWarningsOnClosedStatement() throws Exception {
stmt.clearWarnings();
assertNull(null, stmt.getWarnings());
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getWarnings();
}
});
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.clearWarnings();
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testGetMoreResults.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testGetMoreResults() throws Exception {
assertFalse(stmt.getMoreResults());
stmt.execute("select 1; ");
ResultSet rs = stmt.getResultSet();
assertFalse(stmt.getMoreResults());
assertNull(stmt.getResultSet());
assertTrue(rs.isClosed());
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getMoreResults();
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testAutogenerated.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testAutogenerated() throws Exception {
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.executeUpdate("select 1", -1);
return null;
}
}, SQLException.class, "Invalid autoGeneratedKeys value");
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.execute("select 1", -1);
return null;
}
}, SQLException.class, "Invalid autoGeneratedKeys value");
assertFalse(conn.getMetaData().supportsGetGeneratedKeys());
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getGeneratedKeys();
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.executeUpdate("select 1", Statement.RETURN_GENERATED_KEYS);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.executeUpdate("select 1", new int[] { 1, 2 });
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.executeUpdate("select 1", new String[] { "a", "b" });
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.execute("select 1", Statement.RETURN_GENERATED_KEYS);
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.execute("select 1", new int[] { 1, 2 });
}
});
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.execute("select 1", new String[] { "a", "b" });
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testSetEscapeProcessing.
/**
* @throws Exception If failed.
*/
@org.junit.Test
@Ignore("https://issues.apache.org/jira/browse/IGNITE-5440")
public void testSetEscapeProcessing() throws Exception {
stmt.setEscapeProcessing(false);
final String sqlText = "select {fn CONVERT(1, SQL_BOOLEAN)}";
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
return stmt.executeQuery(sqlText);
}
}, SQLException.class, "Failed to parse");
ResultSet rs = stmt.executeQuery(sqlText);
assertTrue(rs.next());
assertEquals(true, rs.getBoolean(1));
stmt.setEscapeProcessing(true);
stmt.close();
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setEscapeProcessing(true);
}
});
}
Aggregations