完善测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@812 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-16 08:42:41 +00:00
parent 4976b25439
commit 4e64d71c66
2 changed files with 89 additions and 1 deletions
@@ -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();
}
}