完善测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@805 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-16 06:59:28 +00:00
parent 29c01715f0
commit 8aaf373c43
2 changed files with 149 additions and 10 deletions
@@ -52,12 +52,20 @@ public class MockCallableStatement extends MockPreparedStatement implements Call
@Override
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
parameters.add(null);
if (parameterIndex < 1) {
throw new SQLException();
}
if (parameters.size() >= parameterIndex - 1) {
parameters.add(null);
} else {
throw new SQLException();
}
}
@Override
public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
parameters.add(null);
registerOutParameter(parameterIndex, sqlType);
}
@Override
@@ -288,22 +296,22 @@ public class MockCallableStatement extends MockPreparedStatement implements Call
@Override
public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException {
parameters.add(null);
registerOutParameter(parameterIndex, sqlType);
}
@Override
public void registerOutParameter(String parameterName, int sqlType) throws SQLException {
parameters.add(null);
registerOutParameter(Integer.parseInt(parameterName), sqlType);
}
@Override
public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException {
parameters.add(null);
registerOutParameter(parameterName, sqlType);
}
@Override
public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException {
parameters.add(null);
registerOutParameter(parameterName, sqlType);
}
@Override
@@ -5,6 +5,7 @@ import java.io.Reader;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLXML;
@@ -1854,7 +1855,7 @@ public class PoolableCallableStatementTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_setNString() throws Exception {
stmt.setNString(1, (String) null);
@@ -1880,7 +1881,7 @@ public class PoolableCallableStatementTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_getObject() throws Exception {
stmt.getObject(1, null);
@@ -1906,7 +1907,7 @@ public class PoolableCallableStatementTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_setBoolean() throws Exception {
stmt.setBoolean(1, true);
@@ -1932,7 +1933,7 @@ public class PoolableCallableStatementTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_setURL() throws Exception {
stmt.setURL(1, null);
@@ -1958,4 +1959,134 @@ public class PoolableCallableStatementTest extends TestCase {
Assert.assertNotNull(error);
}
}
public void test_setNClob_2() throws Exception {
stmt.setNClob(1, (NClob) null);
stmt.setNClob("1", (NClob) null);
{
SQLException error = null;
try {
stmt.setNClob("0", (NClob) null);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.setNClob(0, (NClob) null);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_setNull_1() throws Exception {
stmt.setNull(1, Types.INTEGER);
stmt.setNull("1", Types.INTEGER);
{
SQLException error = null;
try {
stmt.setNull("0", Types.INTEGER);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.setNull(0, Types.INTEGER);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_registerOutParameter() throws Exception {
stmt.registerOutParameter(1, Types.INTEGER, "Int");
stmt.registerOutParameter("1", Types.INTEGER, "Int");
{
SQLException error = null;
try {
stmt.registerOutParameter("0", Types.INTEGER, "Int");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.registerOutParameter(0, Types.INTEGER, "Int");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_registerOutParameter_1() throws Exception {
stmt.registerOutParameter(1, Types.INTEGER, 2);
stmt.registerOutParameter("1", Types.INTEGER, 2);
{
SQLException error = null;
try {
stmt.registerOutParameter("0", Types.INTEGER, 2);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.registerOutParameter(0, Types.INTEGER, 2);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
public void test_registerOutParameter_2() throws Exception {
stmt.registerOutParameter(1, Types.INTEGER);
stmt.registerOutParameter("1", Types.INTEGER);
{
SQLException error = null;
try {
stmt.registerOutParameter("0", Types.INTEGER);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.registerOutParameter(0, Types.INTEGER);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
}