Search in sources :

Example 66 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class ConfigFilterTest method testNormalInit.

@Test
public void testNormalInit() throws SQLException {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:oracle:thin:@");
    try {
        dataSource.init();
    } finally {
        JdbcUtils.close(dataSource);
    }
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Test(org.junit.Test)

Example 67 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class ConfigFilterTest method testInvalidInit.

@Test
public void testInvalidInit() throws SQLException {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriver(MockDriver.instance);
    dataSource.setFilters("config");
    dataSource.setConnectionProperties("config.file=abcdefeg");
    Exception error = null;
    try {
        dataSource.init();
    } catch (IllegalArgumentException e) {
        error = e;
    } finally {
        JdbcUtils.close(dataSource);
    }
    Assert.assertNotNull(error);
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 68 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class ConfigFilterTest method testInitInvalidRemoteConfigFile.

@Test
public void testInitInvalidRemoteConfigFile() throws SQLException {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setFilters("config");
    dataSource.setConnectionProperties("config.file=abcdef");
    Exception error = null;
    try {
        dataSource.init();
    } catch (IllegalArgumentException e) {
        error = e;
    } finally {
        JdbcUtils.close(dataSource);
    }
    Assert.assertNotNull(error);
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 69 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class ConfigFilterTest method testInitRemoteConfigAndDecrypt.

@Test
public void testInitRemoteConfigAndDecrypt() throws SQLException {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setFilters("config");
    dataSource.setConnectionProperties("config.decrypt=true;config.file=" + "file://" + this.filePath);
    try {
        dataSource.init();
        Assert.assertEquals("The password is " + dataSource.getPassword(), "xiaoyu", dataSource.getPassword());
    } finally {
        JdbcUtils.close(dataSource);
    }
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Test(org.junit.Test)

Example 70 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class ConfigFilterTest1 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("config");
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

DruidDataSource (com.alibaba.druid.pool.DruidDataSource)389 SQLException (java.sql.SQLException)56 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)55 OracleExceptionSorter (com.alibaba.druid.pool.vendor.OracleExceptionSorter)50 MockDriver (com.alibaba.druid.mock.MockDriver)48 Connection (java.sql.Connection)36 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)35 Properties (java.util.Properties)34 FilterChain (com.alibaba.druid.filter.FilterChain)33 ResultSet (java.sql.ResultSet)19 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)18 MockConnection (com.alibaba.druid.mock.MockConnection)13 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)13 Method (java.lang.reflect.Method)11 PreparedStatement (java.sql.PreparedStatement)11 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)10 Field (java.lang.reflect.Field)8 MockResultSet (com.alibaba.druid.mock.MockResultSet)7 TabularData (javax.management.openmbean.TabularData)7 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)6