完善mock和测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@796 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-16 05:00:15 +00:00
parent fad33c53a8
commit a90633b176
4 changed files with 201 additions and 3 deletions
@@ -38,6 +38,9 @@ public class PoolableStatementTest extends TestCase {
Assert.assertEquals(null, stmt.getConnection());
Assert.assertEquals(false, stmt.isPoolable());
stmt.toString();
}
public void test_MaxRows() throws Exception {
}
}
@@ -213,4 +213,163 @@ public class PoolableStatementTest2 extends TestCase {
stmt.close();
conn.close();
}
public void test_MaxRows() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.setMaxRows(44);
Assert.assertEquals(44, stmt.getMaxRows());
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.getMaxRows();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.setMaxRows(23);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
public void test_cancel() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.cancel();
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.cancel();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
public void test_getWarnings() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.getWarnings();
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.getWarnings();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
public void test_clearWarnings() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.clearWarnings();
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.clearWarnings();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
public void test_setCursorName() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.setCursorName("c_name");
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.setCursorName("c_name");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
public void test_getResultSet() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.getResultSet();
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.getResultSet();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
public void test_getUpdateCount() throws Exception {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.getUpdateCount();
((PoolableStatement) stmt).getStatement().close();
{
SQLException error = null;
try {
stmt.getUpdateCount();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
stmt.close();
conn.close();
}
}