Files
Druid/src/test/java/com/alibaba/druid/bvt/pool/ManagedDataSourceTest.java
T
wenshao 2777ac901d 添加测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@355 b9813039-fb51-4c41-a8b9-e21c2acb5095
2011-07-06 14:34:11 +00:00

47 lines
1.0 KiB
Java

package com.alibaba.druid.bvt.pool;
import java.sql.Connection;
import java.sql.SQLException;
import org.junit.Assert;
import junit.framework.TestCase;
import com.alibaba.druid.pool.DruidDataSource;
public class ManagedDataSourceTest extends TestCase {
private DruidDataSource dataSource;
public void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
}
public void tearDown() throws Exception {
dataSource.close();
}
public void test_managed() throws Exception {
{
Connection conn = dataSource.getConnection();
conn.close();
}
dataSource.setEnable(false);
SQLException error = null;
try {
dataSource.getConnection();
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
dataSource.setEnable(true);
{
Connection conn = dataSource.getConnection();
conn.close();
}
}
}