完善mock和测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@784 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-16 00:20:56 +00:00
parent fd94af5b57
commit 09c328aa9c
3 changed files with 256 additions and 10 deletions
@@ -765,7 +765,7 @@ public class ResultSetTest extends TestCase {
{
SQLException error = null;
try {
resultSet.updateBlob(0, (InputStream) null, 1);
resultSet.updateAsciiStream(0, (InputStream) null, 1);
} catch (SQLException ex) {
error = ex;
}
@@ -1872,4 +1872,58 @@ public class ResultSetTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_updateObject() throws Exception {
resultSet.next();
resultSet.updateObject(1, null);
resultSet.updateObject("1", null);
{
SQLException error = null;
try {
resultSet.updateObject(0, null);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
resultSet.updateObject("0", null);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_updateObject_1() throws Exception {
resultSet.next();
resultSet.updateObject(1, null, 1);
resultSet.updateObject("1", null, 1);
{
SQLException error = null;
try {
resultSet.updateObject(0, null, 1);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
resultSet.updateObject("0", null, 1);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
}
@@ -0,0 +1,127 @@
package com.alibaba.druid.bvt.pool.basic;
import java.sql.SQLException;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.mock.MockResultSet;
import com.alibaba.druid.pool.PoolableResultSet;
import com.alibaba.druid.pool.PoolableStatement;
public class ResultSetTest2 extends TestCase {
private PoolableStatement stmt;
private MockResultSet raw;
private PoolableResultSet resultSet;
protected void setUp() throws Exception {
stmt = new PoolableStatement(null, null) {
protected SQLException checkException(Throwable error) throws SQLException {
if (error instanceof SQLException) {
return (SQLException) error;
}
return new SQLException(error);
}
};
raw = new MockResultSet(null);
raw.getRows().add(new Object[] { null });
resultSet = new PoolableResultSet(stmt, raw);
}
public void test_rowDeleted() throws Exception {
resultSet.rowDeleted();
raw.close();
{
SQLException error = null;
try {
resultSet.rowDeleted();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_rowInserted() throws Exception {
resultSet.rowInserted();
raw.close();
{
SQLException error = null;
try {
resultSet.rowInserted();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_rowUpdated() throws Exception {
resultSet.rowInserted();
raw.close();
{
SQLException error = null;
try {
resultSet.rowUpdated();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_getConcurrency() throws Exception {
resultSet.getConcurrency();
raw.close();
{
SQLException error = null;
try {
resultSet.getConcurrency();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_getType() throws Exception {
resultSet.getType();
raw.close();
{
SQLException error = null;
try {
resultSet.getType();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_FetchSize() throws Exception {
resultSet.setFetchSize(10);
Assert.assertEquals(10, resultSet.getFetchSize());
raw.close();
{
SQLException error = null;
try {
resultSet.getFetchSize();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
}