@Test void testAllPropertiesSet() throws Exception { TomcatJdbcDataSourceFactory tomcatJdbcDataSourceFactory = new TomcatJdbcDataSourceFactory(); tomcatJdbcDataSourceFactory.setDbProperties(new Properties()); tomcatJdbcDataSourceFactory.setDefaultAutoCommit(true); tomcatJdbcDataSourceFactory.setDefaultReadOnly(false); tomcatJdbcDataSourceFactory.setDefaultTransactionIsolation( TransactionDefinition.ISOLATION_READ_COMMITTED); tomcatJdbcDataSourceFactory.setDefaultCatalog("myCatalog"); tomcatJdbcDataSourceFactory.setConnectionProperties("foo=bar"); tomcatJdbcDataSourceFactory.setInitialSize(11); tomcatJdbcDataSourceFactory.setMaxActive(100); tomcatJdbcDataSourceFactory.setMaxIdle(110); tomcatJdbcDataSourceFactory.setMinIdle(10); tomcatJdbcDataSourceFactory.setMaxWait(23); tomcatJdbcDataSourceFactory.setValidationQuery("SELECT 1"); tomcatJdbcDataSourceFactory.setTestOnBorrow(true); tomcatJdbcDataSourceFactory.setTestOnReturn(true); tomcatJdbcDataSourceFactory.setTestWhileIdle(true); tomcatJdbcDataSourceFactory.setTimeBetweenEvictionRunsMillis(100); tomcatJdbcDataSourceFactory.setNumTestsPerEvictionRun(100); tomcatJdbcDataSourceFactory.setMinEvictableIdleTimeMillis(1000); tomcatJdbcDataSourceFactory.setAccessToUnderlyingConnectionAllowed(false); tomcatJdbcDataSourceFactory.setRemoveAbandoned(true); tomcatJdbcDataSourceFactory.setLogAbandoned(true); tomcatJdbcDataSourceFactory.setValidationInterval(10000); tomcatJdbcDataSourceFactory.setJmxEnabled(true); tomcatJdbcDataSourceFactory.setInitSQL("SET SCHEMA"); tomcatJdbcDataSourceFactory.setTestOnConnect(true); tomcatJdbcDataSourceFactory.setJdbcInterceptors("foo"); tomcatJdbcDataSourceFactory.setFairQueue(false); tomcatJdbcDataSourceFactory.setUseEquals(false); tomcatJdbcDataSourceFactory.setAbandonWhenPercentageFull(80); tomcatJdbcDataSourceFactory.setMaxAge(100); tomcatJdbcDataSourceFactory.setUseLock(true); tomcatJdbcDataSourceFactory.setSuspectTimeout(200); tomcatJdbcDataSourceFactory.setDataSourceJNDI("foo"); tomcatJdbcDataSourceFactory.setAlternateUsernameAllowed(true); tomcatJdbcDataSourceFactory.setCommitOnReturn(true); tomcatJdbcDataSourceFactory.setRollbackOnReturn(true); tomcatJdbcDataSourceFactory.setUseDisposableConnectionFacade(false); tomcatJdbcDataSourceFactory.setLogValidationErrors(true); tomcatJdbcDataSourceFactory.setPropagateInterruptState(true); DataSourceInformation dataSourceInformation = new DataSourceInformation( DatabaseType.MYSQL, "localhost", 3306, "test", "user", "password"); DataSource dataSource = tomcatJdbcDataSourceFactory .createDataSource(dataSourceInformation); BeanWrapper source = PropertyAccessorFactory .forBeanPropertyAccess(tomcatJdbcDataSourceFactory); BeanWrapper target = PropertyAccessorFactory .forBeanPropertyAccess(dataSource.getPoolProperties()); List<String> ignoredProperties = Arrays.asList("driverClassName", "url", "username", "password"); for (PropertyDescriptor propertyDescriptor : source.getPropertyDescriptors()) { if (propertyDescriptor.getWriteMethod() != null && target.isReadableProperty(propertyDescriptor.getName()) && !ignoredProperties.contains(propertyDescriptor.getName())) { assertThat(target.getPropertyValue(propertyDescriptor.getName())) .isEqualTo(source.getPropertyValue(propertyDescriptor.getName())); } } }
@Override public org.apache.tomcat.jdbc.pool.DataSource createDataSource( DataSourceInformation dataSourceInformation) { PoolConfiguration configurationToUse = new PoolProperties(); BeanUtils.copyProperties(this, configurationToUse); configurationToUse.setDriverClassName(this.databasePlatformSupport .getDriverClassNameForDatabase(dataSourceInformation.getDatabaseType())); configurationToUse.setUrl(this.databasePlatformSupport.getDatabaseUrlForDatabase( dataSourceInformation.getDatabaseType(), dataSourceInformation.getHostName(), dataSourceInformation.getPort(), dataSourceInformation.getDatabaseName())); configurationToUse.setUsername(dataSourceInformation.getUserName()); configurationToUse.setPassword(dataSourceInformation.getPassword()); return new org.apache.tomcat.jdbc.pool.DataSource(configurationToUse); }
TomcatJdbcDataSourceFactory extends PoolProperties implements DataSourceFactory { @Override public org.apache.tomcat.jdbc.pool.DataSource createDataSource( DataSourceInformation dataSourceInformation) { PoolConfiguration configurationToUse = new PoolProperties(); BeanUtils.copyProperties(this, configurationToUse); configurationToUse.setDriverClassName(this.databasePlatformSupport .getDriverClassNameForDatabase(dataSourceInformation.getDatabaseType())); configurationToUse.setUrl(this.databasePlatformSupport.getDatabaseUrlForDatabase( dataSourceInformation.getDatabaseType(), dataSourceInformation.getHostName(), dataSourceInformation.getPort(), dataSourceInformation.getDatabaseName())); configurationToUse.setUsername(dataSourceInformation.getUserName()); configurationToUse.setPassword(dataSourceInformation.getPassword()); return new org.apache.tomcat.jdbc.pool.DataSource(configurationToUse); } }
TomcatJdbcDataSourceFactory extends PoolProperties implements DataSourceFactory { @Override public org.apache.tomcat.jdbc.pool.DataSource createDataSource( DataSourceInformation dataSourceInformation) { PoolConfiguration configurationToUse = new PoolProperties(); BeanUtils.copyProperties(this, configurationToUse); configurationToUse.setDriverClassName(this.databasePlatformSupport .getDriverClassNameForDatabase(dataSourceInformation.getDatabaseType())); configurationToUse.setUrl(this.databasePlatformSupport.getDatabaseUrlForDatabase( dataSourceInformation.getDatabaseType(), dataSourceInformation.getHostName(), dataSourceInformation.getPort(), dataSourceInformation.getDatabaseName())); configurationToUse.setUsername(dataSourceInformation.getUserName()); configurationToUse.setPassword(dataSourceInformation.getPassword()); return new org.apache.tomcat.jdbc.pool.DataSource(configurationToUse); }  }
TomcatJdbcDataSourceFactory extends PoolProperties implements DataSourceFactory { @Override public org.apache.tomcat.jdbc.pool.DataSource createDataSource( DataSourceInformation dataSourceInformation) { PoolConfiguration configurationToUse = new PoolProperties(); BeanUtils.copyProperties(this, configurationToUse); configurationToUse.setDriverClassName(this.databasePlatformSupport .getDriverClassNameForDatabase(dataSourceInformation.getDatabaseType())); configurationToUse.setUrl(this.databasePlatformSupport.getDatabaseUrlForDatabase( dataSourceInformation.getDatabaseType(), dataSourceInformation.getHostName(), dataSourceInformation.getPort(), dataSourceInformation.getDatabaseName())); configurationToUse.setUsername(dataSourceInformation.getUserName()); configurationToUse.setPassword(dataSourceInformation.getPassword()); return new org.apache.tomcat.jdbc.pool.DataSource(configurationToUse); }  @Override void setUsername(String username); @Override void setPassword(String password); @Override void setDriverClassName(String driverClassName); @Override void setUrl(String url); void setDefaultTransactionIsolationName(String constantName); void setDatabasePlatformSupport(
			DatabasePlatformSupport databasePlatformSupport); @Override org.apache.tomcat.jdbc.pool.DataSource createDataSource(
			DataSourceInformation dataSourceInformation); @Override void closeDataSource(DataSource dataSource); }
