Example usage for org.apache.commons.dbcp BasicDataSource getMaxWait

List of usage examples for org.apache.commons.dbcp BasicDataSource getMaxWait

Introduction

In this page you can find the example usage for org.apache.commons.dbcp BasicDataSource getMaxWait.

Prototype

public synchronized long getMaxWait() 

Source Link

Document

Returns the maximum number of milliseconds that the pool will wait for a connection to be returned before throwing an exception.

Usage

From source file:com.hangum.tadpole.engine.manager.TadpoleSQLManager.java

/**
 * dbcp pool info/* w  w w . j  a va 2 s.  c  om*/
 * 
 * @return
 */
public static List<DBCPInfoDAO> getDBCPInfo() {
    List<DBCPInfoDAO> listDbcpInfo = new ArrayList<DBCPInfoDAO>();

    Set<String> setKeys = getDbManager().keySet();
    for (String stKey : setKeys) {

        SqlMapClient sqlMap = dbManager.get(stKey);
        DataSource ds = sqlMap.getDataSource();
        BasicDataSource bds = (BasicDataSource) ds;

        String[] strArryKey = StringUtils.splitByWholeSeparator(stKey, PublicTadpoleDefine.DELIMITER);
        if (!DBDefine.TADPOLE_SYSTEM_DEFAULT.getDBToString().equals(strArryKey[1])) {

            DBCPInfoDAO dao = new DBCPInfoDAO();
            dao.setDbSeq(Integer.parseInt(strArryKey[0]));
            dao.setDbType(strArryKey[1]);
            dao.setDisplayName(strArryKey[2]);

            dao.setNumberActive(bds.getNumActive());
            dao.setMaxActive(bds.getMaxActive());
            dao.setNumberIdle(bds.getNumIdle());
            dao.setMaxWait(bds.getMaxWait());

            listDbcpInfo.add(dao);
        }
    }

    return listDbcpInfo;
}

From source file:net.risesoft.soa.asf.web.controller.SystemController.java

private List<SysInfo> getDBInfo() {
    List list = new ArrayList();
    String group = "4. ??";
    try {// w  ww . jav  a2  s  .  com
        Connection conn = this.basicDataSource.getConnection();
        try {
            DatabaseMetaData dbmd = conn.getMetaData();
            list.add(new SysInfo("DatabaseProductName", dbmd.getDatabaseProductName(), group));
            list.add(new SysInfo("DatabaseProductVersion", dbmd.getDatabaseProductVersion(), group));
            list.add(new SysInfo("DatabaseMajorVersion", Integer.valueOf(dbmd.getDatabaseMajorVersion()),
                    group));
            list.add(new SysInfo("DatabaseMinorVersion", Integer.valueOf(dbmd.getDatabaseMinorVersion()),
                    group));
            list.add(new SysInfo("DriverName", dbmd.getDriverName(), group));
            list.add(new SysInfo("DriverVersion", dbmd.getDriverVersion(), group));
            list.add(new SysInfo("DriverMajorVersion", Integer.valueOf(dbmd.getDriverMajorVersion()), group));
            list.add(new SysInfo("DriverMinorVersion", Integer.valueOf(dbmd.getDriverMinorVersion()), group));
        } finally {
            conn.close();
        }
        group = "5. ?";
        BasicDataSource bds = this.basicDataSource;
        list.add(new SysInfo("InitialSize", Integer.valueOf(bds.getInitialSize()), group));
        list.add(new SysInfo("MaxActive", Integer.valueOf(bds.getMaxActive()), group));
        list.add(new SysInfo("MaxIdle", Integer.valueOf(bds.getMaxIdle()), group));
        list.add(new SysInfo("MinIdle", Integer.valueOf(bds.getMinIdle()), group));
        list.add(new SysInfo("MaxWait", Long.valueOf(bds.getMaxWait()), group));
        list.add(new SysInfo("NumActive", Integer.valueOf(bds.getNumActive()), group));
        list.add(new SysInfo("NumIdle", Integer.valueOf(bds.getNumIdle()), group));
        list.add(new SysInfo("DriverClass", bds.getDriverClassName(), group));
        list.add(new SysInfo("URL", bds.getUrl(), group));
        list.add(new SysInfo("Username", bds.getUsername(), group));
        list.add(new SysInfo("Password", "******", group));
    } catch (Exception ex) {
        log.warn("???: " + ex.getMessage(), ex);
    }
    return list;
}

