mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
增加BoneCP的测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@39 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -27,6 +27,7 @@ import org.apache.commons.dbcp.BasicDataSource;
|
||||
|
||||
import com.alibaba.druid.TestUtil;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.jolbox.bonecp.BoneCPDataSource;
|
||||
|
||||
public class Case0 extends TestCase {
|
||||
|
||||
@@ -39,6 +40,8 @@ public class Case0 extends TestCase {
|
||||
private int maxPoolSize = 2;
|
||||
private int maxActive = 2;
|
||||
private String validationQuery = null;
|
||||
|
||||
public final int LOOP_COUNT = 5;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
jdbcUrl = "jdbc:fake:dragoon_v25masterdb";
|
||||
@@ -63,7 +66,7 @@ public class Case0 extends TestCase {
|
||||
dataSource.setValidationQuery(validationQuery);
|
||||
dataSource.setTestOnBorrow(true);
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
for (int i = 0; i < LOOP_COUNT; ++i) {
|
||||
p0(dataSource, "druid");
|
||||
}
|
||||
System.out.println();
|
||||
@@ -85,11 +88,33 @@ public class Case0 extends TestCase {
|
||||
dataSource.setValidationQuery("SELECT 1");
|
||||
dataSource.setTestOnBorrow(true);
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
for (int i = 0; i < LOOP_COUNT; ++i) {
|
||||
p0(dataSource, "dbcp");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
BoneCPDataSource dataSource = new BoneCPDataSource();
|
||||
// dataSource.(10);
|
||||
// dataSource.setMaxActive(50);
|
||||
dataSource.setMinConnectionsPerPartition(minPoolSize);
|
||||
dataSource.setMaxConnectionsPerPartition(maxPoolSize);
|
||||
|
||||
dataSource.setDriverClass(driverClass);
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
// dataSource.setPoolPreparedStatements(true);
|
||||
// dataSource.setMaxOpenPreparedStatements(100);
|
||||
dataSource.setUsername(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setConnectionTestStatement("SELECT 1");
|
||||
dataSource.setPartitionCount(1);
|
||||
|
||||
for (int i = 0; i < LOOP_COUNT; ++i) {
|
||||
p0(dataSource, "boneCP");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
private void p0(DataSource dataSource, String name) throws SQLException {
|
||||
long startMillis = System.currentTimeMillis();
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.commons.dbcp.BasicDataSource;
|
||||
|
||||
import com.alibaba.druid.TestUtil;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.jolbox.bonecp.BoneCPDataSource;
|
||||
|
||||
public class Case1 extends TestCase {
|
||||
|
||||
@@ -39,7 +40,7 @@ public class Case1 extends TestCase {
|
||||
private int maxPoolSize = 2;
|
||||
private int maxActive = 2;
|
||||
private String validationQuery = "SELECT 1";
|
||||
private int threadCount = 20;
|
||||
private int threadCount = 2;
|
||||
private int loopCount = 5;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@@ -92,6 +93,28 @@ public class Case1 extends TestCase {
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
BoneCPDataSource dataSource = new BoneCPDataSource();
|
||||
// dataSource.(10);
|
||||
// dataSource.setMaxActive(50);
|
||||
dataSource.setMinConnectionsPerPartition(minPoolSize);
|
||||
dataSource.setMaxConnectionsPerPartition(maxPoolSize);
|
||||
|
||||
dataSource.setDriverClass(driverClass);
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
// dataSource.setPoolPreparedStatements(true);
|
||||
// dataSource.setMaxOpenPreparedStatements(100);
|
||||
dataSource.setUsername(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setConnectionTestStatement("SELECT 1");
|
||||
dataSource.setPartitionCount(1);
|
||||
|
||||
for (int i = 0; i < loopCount; ++i) {
|
||||
p0(dataSource, "boneCP", threadCount);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
private void p0(final DataSource dataSource, String name, int threadCount) throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user