mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
完善测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@813 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.alibaba.druid.bvt.pool.adapter;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockDriver;
|
||||
import com.alibaba.druid.pool.DruidDataSourceC3P0Adapter;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
|
||||
public class DruidDataSourceC3P0AdapterTest extends TestCase {
|
||||
private MockDriver driver;
|
||||
private DruidDataSourceC3P0Adapter dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
driver = new MockDriver();
|
||||
|
||||
dataSource = new DruidDataSourceC3P0Adapter();
|
||||
dataSource.setJdbcUrl("jdbc:mock:xxx");
|
||||
dataSource.setDriver(driver);
|
||||
dataSource.setInitialPoolSize(1);
|
||||
dataSource.setMaxPoolSize(2);
|
||||
dataSource.setMinPoolSize(1);
|
||||
dataSource.setMaxIdleTime(300); // 300 / 10
|
||||
dataSource.setIdleConnectionTestPeriod(180); // 180 / 10
|
||||
dataSource.setTestConnectionOnCheckout(false);
|
||||
dataSource.setPreferredTestQuery("SELECT 1");
|
||||
dataSource.setFilters("stat");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
}
|
||||
|
||||
public void test_basic() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user