Java Code Examples for org.apache.tomcat.jdbc.pool.DataSourceProxy

The following examples show how to use org.apache.tomcat.jdbc.pool.DataSourceProxy. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Tomcat8-Source-Read   Source File: TestConnectionState.java    License: MIT License 6 votes vote down vote up
@Test
public void testAutoCommitFalse() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setMinIdle(1);
    d1.setMaxIdle(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultAutoCommit(Boolean.FALSE);
    Connection c1 = d1.getConnection();
    Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
    c1.setAutoCommit(true);
    Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
    c1.close();
    c1 = d1.getConnection();
    Assert.assertFalse("Auto commit should be false for a reused connection",c1.getAutoCommit());
    d1.close(true);
    Assert.assertTrue("Connection should be closed",c1.isClosed());
}
 
Example 2
Source Project: Tomcat8-Source-Read   Source File: TestConnectionState.java    License: MIT License 6 votes vote down vote up
@Test
public void testDefaultCatalog() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultCatalog("information_schema");
    d1.setMinIdle(1);
    Connection c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
    c1.close();
    c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
    c1.setCatalog("mysql");
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"mysql");
    c1.close();
    c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
}
 
Example 3
Source Project: Tomcat7.0.67   Source File: TestConnectionState.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAutoCommitFalse() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setMinIdle(1);
    d1.setMaxIdle(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultAutoCommit(Boolean.FALSE);
    Connection c1 = d1.getConnection();
    Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
    c1.setAutoCommit(true);
    Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
    c1.close();
    c1 = d1.getConnection();
    Assert.assertFalse("Auto commit should be false for a reused connection",c1.getAutoCommit());
    d1.close(true);
    Assert.assertTrue("Connection should be closed",c1.isClosed());
}
 
Example 4
Source Project: Tomcat7.0.67   Source File: TestConnectionState.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultCatalog() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultCatalog("information_schema");
    d1.setMinIdle(1);
    Connection c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
    c1.close();
    c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
    c1.setCatalog("mysql");
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"mysql");
    c1.close();
    c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
}
 
Example 5
Source Project: tomcatsrc   Source File: TestConnectionState.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAutoCommitFalse() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setMinIdle(1);
    d1.setMaxIdle(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultAutoCommit(Boolean.FALSE);
    Connection c1 = d1.getConnection();
    Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
    c1.setAutoCommit(true);
    Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
    c1.close();
    c1 = d1.getConnection();
    Assert.assertFalse("Auto commit should be false for a reused connection",c1.getAutoCommit());
    d1.close(true);
    Assert.assertTrue("Connection should be closed",c1.isClosed());
}
 
Example 6
Source Project: tomcatsrc   Source File: TestConnectionState.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultCatalog() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultCatalog("information_schema");
    d1.setMinIdle(1);
    Connection c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
    c1.close();
    c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
    c1.setCatalog("mysql");
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"mysql");
    c1.close();
    c1 = d1.getConnection();
    Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
}
 
Example 7
Source Project: Tomcat8-Source-Read   Source File: Async0IdleTestBug50477.java    License: MIT License 5 votes vote down vote up
@Test
public void testAsync0Idle0Size() throws Exception {
    System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async");
    this.datasource.getPoolProperties().setMaxActive(10);
    this.datasource.getPoolProperties().setFairQueue(true);
    this.datasource.getPoolProperties().setInitialSize(0);
    try {
        Future<Connection> cf = ((DataSourceProxy)datasource).getConnectionAsync();
        cf.get(5, TimeUnit.SECONDS);
    }finally {
        tearDown();
    }
}
 
Example 8
Source Project: Tomcat8-Source-Read   Source File: TestConnectionState.java    License: MIT License 5 votes vote down vote up
@Test
public void testAutoCommitTrue() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultAutoCommit(Boolean.TRUE);
    d1.setMinIdle(1);
    Connection c1 = d1.getConnection();
    Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
    c1.setAutoCommit(false);
    Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
    c1.close();
    c1 = d1.getConnection();
    Assert.assertTrue("Auto commit should be true for a reused connection",c1.getAutoCommit());
}
 
Example 9
Source Project: Tomcat7.0.67   Source File: Async0IdleTestBug50477.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAsync0Idle0Size() throws Exception {
    System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async");
    this.datasource.getPoolProperties().setMaxActive(10);
    this.datasource.getPoolProperties().setFairQueue(true);
    this.datasource.getPoolProperties().setInitialSize(0);
    try {
        Future<Connection> cf = ((DataSourceProxy)datasource).getConnectionAsync();
        cf.get(5, TimeUnit.SECONDS);
    }finally {
        tearDown();
    }
}
 
Example 10
Source Project: Tomcat7.0.67   Source File: TestConnectionState.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAutoCommitTrue() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultAutoCommit(Boolean.TRUE);
    d1.setMinIdle(1);
    Connection c1 = d1.getConnection();
    Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
    c1.setAutoCommit(false);
    Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
    c1.close();
    c1 = d1.getConnection();
    Assert.assertTrue("Auto commit should be true for a reused connection",c1.getAutoCommit());
}
 
Example 11
Source Project: metacat   Source File: DataSourceManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Closes all the data sources stored in the manager.
 */
@PreDestroy
public void close() {
    final Iterator<DataSource> iter = dataSources.values().iterator();
    while (iter.hasNext()) {
        final DataSourceProxy dataSource = (DataSourceProxy) iter.next();
        if (dataSource != null) {
            dataSource.close();
        }
        iter.remove();
    }
}
 
Example 12
Source Project: tomcatsrc   Source File: Async0IdleTestBug50477.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAsync0Idle0Size() throws Exception {
    System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async");
    this.datasource.getPoolProperties().setMaxActive(10);
    this.datasource.getPoolProperties().setFairQueue(true);
    this.datasource.getPoolProperties().setInitialSize(0);
    try {
        Future<Connection> cf = ((DataSourceProxy)datasource).getConnectionAsync();
        cf.get(5, TimeUnit.SECONDS);
    }finally {
        tearDown();
    }
}
 
Example 13
Source Project: tomcatsrc   Source File: TestConnectionState.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAutoCommitTrue() throws Exception {
    DataSourceProxy d1 = this.createDefaultDataSource();
    d1.setMaxActive(1);
    d1.setJdbcInterceptors(ConnectionState.class.getName());
    d1.setDefaultAutoCommit(Boolean.TRUE);
    d1.setMinIdle(1);
    Connection c1 = d1.getConnection();
    Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
    c1.setAutoCommit(false);
    Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
    c1.close();
    c1 = d1.getConnection();
    Assert.assertTrue("Auto commit should be true for a reused connection",c1.getAutoCommit());
}