From 9eaf49542d1688cc9946e96f208a5825162e1895 Mon Sep 17 00:00:00 2001 From: wenshao Date: Thu, 15 Sep 2011 05:00:21 +0000 Subject: [PATCH] git-svn-id: http://code.alibabatech.com/svn/druid/trunk@745 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../druid/bvt/pool/PoolableResultSetTest.java | 186 +++++++++++++++++- 1 file changed, 179 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/alibaba/druid/bvt/pool/PoolableResultSetTest.java b/src/test/java/com/alibaba/druid/bvt/pool/PoolableResultSetTest.java index c01c2a5a4b..c8e48c9404 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/PoolableResultSetTest.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/PoolableResultSetTest.java @@ -10,26 +10,27 @@ import com.alibaba.druid.mock.MockResultSet; import com.alibaba.druid.pool.PoolableResultSet; import com.alibaba.druid.pool.PoolableStatement; - public class PoolableResultSetTest extends TestCase { + public void test_0() throws Exception { PoolableStatement stmt = new PoolableStatement(null, null) { + protected SQLException checkException(Throwable error) throws SQLException { if (error instanceof SQLException) { return (SQLException) error; } - + return new SQLException(error); } }; - + MockResultSet raw = new MockResultSet(null); - raw.getRows().add(new Object[] {null}); + raw.getRows().add(new Object[] { null }); PoolableResultSet resultSet = new PoolableResultSet(stmt, raw); - + Assert.assertTrue(stmt == resultSet.getPoolableStatement()); Assert.assertTrue(raw == resultSet.getRawResultSet()); - + Assert.assertTrue(resultSet.next()); Assert.assertTrue(resultSet.wasNull() == false); resultSet.getString(1); @@ -50,7 +51,7 @@ public class PoolableResultSetTest extends TestCase { resultSet.getAsciiStream(1); resultSet.getUnicodeStream(1); resultSet.getBinaryStream(1); - + resultSet.getString("1"); resultSet.getBoolean("1"); resultSet.getByte("1"); @@ -68,5 +69,176 @@ public class PoolableResultSetTest extends TestCase { resultSet.getAsciiStream("1"); resultSet.getUnicodeStream("1"); resultSet.getBinaryStream("1"); + + { + SQLException error = null; + try { + resultSet.getString(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getBoolean(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getByte(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getShort(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getInt(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getLong(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getFloat(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getDouble(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getBigDecimal(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getBigDecimal(0, 1); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getBytes(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getDate(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getTime(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getTimestamp(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getAsciiStream(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getUnicodeStream(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + { + SQLException error = null; + try { + resultSet.getBinaryStream(0); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } }