From 40ab2d3d3a41c14505bbd23f859e7a93059cc107 Mon Sep 17 00:00:00 2001 From: wenshao Date: Sun, 18 Sep 2011 03:21:00 +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@829 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../druid/bvt/pool/basic/ConnectionTest5.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/test/java/com/alibaba/druid/bvt/pool/basic/ConnectionTest5.java b/src/test/java/com/alibaba/druid/bvt/pool/basic/ConnectionTest5.java index 392e718ffd..aa60e5b07e 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/basic/ConnectionTest5.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/basic/ConnectionTest5.java @@ -3,6 +3,9 @@ package com.alibaba.druid.bvt.pool.basic; import java.sql.SQLException; import java.util.Properties; +import javax.sql.ConnectionEvent; +import javax.sql.ConnectionEventListener; + import junit.framework.Assert; import junit.framework.TestCase; @@ -129,6 +132,37 @@ public class ConnectionTest5 extends TestCase { Assert.assertEquals(true, conn.isClosed()); } + public void test_handleException_5() throws Exception { + PoolableConnection conn = dataSource.getConnection().unwrap(PoolableConnection.class); + conn.addConnectionEventListener(new ConnectionEventListener() { + + @Override + public void connectionClosed(ConnectionEvent event) { + + } + + @Override + public void connectionErrorOccurred(ConnectionEvent event) { + + } + + }); + conn.getConnection().close(); + + { + SQLException error = null; + try { + conn.handleException(new RuntimeException()); + } catch (SQLException ex) { + error = ex; + } + Assert.assertNotNull(error); + } + + conn.close(); + + } + public void test_setClientInfo() throws Exception { PoolableConnection conn = dataSource.getConnection().unwrap(PoolableConnection.class);