From 6a1a477a14135ddb257b4e4784d40057558c09c8 Mon Sep 17 00:00:00 2001 From: wenshao Date: Fri, 16 Sep 2011 06:29:42 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B5=8B=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@802 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../bvt/pool/basic/PoolableStatementTest.java | 5 +- .../pool/basic/PoolableStatementTest2.java | 125 ++++++++++++++++++ 2 files changed, 127 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java index d4313f7fd2..9f6105c861 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest.java @@ -1,5 +1,6 @@ package com.alibaba.druid.bvt.pool.basic; +import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -40,7 +41,5 @@ public class PoolableStatementTest extends TestCase { stmt.toString(); } - public void test_MaxRows() throws Exception { - - } + } diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java index 72817414ff..e206b14364 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/PoolableStatementTest2.java @@ -607,4 +607,129 @@ public class PoolableStatementTest2 extends TestCase { conn.close(); } + public void test_getResultSetHoldability() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.getResultSetHoldability(); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.getResultSetHoldability(); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_execute() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.execute("SELECT 1", new String[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new String[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_execute_1() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.execute("SELECT 1", new int[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new int[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_execute_2() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.execute("SELECT 1", Statement.NO_GENERATED_KEYS); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", Statement.NO_GENERATED_KEYS); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_executeUpdate_1() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SELECT 1", new String[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new String[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } + + public void test_executeUpdate_2() throws Exception { + Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("SELECT 1", new int[0]); + ((PoolableStatement) stmt).getStatement().close(); + + { + SQLException error = null; + try { + stmt.execute("SELECT 1", new int[0]); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + stmt.close(); + conn.close(); + } }