git-svn-id: http://code.alibabatech.com/svn/druid/trunk@752 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-15 06:28:01 +00:00
parent 2abb0e0c10
commit 13736981df
@@ -0,0 +1,334 @@
package com.alibaba.druid.bvt.pool;
import java.sql.SQLException;
import java.sql.Types;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.alibaba.druid.mock.MockCallableStatement;
import com.alibaba.druid.pool.PoolableCallableStatement;
public class PoolableCallableStatementTest extends TestCase {
public void test_callableStmt() throws Exception {
MockCallableStatement raw = new MockCallableStatement(null, null);
PoolableCallableStatement stmt = new PoolableCallableStatement(null, raw, null) {
protected SQLException checkException(Throwable error) throws SQLException {
if (error instanceof SQLException) {
return (SQLException) error;
}
return new SQLException(error);
}
};
Assert.assertEquals(0, raw.getParameters().size());
raw.registerOutParameter(1, Types.INTEGER);
Assert.assertEquals(1, raw.getParameters().size());
Assert.assertTrue(stmt.wasNull() == false);
stmt.getString(1);
Assert.assertTrue(stmt.wasNull());
stmt.getBoolean(1);
stmt.getByte(1);
stmt.getShort(1);
stmt.getInt(1);
stmt.getLong(1);
stmt.getFloat(1);
stmt.getDouble(1);
stmt.getBigDecimal(1);
stmt.getBigDecimal(1, 1);
stmt.getBytes(1);
stmt.getDate(1);
stmt.getTime(1);
stmt.getTimestamp(1);
stmt.getString("1");
stmt.getBoolean("1");
stmt.getByte("1");
stmt.getShort("1");
stmt.getInt("1");
stmt.getLong("1");
stmt.getFloat("1");
stmt.getDouble("1");
stmt.getBigDecimal("1");
stmt.getBytes("1");
stmt.getDate("1");
stmt.getTime("1");
stmt.getTimestamp("1");
{
SQLException error = null;
try {
stmt.getString(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBoolean(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getByte(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getShort(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getInt(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getLong(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getFloat(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getDouble(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBigDecimal(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBigDecimal(0, 1);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBytes(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getDate(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getTime(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getTimestamp(0);
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
// ////////////////
{
SQLException error = null;
try {
stmt.getString("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBoolean("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getByte("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getShort("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getInt("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getLong("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getFloat("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getDouble("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBigDecimal("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getBytes("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getDate("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getTime("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
{
SQLException error = null;
try {
stmt.getTimestamp("0");
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
}