From source file:org.alfresco.repo.tenant.TenantBasicDataSource.java

public TenantBasicDataSource(BasicDataSource bds, String tenantUrl, int tenantMaxActive) throws SQLException {
    // tenant-specific
    this.setUrl(tenantUrl);
    this.setMaxActive(tenantMaxActive == -1 ? bds.getMaxActive() : tenantMaxActive);

    // defaults/overrides - see also 'baseDefaultDataSource' (core-services-context.xml + repository.properties)

    this.setDriverClassName(bds.getDriverClassName());
    this.setUsername(bds.getUsername());
    this.setPassword(bds.getPassword());

    this.setInitialSize(bds.getInitialSize());
    this.setMinIdle(bds.getMinIdle());
    this.setMaxIdle(bds.getMaxIdle());
    this.setDefaultAutoCommit(bds.getDefaultAutoCommit());
    this.setDefaultTransactionIsolation(bds.getDefaultTransactionIsolation());
    this.setMaxWait(bds.getMaxWait());
    this.setValidationQuery(bds.getValidationQuery());
    this.setTimeBetweenEvictionRunsMillis(bds.getTimeBetweenEvictionRunsMillis());
    this.setMinEvictableIdleTimeMillis(bds.getMinEvictableIdleTimeMillis());
    this.setNumTestsPerEvictionRun(bds.getNumTestsPerEvictionRun());
    this.setTestOnBorrow(bds.getTestOnBorrow());
    this.setTestOnReturn(bds.getTestOnReturn());
    this.setTestWhileIdle(bds.getTestWhileIdle());
    this.setRemoveAbandoned(bds.getRemoveAbandoned());
    this.setRemoveAbandonedTimeout(bds.getRemoveAbandonedTimeout());
    this.setPoolPreparedStatements(bds.isPoolPreparedStatements());
    this.setMaxOpenPreparedStatements(bds.getMaxOpenPreparedStatements());
    this.setLogAbandoned(bds.getLogAbandoned());
}

From source file:org.apache.cayenne.configuration.server.DBCPDataSourceFactoryTest.java

@Test
public void testGetDataSource() throws Exception {

    String baseUrl = getClass().getPackage().getName().replace('.', '/');
    URL url = getClass().getClassLoader().getResource(baseUrl + "/");
    assertNotNull(url);//from   w  ww. j  a va  2s. c om

    DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
    nodeDescriptor.setConfigurationSource(new URLResource(url));
    nodeDescriptor.setParameters("testDBCP.properties");

    DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
    DataSource dataSource = factory.getDataSource(nodeDescriptor);
    assertNotNull(dataSource);

    assertTrue(dataSource instanceof BasicDataSource);
    BasicDataSource basicDataSource = (BasicDataSource) dataSource;
    assertEquals("com.example.jdbc.Driver", basicDataSource.getDriverClassName());
    assertEquals("jdbc:somedb://localhost/cayenne", basicDataSource.getUrl());
    assertEquals("john", basicDataSource.getUsername());
    assertEquals("secret", basicDataSource.getPassword());
    assertEquals(20, basicDataSource.getMaxActive());
    assertEquals(5, basicDataSource.getMinIdle());
    assertEquals(8, basicDataSource.getMaxIdle());
    assertEquals(10000, basicDataSource.getMaxWait());
    assertEquals("select 1 from xyz;", basicDataSource.getValidationQuery());
}

From source file:org.apache.cayenne.configuration.server.DBCPDataSourceFactoryTest.java

