org.apache.tomcat.jdbc.pool.interceptor.TestInterceptor Java Examples

The following examples show how to use org.apache.tomcat.jdbc.pool.interceptor.TestInterceptor. 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: TestInterceptorShortName.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Test
public void testShortInterceptor() throws Exception {
    this.datasource = this.createDefaultDataSource();
    this.datasource.setJdbcInterceptors("TestInterceptor");
    this.datasource.setUseDisposableConnectionFacade(false);
    this.datasource.setMaxActive(1);
    this.datasource.createPool();
    Assert.assertEquals("Only one interceptor should have been called setProperties[1]",1,TestInterceptor.instancecount.get());
    TestInterceptor.instancecount.set(0);
    Connection con = this.datasource.getConnection();
    Assert.assertTrue("Pool should have been started.",TestInterceptor.poolstarted);
    Assert.assertEquals("Only one interceptor should have been called setProperties[2]",1,TestInterceptor.instancecount.get());
    con.close();
    this.datasource.close();
    Assert.assertTrue("Pool should have been closed.",TestInterceptor.poolclosed);
}
 
Example #2
Source File: TestInterceptorShortName.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testShortInterceptor() throws Exception {
    this.datasource = this.createDefaultDataSource();
    this.datasource.setJdbcInterceptors("TestInterceptor");
    this.datasource.setUseDisposableConnectionFacade(false);
    this.datasource.setMaxActive(1);
    this.datasource.createPool();
    Assert.assertEquals("Only one interceptor should have been called setProperties[1]",1,TestInterceptor.instancecount.get());
    TestInterceptor.instancecount.set(0);
    Connection con = this.datasource.getConnection();
    Assert.assertTrue("Pool should have been started.",TestInterceptor.poolstarted);
    Assert.assertEquals("Only one interceptor should have been called setProperties[2]",1,TestInterceptor.instancecount.get());
    con.close();
    this.datasource.close();
    Assert.assertTrue("Pool should have been closed.",TestInterceptor.poolclosed);
}
 
Example #3
Source File: TestInterceptorShortName.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testShortInterceptor() throws Exception {
    this.datasource = this.createDefaultDataSource();
    this.datasource.setJdbcInterceptors("TestInterceptor");
    this.datasource.setUseDisposableConnectionFacade(false);
    this.datasource.setMaxActive(1);
    this.datasource.createPool();
    Assert.assertEquals("Only one interceptor should have been called setProperties[1]",1,TestInterceptor.instancecount.get());
    TestInterceptor.instancecount.set(0);
    Connection con = this.datasource.getConnection();
    Assert.assertTrue("Pool should have been started.",TestInterceptor.poolstarted);
    Assert.assertEquals("Only one interceptor should have been called setProperties[2]",1,TestInterceptor.instancecount.get());
    con.close();
    this.datasource.close();
    Assert.assertTrue("Pool should have been closed.",TestInterceptor.poolclosed);
}