tearDown();
}
- public void testDBCPThreads10Connections10WithQuery() throws Exception {
- init();
- this.datasource.getPoolProperties().setMaxActive(10);
- this.datasource.getPoolProperties().setTestOnBorrow(false);
- this.threadcount = 10;
- this.transferProperties();
- this.tDatasource.getConnection().close();
- latch = new CountDownLatch(threadcount);
- long start = System.currentTimeMillis();
- for (int i=0; i<threadcount; i++) {
- TestThread t = new TestThread();
- t.setName("tomcat-dbcp-"+i);
- t.d = this.tDatasource;
- t.query = "select * from user";
- t.start();
- }
- latch.await();
- long delta = System.currentTimeMillis() - start;
- System.out.println("[testDBCPThreads10Connections10WithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
- tearDown();
- }
-
- public void testPoolThreads10Connections10WithQuery() throws Exception {
- init();
- this.datasource.getPoolProperties().setMaxActive(10);
- this.datasource.getPoolProperties().setTestOnBorrow(false);
- this.threadcount = 10;
- this.transferProperties();
- this.datasource.getConnection().close();
- latch = new CountDownLatch(threadcount);
- long start = System.currentTimeMillis();
- for (int i=0; i<threadcount; i++) {
- TestThread t = new TestThread();
- t.setName("tomcat-pool-"+i);
- t.d = DataSourceFactory.getDataSource(this.datasource);
- t.query = "select * from user";
- t.start();
- }
- latch.await();
- long delta = System.currentTimeMillis() - start;
- System.out.println("[testPoolThreads10Connections10WithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
- tearDown();
- }
-
- public void testDBCPThreads10Connections10WithValidateWithQuery() throws Exception {
- init();
- this.datasource.getPoolProperties().setMaxActive(10);
- this.datasource.getPoolProperties().setTestOnBorrow(true);
- this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
- this.threadcount = 10;
- this.transferProperties();
- this.tDatasource.getConnection().close();
- latch = new CountDownLatch(threadcount);
- long start = System.currentTimeMillis();
- for (int i=0; i<threadcount; i++) {
- TestThread t = new TestThread();
- t.setName("tomcat-dbcp-"+i);
- t.d = this.tDatasource;
- t.query = "select * from user";
- t.start();
- }
- latch.await();
- long delta = System.currentTimeMillis() - start;
- System.out.println("[testDBCPThreads10Connections10WithValidateWithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
- tearDown();
- }
-
- public void testPoolThreads10Connections10WithValidateWithQuery() throws Exception {
- init();
- this.datasource.getPoolProperties().setMaxActive(10);
- this.datasource.getPoolProperties().setTestOnBorrow(true);
- this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
- this.threadcount = 10;
- this.transferProperties();
- this.datasource.getConnection().close();
- latch = new CountDownLatch(threadcount);
- long start = System.currentTimeMillis();
- for (int i=0; i<threadcount; i++) {
- TestThread t = new TestThread();
- t.setName("tomcat-pool-"+i);
- t.d = DataSourceFactory.getDataSource(this.datasource);
- t.query = "select * from user";
- t.start();
- }
- latch.await();
- long delta = System.currentTimeMillis() - start;
- System.out.println("[testPoolThreads10Connections10WithValidateWithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
- tearDown();
- }
-
public class TestThread extends Thread {
protected DataSource d;
protected String query = null;