use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class PropertyFileConnectionStringProviderTest method testPropertyFileConnectionStringProvider.
@Test
public void testPropertyFileConnectionStringProvider() throws Exception {
PropertyFileConnectionStringProvider provider = new PropertyFileConnectionStringProvider();
Set<String> names = new HashSet<>();
names.add(NAME);
Map<String, DataSourceConfigure> map = provider.getConnectionStrings(names);
DataSourceConfigure configure = map.get(NAME);
Assert.assertEquals(configure.getUserName(), "testUser");
Assert.assertEquals(configure.getPassword(), "testPassword");
Assert.assertEquals(configure.getConnectionUrl(), "jdbc:mysql://testIP:3306/testDb");
Assert.assertEquals(configure.getDriverClass(), "com.mysql.jdbc.Driver");
}
use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class DatabasePoolConfigParserTest method test2.
@Test
public void test2() {
DataSourceConfigure config = DataSourceConfigureLocator.getInstance().getUserDataSourceConfigure("dao_test_select");
Assert.assertEquals("dao_test_select", config.getName());
Assert.assertEquals(true, config.getBooleanProperty(DataSourceConfigureConstants.TESTWHILEIDLE, false));
Assert.assertEquals(true, config.getBooleanProperty(DataSourceConfigureConstants.TESTONBORROW, false));
Assert.assertEquals("SELECT 1", config.getProperty(DataSourceConfigureConstants.VALIDATIONQUERY));
Assert.assertEquals(30000, config.getIntProperty(DataSourceConfigureConstants.VALIDATIONINTERVAL, 0));
Assert.assertEquals(30000, config.getIntProperty(DataSourceConfigureConstants.TIMEBETWEENEVICTIONRUNSMILLIS, 0));
Assert.assertEquals(100, config.getIntProperty(DataSourceConfigureConstants.MAXACTIVE, 0));
Assert.assertEquals(10, config.getIntProperty(DataSourceConfigureConstants.MINIDLE, 0));
Assert.assertEquals(1000, config.getIntProperty(DataSourceConfigureConstants.MAXWAIT, 0));
Assert.assertEquals(10, config.getIntProperty(DataSourceConfigureConstants.INITIALSIZE, 0));
Assert.assertEquals(60, config.getIntProperty(DataSourceConfigureConstants.REMOVEABANDONEDTIMEOUT, 0));
Assert.assertEquals(true, config.getBooleanProperty(DataSourceConfigureConstants.REMOVEABANDONED, false));
Assert.assertEquals(true, config.getBooleanProperty(DataSourceConfigureConstants.LOGABANDONED, false));
Assert.assertEquals(30000, config.getIntProperty(DataSourceConfigureConstants.MINEVICTABLEIDLETIMEMILLIS, 0));
Assert.assertEquals("rewriteBatchedStatements=true;allowMultiQueries=true", config.getProperty(DataSourceConfigureConstants.CONNECTIONPROPERTIES));
}
use of com.ctrip.platform.dal.dao.configure.DataSourceConfigure in project dal by ctripcorp.
the class RefreshableDataSource method configChanged.
@Override
public synchronized void configChanged(DataSourceConfigureChangeEvent event) throws SQLException {
String name = event.getName();
DataSourceConfigure newConfigure = event.getNewDataSourceConfigure();
SingleDataSource newDataSource = new SingleDataSource(name, newConfigure);
SingleDataSource oldDataSource = dataSourceReference.getAndSet(newDataSource);
close(oldDataSource);
}
Aggregations