org.apache.tomcat.jdbc.test.DefaultProperties Java Examples

The following examples show how to use org.apache.tomcat.jdbc.test.DefaultProperties. 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 File: Bug54978.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@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();
        Assert.fail("Validation should have failed.");
    }catch (SQLException x) {
    }
}
 
Example #2
Source File: Bug54978.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testIllegalValidationQueryWithLegalInit() throws SQLException {
    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");
    poolProperties.setInitSQL("SELECT 1");
    final DataSource ds = new DataSource(poolProperties);
    ds.getConnection().close();
}
 
Example #3
Source File: Bug54225.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testPool() throws SQLException {
    PoolProperties poolProperties = new DefaultProperties();
    poolProperties.setMinIdle(0);
    poolProperties.setInitialSize(0);
    poolProperties.setMaxWait(5000);
    poolProperties.setRemoveAbandoned(true);
    poolProperties.setRemoveAbandonedTimeout(300);
    poolProperties.setRollbackOnReturn(true);
    poolProperties.setInitSQL(initSQL);
    final DataSource ds = new DataSource(poolProperties);
    ds.getConnection().close();
    Assert.assertNull(poolProperties.getInitSQL());
}
 
Example #4
Source File: Bug54227.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testPool() throws SQLException, InterruptedException {
    PoolProperties poolProperties = new DefaultProperties();
    poolProperties.setMinIdle(0);
    poolProperties.setInitialSize(0);
    poolProperties.setMaxActive(1);
    poolProperties.setMaxWait(5000);
    poolProperties.setMaxAge(100);
    poolProperties.setRemoveAbandoned(false);

    final DataSource ds = new DataSource(poolProperties);
    Connection con;
    Connection actual1;
    Connection actual2;

    con = ds.getConnection();
    actual1 = ((PooledConnection)con).getConnection();
    con.close();
    con = ds.getConnection();
    actual2 = ((PooledConnection)con).getConnection();
    Assert.assertSame(actual1, actual2);
    con.close();
    Thread.sleep(150);
    con = ds.getConnection();
    actual2 = ((PooledConnection)con).getConnection();
    Assert.assertNotSame(actual1, actual2);
    con.close();
}