TomcatJdbcDataSourceFactory extends PoolProperties implements DataSourceFactory { @Override public org.apache.tomcat.jdbc.pool.DataSource createDataSource( DataSourceInformation dataSourceInformation) { PoolConfiguration configurationToUse = new PoolProperties(); BeanUtils.copyProperties(this, configurationToUse); configurationToUse.setDriverClassName(this.databasePlatformSupport .getDriverClassNameForDatabase(dataSourceInformation.getDatabaseType())); configurationToUse.setUrl(this.databasePlatformSupport.getDatabaseUrlForDatabase( dataSourceInformation.getDatabaseType(), dataSourceInformation.getHostName(), dataSourceInformation.getPort(), dataSourceInformation.getDatabaseName())); configurationToUse.setUsername(dataSourceInformation.getUserName()); configurationToUse.setPassword(dataSourceInformation.getPassword()); return new org.apache.tomcat.jdbc.pool.DataSource(configurationToUse); }  @Override void setUsername(String username); @Override void setPassword(String password); @Override void setDriverClassName(String driverClassName); @Override void setUrl(String url); void setDefaultTransactionIsolationName(String constantName); void setDatabasePlatformSupport(
			DatabasePlatformSupport databasePlatformSupport); @Override org.apache.tomcat.jdbc.pool.DataSource createDataSource(
			DataSourceInformation dataSourceInformation); @Override void closeDataSource(DataSource dataSource);  }