use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidDataSourceDecryptTest method testDecrypt.
@Test
public void testDecrypt() throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:oracle:thin:@");
dataSource.setUsername("xiaoyu");
dataSource.setPassword("OJfUm6WCHi7EuXqE6aEc+Po2xFrAGBeSNy8O2jWhV2FTG8/5kbRRr2rjNKhptlevm/03Y0048P7h88gdUOXAYg==");
dataSource.setFilters("config");
dataSource.setConnectionProperties("config.decrypt=true");
try {
dataSource.init();
Assert.assertEquals("The password is " + dataSource.getPassword(), "xiaoyu", dataSource.getPassword());
} finally {
JdbcUtils.close(dataSource);
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidDataSourceFactoryTest1 method test_other.
public void test_other() throws Exception {
Properties properties = new Properties();
properties.put(DruidDataSourceFactory.PROP_URL, "jdbc:mock:xxx");
properties.put(DruidDataSourceFactory.PROP_DEFAULTTRANSACTIONISOLATION, "xxx");
DruidDataSource dataSource = null;
try {
dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
Assert.assertEquals("jdbc:mock:xxx", dataSource.getUrl());
Assert.assertEquals(-1, dataSource.getDefaultTransactionIsolation().intValue());
} finally {
JdbcUtils.close(dataSource);
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidDataSourceFactoryTest1 method test_NONE.
public void test_NONE() throws Exception {
Properties properties = new Properties();
properties.put(DruidDataSourceFactory.PROP_URL, "jdbc:mock:xxx");
properties.put(DruidDataSourceFactory.PROP_DEFAULTTRANSACTIONISOLATION, "NONE");
DruidDataSource dataSource = null;
try {
dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
Assert.assertEquals("jdbc:mock:xxx", dataSource.getUrl());
Assert.assertEquals(Connection.TRANSACTION_NONE, dataSource.getDefaultTransactionIsolation().intValue());
} finally {
JdbcUtils.close(dataSource);
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class ConfigErrorTestMysql method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mysql:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(0);
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class DruidConnectionHolderTest method setUp.
protected void setUp() throws Exception {
driver = new Driver();
if (driver.getMajorVersion() == 5) {
exceptionClass = Class.forName("com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException");
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public int connection_getTransactionIsolation(FilterChain chain, ConnectionProxy connection) throws SQLException {
throw createSyntaxException();
}
});
}
}
Aggregations