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@799 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -373,7 +373,7 @@ public class MockCallableStatement extends MockPreparedStatement implements Call
|
||||
|
||||
@Override
|
||||
public void setDate(String parameterName, Date x) throws SQLException {
|
||||
|
||||
setObject(parameterName, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -224,7 +224,7 @@ public class MockPreparedStatement extends MockStatement implements PreparedStat
|
||||
|
||||
@Override
|
||||
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
|
||||
|
||||
parameters.add(parameterIndex - 1, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,10 @@ package com.alibaba.druid.bvt.pool.basic;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.sql.Clob;
|
||||
import java.sql.Date;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
|
||||
import junit.framework.Assert;
|
||||
@@ -834,12 +837,12 @@ public class PoolableCallableStatementTest extends TestCase {
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void test_setAsciiStream_1() throws Exception {
|
||||
|
||||
|
||||
stmt.setAsciiStream(1, (InputStream) null, 1L);
|
||||
stmt.setAsciiStream("1", (InputStream) null, 1L);
|
||||
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
@@ -849,7 +852,7 @@ public class PoolableCallableStatementTest extends TestCase {
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
@@ -860,4 +863,108 @@ public class PoolableCallableStatementTest extends TestCase {
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
public void test_setNull() throws Exception {
|
||||
|
||||
stmt.setNull(1, Types.INTEGER, "Int");
|
||||
stmt.setNull("1", Types.INTEGER, "Int");
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setNull("0", Types.INTEGER, "Int");
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setNull(0, Types.INTEGER, "Int");
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
public void test_setTimestamp() throws Exception {
|
||||
|
||||
stmt.setTimestamp(1, (Timestamp) null, null);
|
||||
stmt.setTimestamp("1", (Timestamp) null, null);
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setTimestamp("0", (Timestamp) null, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setTimestamp(0, (Timestamp) null, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
public void test_setTime() throws Exception {
|
||||
|
||||
stmt.setTime(1, (Time) null, null);
|
||||
stmt.setTime("1", (Time) null, null);
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setTime("0", (Time) null, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setTime(0, (Time) null, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
|
||||
public void test_setDate() throws Exception {
|
||||
|
||||
stmt.setDate(1, (Date) null, null);
|
||||
stmt.setDate("1", (Date) null, null);
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setDate("0", (Date) null, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
|
||||
{
|
||||
SQLException error = null;
|
||||
try {
|
||||
stmt.setDate(0, (Date) null, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user