Search in sources :

Example 6 with DefaultProperties

use of org.apache.tomcat.jdbc.test.DefaultProperties in project tomcat by apache.

the class Bug54978 method testIllegalValidationQuery.

@Test
public void testIllegalValidationQuery() {
    PoolProperties poolProperties = new DefaultProperties();
    poolProperties.setMinIdle(0);
    poolProperties.setInitialSize(1);
    poolProperties.setMaxActive(1);
    poolProperties.setMaxWait(5000);
    poolProperties.setMaxAge(100);
    poolProperties.setRemoveAbandoned(false);
    poolProperties.setTestOnBorrow(true);
    poolProperties.setTestOnConnect(false);
    poolProperties.setValidationQuery("sdadsada");
    final DataSource ds = new DataSource(poolProperties);
    try {
        ds.getConnection().close();
        fail("Validation should have failed.");
    } catch (SQLException x) {
    }
}
Also used : DefaultProperties(org.apache.tomcat.jdbc.test.DefaultProperties) SQLException(java.sql.SQLException) PoolProperties(org.apache.tomcat.jdbc.pool.PoolProperties) DataSource(org.apache.tomcat.jdbc.pool.DataSource) Test(org.junit.Test)

Aggregations

DefaultProperties (org.apache.tomcat.jdbc.test.DefaultProperties)6 DataSource (org.apache.tomcat.jdbc.pool.DataSource)5 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)5 Test (org.junit.Test)5 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)2 ConnectionPool (org.apache.tomcat.jdbc.pool.ConnectionPool)2 CallableStatement (java.sql.CallableStatement)1 Statement (java.sql.Statement)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 PooledConnection (javax.sql.PooledConnection)1 PoolConfiguration (org.apache.tomcat.jdbc.pool.PoolConfiguration)1 PoolExhaustedException (org.apache.tomcat.jdbc.pool.PoolExhaustedException)1