add DataSourceClosedException

This commit is contained in:
wenshao
2012-08-08 21:13:26 +08:00
parent 2b4086981e
commit ff91ee541d
3 changed files with 78 additions and 15 deletions
@@ -0,0 +1,32 @@
package com.alibaba.druid.bvt.pool;
import java.sql.Connection;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.alibaba.druid.pool.DataSourceClosedException;
import com.alibaba.druid.pool.DruidDataSource;
public class ClosedTest extends TestCase {
public void test_close() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
Connection conn = dataSource.getConnection();
conn.close();
dataSource.close();
DataSourceClosedException error = null;
try {
dataSource.getConnection();
} catch (DataSourceClosedException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}