mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
完善测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@812 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -505,7 +505,11 @@ public class PoolableStatement extends PoolableWrapper implements Statement {
|
||||
|
||||
@Override
|
||||
public final void setPoolable(boolean poolable) throws SQLException {
|
||||
throw new UnsupportedOperationException();
|
||||
if (poolable) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new SQLException("not support");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -931,4 +931,88 @@ public class PoolableStatementTest2 extends TestCase {
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_executeUpdate_5() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
stmt.executeUpdate("SET 1", Statement.RETURN_GENERATED_KEYS);
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.executeUpdate("SET 1", Statement.RETURN_GENERATED_KEYS);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_executeUpdate_6() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
stmt.executeUpdate("SET 1", new String[0]);
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.executeUpdate("SET 1", new String[0]);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_executeUpdate_7() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
stmt.executeUpdate("SET 1", new int[0]);
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.executeUpdate("SET 1", new int[0]);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
public void test_setPoolable() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
stmt.setPoolable(true);
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setPoolable(false);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user