mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
49 lines
1.3 KiB
Java
49 lines
1.3 KiB
Java
package com.alibaba.druid.bvt.pool;
|
|
|
|
import java.sql.SQLException;
|
|
import java.util.Properties;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
import com.alibaba.druid.filter.FilterAdapter;
|
|
import com.alibaba.druid.filter.FilterChain;
|
|
import com.alibaba.druid.pool.DruidDataSource;
|
|
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
|
|
|
|
public class DruidDataSourceTest8 extends TestCase {
|
|
|
|
private DruidDataSource dataSource;
|
|
|
|
protected void setUp() throws Exception {
|
|
dataSource = new DruidDataSource();
|
|
dataSource.setUrl("jdbc:mock:xxx");
|
|
dataSource.setInitialSize(1);
|
|
dataSource.getProxyFilters().add(new FilterAdapter() {
|
|
|
|
@Override
|
|
public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
|
|
throw new Error();
|
|
}
|
|
});
|
|
}
|
|
|
|
protected void tearDown() throws Exception {
|
|
dataSource.close();
|
|
}
|
|
|
|
public void testInitError() throws Exception {
|
|
Assert.assertEquals(0, dataSource.getCreateErrorCount());
|
|
Throwable error = null;
|
|
try {
|
|
dataSource.init();
|
|
} catch (Throwable e) {
|
|
error = e;
|
|
}
|
|
Assert.assertNotNull(error);
|
|
Assert.assertTrue(dataSource.getCreateErrorCount() > 0);
|
|
}
|
|
|
|
}
|