mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
完善mock和测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@808 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -323,4 +323,33 @@ public class PoolablePreparedStatementTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void test_setRef() throws Exception {
|
||||
|
||||
stmt.setRef(1, null);
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setRef(0, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
public void test_setArray() throws Exception {
|
||||
|
||||
stmt.setArray(1, null);
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setArray(0, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.druid.bvt.pool.basic;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
@@ -804,5 +805,130 @@ public class PoolableStatementTest2 extends TestCase {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_wasNull() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
CallableStatement stmt = conn.prepareCall("SELELCT 1");
|
||||
|
||||
stmt.wasNull();
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.wasNull();
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_executeQuery() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement("SELELCT 1");
|
||||
|
||||
stmt.executeQuery();
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.executeQuery();
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_executeUpdate_4() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement("SELELCT 1");
|
||||
|
||||
stmt.executeQuery();
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_execute_3() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement("SELELCT 1");
|
||||
|
||||
stmt.execute();
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.execute();
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
public void test_clearParameters() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement("SELELCT 1");
|
||||
|
||||
stmt.clearParameters();
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.clearParameters();
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public void test_addBatch_1() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement("SELELCT 1");
|
||||
|
||||
stmt.addBatch();
|
||||
((PoolableStatement) stmt).getStatement().close();
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.addBatch();
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user