mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
完善mock和测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@829 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user