mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
if config incorrect, log error
This commit is contained in:
@@ -2,6 +2,7 @@ package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
@@ -21,8 +22,12 @@ public class ConfigErrorTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test_connect() throws Exception {
|
||||
Connection conn = dataSource.getConnection();
|
||||
DruidDataSource.LOG.resetStat();
|
||||
Assert.assertEquals(0, DruidDataSource.LOG.getErrorCount());
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(1, DruidDataSource.LOG.getErrorCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class ConfigErrorTest2 extends TestCase {
|
||||
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:wrap-jdbc:jdbc:mock:xxx");
|
||||
dataSource.setTestOnBorrow(false);
|
||||
dataSource.setTestOnReturn(false);
|
||||
dataSource.setTestWhileIdle(false);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
public void test_connect() throws Exception {
|
||||
DruidDataSource.LOG.resetStat();
|
||||
Assert.assertEquals(0, DruidDataSource.LOG.getErrorCount());
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(1, DruidDataSource.LOG.getErrorCount());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class ConfigErrorTest3 extends TestCase {
|
||||
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mysql:xxx");
|
||||
dataSource.setTestOnBorrow(false);
|
||||
dataSource.setTestOnReturn(false);
|
||||
dataSource.setTestWhileIdle(false);
|
||||
dataSource.setInitialSize(0);
|
||||
dataSource.setPoolPreparedStatements(true);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
public void test_connect() throws Exception {
|
||||
DruidDataSource.LOG.resetStat();
|
||||
Assert.assertEquals(0, DruidDataSource.LOG.getErrorCount());
|
||||
dataSource.init();
|
||||
Assert.assertEquals(1, DruidDataSource.LOG.getErrorCount());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user