From 13736981dfcac4090c73cfb60a9b351cb1f5db66 Mon Sep 17 00:00:00 2001 From: wenshao Date: Thu, 15 Sep 2011 06:28:01 +0000 Subject: [PATCH] bvt git-svn-id: http://code.alibabatech.com/svn/druid/trunk@752 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../pool/PoolableCallableStatementTest.java | 334 ++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 src/test/java/com/alibaba/druid/bvt/pool/PoolableCallableStatementTest.java diff --git a/src/test/java/com/alibaba/druid/bvt/pool/PoolableCallableStatementTest.java b/src/test/java/com/alibaba/druid/bvt/pool/PoolableCallableStatementTest.java new file mode 100644 index 0000000000..bba984fe08 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/pool/PoolableCallableStatementTest.java @@ -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); + } + + } +}