use of org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig in project spring-cloud-connectors by spring-cloud.
the class AbstractDataSourceCreatorTest method cloudDataSourceCreationWithConfig.
@Test
public void cloudDataSourceCreationWithConfig() throws Exception {
SI relationalServiceInfo = createServiceInfo();
PoolConfig poolConfig = new PoolConfig("5", 100);
ConnectionConfig connectionConfig = new ConnectionConfig("foo=bar");
List<String> pooledDataSource = Collections.singletonList(BasicDbcpPooledDataSourceCreator.class.getSimpleName());
DataSourceConfig config = new DataSourceConfig(poolConfig, connectionConfig, pooledDataSource);
DataSource dataSource = getCreator().create(relationalServiceInfo, config);
assertDataSourceProperties(relationalServiceInfo, dataSource);
DataSourceCloudConfigTestHelper.assertPoolProperties(dataSource, 5, 0, 100);
Properties connectionProp = new Properties();
connectionProp.put("foo", "bar");
assertConnectionProperties(dataSource, connectionProp);
}
use of org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig in project spring-cloud-connectors by spring-cloud.
the class PooledDataSourceCreatorsTest method pooledDataSourceCreationDefault.
@Test
public void pooledDataSourceCreationDefault() throws Exception {
PoolConfig poolConfig = new PoolConfig(MIN_POOL_SIZE, MAX_POOL_SIZE, MAX_WAIT_TIME);
ConnectionConfig connectionConfig = new ConnectionConfig(CONNECTION_PROPERTIES_STRING);
DataSourceConfig config = new DataSourceConfig(poolConfig, connectionConfig);
DataSource ds = createMysqlDataSource(config);
assertTomcatJdbcDataSource(ds);
}
use of org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig in project spring-cloud-connectors by spring-cloud.
the class DatasourceConfigWithServiceConfig method dataSourceWithPoolAndConnectionConfig.
@Bean
public DataSource dataSourceWithPoolAndConnectionConfig() {
PoolConfig poolConfig = new PoolConfig(20, 200);
ConnectionConfig connectionConfig = new ConnectionConfig("sessionVariables=sql_mode='ANSI';characterEncoding=UTF-8");
DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, connectionConfig, basicDbcpConnectionPool());
return connectionFactory().dataSource("my-service", serviceConfig);
}
use of org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig in project spring-cloud-connectors by spring-cloud.
the class GenericServiceWithConnectorType method myServiceWithTypeWithServiceNameAndConfig.
@Bean
public DataSource myServiceWithTypeWithServiceNameAndConfig() {
PoolConfig poolConfig = new PoolConfig(20, 200);
ConnectionConfig connectionConfig = new ConnectionConfig("sessionVariables=sql_mode='ANSI';characterEncoding=UTF-8");
DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, connectionConfig);
return connectionFactory().service("my-service", DataSource.class, serviceConfig);
}
use of org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig in project spring-cloud-connectors by spring-cloud.
the class PooledDataSourceCreatorsTest method createMysqlDataSourceWithPooledName.
private DataSource createMysqlDataSourceWithPooledName(String pooledDataSourceName) {
List<String> dataSourceNames = Collections.singletonList(pooledDataSourceName);
PoolConfig poolConfig = new PoolConfig(MIN_POOL_SIZE, MAX_POOL_SIZE, MAX_WAIT_TIME);
ConnectionConfig connectionConfig = new ConnectionConfig(CONNECTION_PROPERTIES_STRING);
DataSourceConfig config = new DataSourceConfig(poolConfig, connectionConfig, dataSourceNames);
return createMysqlDataSource(config);
}
Aggregations