@Test
public void testGetDataSource_LegacyConfig() throws Exception {

    String baseUrl = getClass().getPackage().getName().replace('.', '/');
    URL url = getClass().getClassLoader().getResource(baseUrl + "/");
    assertNotNull(url);/*from  ww  w.  j a  v  a  2s .co  m*/

    DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
    nodeDescriptor.setConfigurationSource(new URLResource(url));
    nodeDescriptor.setParameters("testDBCP_legacy.properties");

    DBCPDataSourceFactory factory = new DBCPDataSourceFactory();
    DataSource dataSource = factory.getDataSource(nodeDescriptor);
    assertNotNull(dataSource);

    assertTrue(dataSource instanceof BasicDataSource);
    BasicDataSource basicDataSource = (BasicDataSource) dataSource;
    assertEquals("com.example.jdbc.Driver", basicDataSource.getDriverClassName());
    assertEquals("jdbc:somedb://localhost/cayenne", basicDataSource.getUrl());
    assertEquals("john", basicDataSource.getUsername());
    assertEquals("secret", basicDataSource.getPassword());
    assertEquals(20, basicDataSource.getMaxActive());
    assertEquals(5, basicDataSource.getMinIdle());
    assertEquals(8, basicDataSource.getMaxIdle());
    assertEquals(10000, basicDataSource.getMaxWait());
    assertEquals("select 1 from xyz;", basicDataSource.getValidationQuery());
}

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

@Test
public void get() throws Throwable {
    final String driver = "org.mybatis.guice.TestDriver";
    final String url = "jdbc:h2:mem:testdb";
    final String username = "test_user";
    final String password = "test_password";
    final boolean autoCommit = true;
    final Properties driverProperties = new Properties();
    driverProperties.put("my_property", "true");
    final boolean accessToUnderlyingConnectionAllowed = true;
    final String defaultCatalog = "test_catalog";
    final boolean defaultReadOnly = true;
    final int defaultTransactionIsolation = 20;
    final int initialSize = 30;
    final int maxActive = 40;
    final int maxIdle = 50;
    final int maxOpenPreparedStatements = 60;
    final long maxWait = 70;
    final int minIdle = 80;
    final int numTestsPerEvictionRun = 90;
    final boolean poolPreparedStatements = true;
    final boolean testOnBorrow = true;
    final boolean testOnReturn = true;
    final boolean testWhileIdle = true;
    final int timeBetweenEvictionRunsMillis = 100;
    final String validationQuery = "SELECT 1";
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override//from   ww w  . j av  a 2  s.c  o m
        protected void configure() {
            bind(ClassLoader.class).annotatedWith(Names.named("JDBC.driverClassLoader"))
                    .toInstance(driverClassLoader);
            bindConstant().annotatedWith(Names.named("JDBC.driver")).to(driver);
            bindConstant().annotatedWith(Names.named("JDBC.url")).to(url);
            bindConstant().annotatedWith(Names.named("JDBC.username")).to(username);
            bindConstant().annotatedWith(Names.named("JDBC.password")).to(password);
            bindConstant().annotatedWith(Names.named("JDBC.autoCommit")).to(autoCommit);
            bind(Properties.class).annotatedWith(Names.named("JDBC.driverProperties"))
                    .toInstance(driverProperties);
            bindConstant().annotatedWith(Names.named("DBCP.accessToUnderlyingConnectionAllowed"))
                    .to(accessToUnderlyingConnectionAllowed);
            bindConstant().annotatedWith(Names.named("DBCP.defaultCatalog")).to(defaultCatalog);
            bindConstant().annotatedWith(Names.named("DBCP.defaultReadOnly")).to(defaultReadOnly);
            bindConstant().annotatedWith(Names.named("DBCP.defaultTransactionIsolation"))
                    .to(defaultTransactionIsolation);
            bindConstant().annotatedWith(Names.named("DBCP.initialSize")).to(initialSize);
            bindConstant().annotatedWith(Names.named("DBCP.maxActive")).to(maxActive);
            bindConstant().annotatedWith(Names.named("DBCP.maxIdle")).to(maxIdle);
            bindConstant().annotatedWith(Names.named("DBCP.maxOpenPreparedStatements"))
                    .to(maxOpenPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.maxWait")).to(maxWait);
            bindConstant().annotatedWith(Names.named("DBCP.minIdle")).to(minIdle);
            bindConstant().annotatedWith(Names.named("DBCP.numTestsPerEvictionRun")).to(numTestsPerEvictionRun);
            bindConstant().annotatedWith(Names.named("DBCP.poolPreparedStatements")).to(poolPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.testOnBorrow")).to(testOnBorrow);
            bindConstant().annotatedWith(Names.named("DBCP.testOnReturn")).to(testOnReturn);
            bindConstant().annotatedWith(Names.named("DBCP.testWhileIdle")).to(testWhileIdle);
            bindConstant().annotatedWith(Names.named("DBCP.timeBetweenEvictionRunsMillis"))
                    .to(timeBetweenEvictionRunsMillis);
            bindConstant().annotatedWith(Names.named("DBCP.validationQuery")).to(validationQuery);
        }
    });
    BasicDataSourceProvider provider = injector.getInstance(BasicDataSourceProvider.class);

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

    assertEquals(driverClassLoader, dataSource.getDriverClassLoader());
    assertEquals(driver, dataSource.getDriverClassName());
    assertEquals(url, dataSource.getUrl());
    assertEquals(username, dataSource.getUsername());
    assertEquals(password, dataSource.getPassword());
    assertEquals(autoCommit, dataSource.getDefaultAutoCommit());
    // Cannot test driver properties.
    assertEquals(accessToUnderlyingConnectionAllowed, dataSource.isAccessToUnderlyingConnectionAllowed());
    assertEquals(defaultCatalog, dataSource.getDefaultCatalog());
    assertEquals(defaultReadOnly, dataSource.getDefaultReadOnly());
    assertEquals(defaultTransactionIsolation, dataSource.getDefaultTransactionIsolation());
    assertEquals(initialSize, dataSource.getInitialSize());
    assertEquals(maxActive, dataSource.getMaxActive());
    assertEquals(maxIdle, dataSource.getMaxIdle());
    assertEquals(maxOpenPreparedStatements, dataSource.getMaxOpenPreparedStatements());
    assertEquals(maxWait, dataSource.getMaxWait());
    assertEquals(minIdle, dataSource.getMinIdle());
    assertEquals(numTestsPerEvictionRun, dataSource.getNumTestsPerEvictionRun());
    assertEquals(poolPreparedStatements, dataSource.isPoolPreparedStatements());
    assertEquals(testOnBorrow, dataSource.getTestOnBorrow());
    assertEquals(testOnReturn, dataSource.getTestOnReturn());
    assertEquals(testWhileIdle, dataSource.getTestWhileIdle());
    assertEquals(timeBetweenEvictionRunsMillis, dataSource.getTimeBetweenEvictionRunsMillis());
    assertEquals(validationQuery, dataSource.getValidationQuery());
}

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

