完善mock和测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@786 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-16 00:39:49 +00:00
parent 4b7798248d
commit 8549dd0754
4 changed files with 178 additions and 33 deletions
@@ -1467,6 +1467,32 @@ public class ResultSetTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_getRowId() throws Exception {
resultSet.next();
resultSet.getRowId(1);
resultSet.getRowId("1");
{
SQLException error = null;
try {
resultSet.getRowId(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
resultSet.getRowId("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_getTimestamp() throws Exception {
resultSet.next();
@@ -10,8 +10,8 @@ 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;
@@ -32,11 +32,11 @@ public class ResultSetTest2 extends TestCase {
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 {
@@ -47,11 +47,11 @@ public class ResultSetTest2 extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_rowInserted() throws Exception {
resultSet.rowInserted();
raw.close();
{
SQLException error = null;
try {
@@ -62,11 +62,11 @@ public class ResultSetTest2 extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_rowUpdated() throws Exception {
resultSet.rowInserted();
raw.close();
{
SQLException error = null;
try {
@@ -77,11 +77,11 @@ public class ResultSetTest2 extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_getConcurrency() throws Exception {
resultSet.getConcurrency();
raw.close();
{
SQLException error = null;
try {
@@ -92,11 +92,11 @@ public class ResultSetTest2 extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_getType() throws Exception {
resultSet.getType();
raw.close();
{
SQLException error = null;
try {
@@ -107,12 +107,12 @@ public class ResultSetTest2 extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_FetchSize() throws Exception {
resultSet.setFetchSize(10);
Assert.assertEquals(10, resultSet.getFetchSize());
raw.close();
{
SQLException error = null;
try {
@@ -122,6 +122,112 @@ public class ResultSetTest2 extends TestCase {
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
resultSet.setFetchSize(10);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_getHoldability() throws Exception {
resultSet.getHoldability();
raw.close();
{
SQLException error = null;
try {
resultSet.getHoldability();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_getStatement() throws Exception {
resultSet.getStatement();
raw.close();
{
SQLException error = null;
try {
raw.getStatement();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_moveToCurrentRow() throws Exception {
resultSet.moveToCurrentRow();
raw.close();
{
SQLException error = null;
try {
resultSet.moveToCurrentRow();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_moveToInsertRow() throws Exception {
resultSet.moveToInsertRow();
raw.close();
{
SQLException error = null;
try {
resultSet.moveToInsertRow();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_cancelRowUpdates() throws Exception {
resultSet.cancelRowUpdates();
raw.close();
{
SQLException error = null;
try {
resultSet.cancelRowUpdates();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_refreshRow() throws Exception {
resultSet.refreshRow();
raw.close();
{
SQLException error = null;
try {
resultSet.refreshRow();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
}