use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testMaxFieldSize.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testMaxFieldSize() throws Exception {
assertTrue(stmt.getMaxFieldSize() >= 0);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.setMaxFieldSize(-1);
return null;
}
}, SQLException.class, "Invalid field limit");
checkNotSupported(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setMaxFieldSize(100);
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testGetSetMaxRows.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testGetSetMaxRows() throws Exception {
assertEquals(0, stmt.getMaxRows());
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.setMaxRows(-1);
return null;
}
}, SQLException.class, "Invalid max rows value");
assertEquals(0, stmt.getMaxRows());
final int maxRows = 1;
stmt.setMaxRows(maxRows);
assertEquals(maxRows, stmt.getMaxRows());
String sqlText = "select * from test";
ResultSet rs = stmt.executeQuery(sqlText);
assertTrue(rs.next());
// max rows reached
assertFalse(rs.next());
stmt.close();
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getMaxRows();
}
});
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setMaxRows(maxRows);
}
});
}
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);
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testExecuteQuery1.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testExecuteQuery1() throws Exception {
final String sqlText = "select val from test";
try (ResultSet rs = stmt.executeQuery(sqlText)) {
assertNotNull(rs);
assertTrue(rs.next());
int val = rs.getInt(1);
assertTrue("Invalid val: " + val, val >= 1 && val <= 10);
}
stmt.close();
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.executeQuery(sqlText);
}
});
}
use of org.apache.ignite.testframework.GridTestUtils.RunnableX in project ignite by apache.
the class JdbcThinStatementSelfTest method testGetSetQueryTimeout.
/**
* @throws Exception If failed.
*/
@org.junit.Test
public void testGetSetQueryTimeout() throws Exception {
assertEquals(0, stmt.getQueryTimeout());
// Invalid argument
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
stmt.setQueryTimeout(-1);
return null;
}
}, SQLException.class, "Invalid timeout value");
assertEquals(0, stmt.getQueryTimeout());
final int timeout = 3;
stmt.setQueryTimeout(timeout);
assertEquals(timeout, stmt.getQueryTimeout());
stmt.close();
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.getQueryTimeout();
}
});
// Call on a closed statement
checkStatementClosed(new RunnableX() {
@Override
public void runx() throws Exception {
stmt.setQueryTimeout(timeout);
}
});
}
Aggregations