@Test
public void get_OtherValues() throws Throwable {
    final String driver = "org.mybatis.guice.TestDriver2";
    final String url = "jdbc:h2:mem:testdb2";
    final String username = "test_user2";
    final String password = "test_password2";
    final boolean autoCommit = false;
    final Properties driverProperties = new Properties();
    driverProperties.put("my_property", "false");
    final boolean accessToUnderlyingConnectionAllowed = false;
    final String defaultCatalog = "test_catalog2";
    final boolean defaultReadOnly = false;
    final int defaultTransactionIsolation = 21;
    final int initialSize = 31;
    final int maxActive = 41;
    final int maxIdle = 51;
    final int maxOpenPreparedStatements = 61;
    final long maxWait = 71;
    final int minIdle = 81;
    final int numTestsPerEvictionRun = 91;
    final boolean poolPreparedStatements = false;
    final boolean testOnBorrow = false;
    final boolean testOnReturn = false;
    final boolean testWhileIdle = false;
    final int timeBetweenEvictionRunsMillis = 101;
    final String validationQuery = "SELECT 2";
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override//from w  ww .  j a va  2  s .c  om
        protected void configure() {
            bind(ClassLoader.class).annotatedWith(Names.named("JDBC.driverClassLoader"))
                    .toInstance(driverClassLoader);
            bindConstant().annotatedWith(Names.named("JDBC.driver")).to(driver);
            bindConstant().annotatedWith(Names.named("JDBC.url")).to(url);
            bindConstant().annotatedWith(Names.named("JDBC.username")).to(username);
            bindConstant().annotatedWith(Names.named("JDBC.password")).to(password);
            bindConstant().annotatedWith(Names.named("JDBC.autoCommit")).to(autoCommit);
            bind(Properties.class).annotatedWith(Names.named("JDBC.driverProperties"))
                    .toInstance(driverProperties);
            bindConstant().annotatedWith(Names.named("DBCP.accessToUnderlyingConnectionAllowed"))
                    .to(accessToUnderlyingConnectionAllowed);
            bindConstant().annotatedWith(Names.named("DBCP.defaultCatalog")).to(defaultCatalog);
            bindConstant().annotatedWith(Names.named("DBCP.defaultReadOnly")).to(defaultReadOnly);
            bindConstant().annotatedWith(Names.named("DBCP.defaultTransactionIsolation"))
                    .to(defaultTransactionIsolation);
            bindConstant().annotatedWith(Names.named("DBCP.initialSize")).to(initialSize);
            bindConstant().annotatedWith(Names.named("DBCP.maxActive")).to(maxActive);
            bindConstant().annotatedWith(Names.named("DBCP.maxIdle")).to(maxIdle);
            bindConstant().annotatedWith(Names.named("DBCP.maxOpenPreparedStatements"))
                    .to(maxOpenPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.maxWait")).to(maxWait);
            bindConstant().annotatedWith(Names.named("DBCP.minIdle")).to(minIdle);
            bindConstant().annotatedWith(Names.named("DBCP.numTestsPerEvictionRun")).to(numTestsPerEvictionRun);
            bindConstant().annotatedWith(Names.named("DBCP.poolPreparedStatements")).to(poolPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.testOnBorrow")).to(testOnBorrow);
            bindConstant().annotatedWith(Names.named("DBCP.testOnReturn")).to(testOnReturn);
            bindConstant().annotatedWith(Names.named("DBCP.testWhileIdle")).to(testWhileIdle);
            bindConstant().annotatedWith(Names.named("DBCP.timeBetweenEvictionRunsMillis"))
                    .to(timeBetweenEvictionRunsMillis);
            bindConstant().annotatedWith(Names.named("DBCP.validationQuery")).to(validationQuery);
        }
    });
    BasicDataSourceProvider provider = injector.getInstance(BasicDataSourceProvider.class);

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

    assertEquals(driverClassLoader, dataSource.getDriverClassLoader());
    assertEquals(driver, dataSource.getDriverClassName());
    assertEquals(url, dataSource.getUrl());
    assertEquals(username, dataSource.getUsername());
    assertEquals(password, dataSource.getPassword());
    assertEquals(autoCommit, dataSource.getDefaultAutoCommit());
    // Cannot test driver properties.
    assertEquals(accessToUnderlyingConnectionAllowed, dataSource.isAccessToUnderlyingConnectionAllowed());
    assertEquals(defaultCatalog, dataSource.getDefaultCatalog());
    assertEquals(defaultReadOnly, dataSource.getDefaultReadOnly());
    assertEquals(defaultTransactionIsolation, dataSource.getDefaultTransactionIsolation());
    assertEquals(initialSize, dataSource.getInitialSize());
    assertEquals(maxActive, dataSource.getMaxActive());
    assertEquals(maxIdle, dataSource.getMaxIdle());
    assertEquals(maxOpenPreparedStatements, dataSource.getMaxOpenPreparedStatements());
    assertEquals(maxWait, dataSource.getMaxWait());
    assertEquals(minIdle, dataSource.getMinIdle());
    assertEquals(numTestsPerEvictionRun, dataSource.getNumTestsPerEvictionRun());
    assertEquals(poolPreparedStatements, dataSource.isPoolPreparedStatements());
    assertEquals(testOnBorrow, dataSource.getTestOnBorrow());
    assertEquals(testOnReturn, dataSource.getTestOnReturn());
    assertEquals(testWhileIdle, dataSource.getTestWhileIdle());
    assertEquals(timeBetweenEvictionRunsMillis, dataSource.getTimeBetweenEvictionRunsMillis());
    assertEquals(validationQuery, dataSource.getValidationQuery());
}

