Example usage for org.apache.commons.dbcp.datasources SharedPoolDataSource getDataSourceName

List of usage examples for org.apache.commons.dbcp.datasources SharedPoolDataSource getDataSourceName

Introduction

In this page you can find the example usage for org.apache.commons.dbcp.datasources SharedPoolDataSource getDataSourceName.

Prototype

public String getDataSourceName() 

Source Link

Document

Get the name of the ConnectionPoolDataSource which backs this pool.

Usage

From source file:org.mybatis.guice.datasource.dbcp.SharedPoolDataSourceProviderTest.java

@Test
public void get_DataSourceName() throws Throwable {
    final String name = "test_name";
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override//from ww  w  .j  a v  a 2s.co  m
        protected void configure() {
            bindConstant().annotatedWith(Names.named("DBCP.name")).to(name);
        }
    });
    SharedPoolDataSourceProvider provider = injector.getInstance(SharedPoolDataSourceProvider.class);

    SharedPoolDataSource dataSource = (SharedPoolDataSource) provider.get();

    assertEquals(name, dataSource.getDataSourceName());
}