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

The following examples show how to use org.apache.tomcat.jdbc.pool.interceptor.TestInterceptor. 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: TestInterceptorShortName.java    License: 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 Project: Tomcat7.0.67   Source File: TestInterceptorShortName.java    License: 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 Project: tomcatsrc   Source File: TestInterceptorShortName.java    License: 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);
}