From source file:org.openkoala.koala.monitor.support.DbcpDataSourceCollector.java

public synchronized JdbcPoolStatusVo currentPoolStatus() {
    JdbcPoolStatusVo poolStatus = new JdbcPoolStatusVo();
    try {//  w ww .j  a v a  2s  .c  o m
        BasicDataSource realDS = (BasicDataSource) dataSoure;

        poolStatus.setDriverName(realDS.getDriverClassName());
        //         poolStatus.setStartTime();
        poolStatus.setProvider(dataSoure.getClass().getName());
        poolStatus.setInitConnectionCount(realDS.getInitialSize());
        poolStatus.setMaxConnectionCount(realDS.getMaxActive());
        poolStatus.setMaxActiveTime(realDS.getMaxWait());

        poolStatus.setMaxOpenStatements(realDS.getMaxOpenPreparedStatements());
        poolStatus.setSnapshotTime(new Date());
        poolStatus.setIdleConnectionCount(realDS.getNumIdle());
        poolStatus.setActiveConnectionCount(realDS.getNumActive());
    } catch (Exception e) {
        poolStatus.setErrorTip("??");
    }

    return poolStatus;
}

From source file:org.pentaho.di.core.database.PoolableDataSourceTest.java

@Test
public void testPropertiesAreSet() throws Exception {
    Connection conn = null;//from  w  w  w. j av  a 2 s .c  o  m
    try {
        conn = getConnection();
        Field field = ConnectionPoolUtil.class.getDeclaredField("dataSources");
        assertNotNull("Can't find field 'dataSources' in class ConnectionPoolUtil", field);
        field.setAccessible(true);
        Map<String, BasicDataSource> dataSources = (Map<String, BasicDataSource>) field
                .get(ConnectionPoolUtil.class);
        BasicDataSource ds = dataSources.get(dbMeta.getName());

        assertEquals(true, ds.getDefaultAutoCommit());
        assertEquals(true, ds.getDefaultReadOnly());
        assertEquals(1, ds.getDefaultTransactionIsolation());
        assertEquals(null, ds.getDefaultCatalog());
        assertEquals(30, ds.getMaxIdle());
        assertEquals(3, ds.getMinIdle());
        assertEquals(MAX_WAIT_TIME, ds.getMaxWait());
        assertEquals(VALIDATION_QUERY, ds.getValidationQuery());
        assertEquals(true, ds.getTestOnBorrow());
        assertEquals(true, ds.getTestOnReturn());
        assertEquals(true, ds.getTestWhileIdle());
        assertEquals(300000, ds.getTimeBetweenEvictionRunsMillis());
        assertEquals(true, ds.isPoolPreparedStatements());
        assertEquals(2, ds.getMaxOpenPreparedStatements());
        assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
        assertEquals(false, ds.getRemoveAbandoned());
        assertEquals(1000, ds.getRemoveAbandonedTimeout());
        assertEquals(false, ds.getLogAbandoned());
    } finally {
        DatabaseUtil.closeSilently(conn);
    }
}

From source file:org.springframework.boot.autoconfigure.jdbc.CommonsDataSourceConfigurationTests.java

@Test
public void testDataSourcePropertiesOverridden() throws Exception {
    this.context.register(CommonsDataSourceConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "url:jdbc:foo//bar/spam");
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testWhileIdle:true");
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnBorrow:true");
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "testOnReturn:true");
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "timeBetweenEvictionRunsMillis:10000");
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "minEvictableIdleTimeMillis:12345");
    EnvironmentTestUtils.addEnvironment(this.context, PREFIX + "maxWait:1234");
    this.context.refresh();
    BasicDataSource ds = this.context.getBean(BasicDataSource.class);
    assertEquals("jdbc:foo//bar/spam", ds.getUrl());
    assertTrue(ds.getTestWhileIdle());//from  www  .j ava  2  s.c om
    assertTrue(ds.getTestOnBorrow());
    assertTrue(ds.getTestOnReturn());
    assertEquals(10000, ds.getTimeBetweenEvictionRunsMillis());
    assertEquals(12345, ds.getMinEvictableIdleTimeMillis());
    assertEquals(1234, ds.getMaxWait());
}