List of usage examples for org.apache.commons.dbcp.datasources PerUserPoolDataSource getJndiEnvironment
public String getJndiEnvironment(String key)
From source file:org.mybatis.guice.datasource.dbcp.PerUserPoolDataSourceProviderTest.java
@Test public void get_Jndi() throws Throwable { final String jndiKey = "test_key"; final String jndiValue = "test_value"; Injector injector = Guice.createInjector(new AbstractModule() { @Override/*from w w w. j a v a 2s . c om*/ protected void configure() { bind(ConnectionPoolDataSource.class).toInstance(connectionPoolDataSource); bindConstant().annotatedWith(Names.named("DBCP.jndi.key")).to(jndiKey); bindConstant().annotatedWith(Names.named("DBCP.jndi.value")).to(jndiValue); } }); PerUserPoolDataSourceProvider provider = injector.getInstance(PerUserPoolDataSourceProvider.class); PerUserPoolDataSource dataSource = (PerUserPoolDataSource) provider.get(); assertEquals(connectionPoolDataSource, dataSource.getConnectionPoolDataSource()); assertEquals(jndiValue, dataSource.getJndiEnvironment(jndiKey)); }