From 9c06a5c1eebbb387477002220de639714c916156 Mon Sep 17 00:00:00 2001 From: wenshao Date: Fri, 16 Sep 2011 04:04:23 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84mock=E5=92=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/druid/trunk@789 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../com/alibaba/druid/mock/MockResultSet.java | 4 +- .../druid/bvt/pool/basic/ResultSetTest2.java | 144 ++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/druid/mock/MockResultSet.java b/src/main/java/com/alibaba/druid/mock/MockResultSet.java index 5202469a3d..e1e9c728c6 100644 --- a/src/main/java/com/alibaba/druid/mock/MockResultSet.java +++ b/src/main/java/com/alibaba/druid/mock/MockResultSet.java @@ -404,7 +404,9 @@ public class MockResultSet implements ResultSet { @Override public boolean isAfterLast() throws SQLException { - + if (closed) { + throw new SQLException(); + } return false; } diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest2.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest2.java index ec0ccbf005..c776ec37fa 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest2.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/ResultSetTest2.java @@ -382,6 +382,150 @@ public class ResultSetTest2 extends TestCase { Assert.assertNotNull(error); } } + + public void test_isBeforeFirst() throws Exception { + resultSet.isBeforeFirst(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.isBeforeFirst(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_isAfterLast() throws Exception { + resultSet.isAfterLast(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.isAfterLast(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_isFirst() throws Exception { + resultSet.isFirst(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.isFirst(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_isLast() throws Exception { + resultSet.isLast(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.isLast(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_beforeFirst() throws Exception { + resultSet.beforeFirst(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.beforeFirst(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_first() throws Exception { + resultSet.first(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.first(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_afterLast() throws Exception { + resultSet.afterLast(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.afterLast(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_last() throws Exception { + resultSet.last(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.last(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } + + public void test_getRow() throws Exception { + resultSet.getRow(); + + raw.close(); + + { + SQLException error = null; + try { + resultSet.getRow(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + } }