mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
testcase refactor.
This commit is contained in:
@@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -27,13 +28,13 @@ import com.alibaba.druid.mock.MockDriver;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
public class ConnectionTest extends TestCase {
|
||||
public class ConnectionTest extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
DruidDataSourceStatManager.clear();
|
||||
super.setUp();
|
||||
|
||||
driver = new MockDriver();
|
||||
|
||||
@@ -54,7 +55,7 @@ public class ConnectionTest extends TestCase {
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_prepare() throws Exception {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -27,7 +28,7 @@ import com.alibaba.druid.mock.MockDriver;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
public class ConnectionTest2 extends TestCase {
|
||||
public class ConnectionTest2 extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
@@ -58,6 +59,8 @@ public class ConnectionTest2 extends TestCase {
|
||||
Assert.assertEquals(0, dataSource.getCreateCount());
|
||||
dataSource.close();
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_prepare() throws Exception {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -30,7 +31,7 @@ import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
import com.alibaba.druid.stat.JdbcStatContext;
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
|
||||
public class ConnectionTest3 extends TestCase {
|
||||
public class ConnectionTest3 extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
@@ -64,6 +65,8 @@ public class ConnectionTest3 extends TestCase {
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
JdbcStatManager.getInstance().setStatContext(null);
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_basic() throws Exception {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -35,7 +36,7 @@ import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
import com.alibaba.druid.stat.JdbcStatContext;
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
|
||||
public class ConnectionTest4 extends TestCase {
|
||||
public class ConnectionTest4 extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
@@ -70,6 +71,7 @@ public class ConnectionTest4 extends TestCase {
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
JdbcStatManager.getInstance().setStatContext(null);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_basic() throws Exception {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Properties;
|
||||
import javax.sql.ConnectionEvent;
|
||||
import javax.sql.ConnectionEventListener;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -31,7 +32,7 @@ import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
import com.alibaba.druid.stat.JdbcStatContext;
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
|
||||
public class ConnectionTest5 extends TestCase {
|
||||
public class ConnectionTest5 extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
@@ -66,6 +67,8 @@ public class ConnectionTest5 extends TestCase {
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
JdbcStatManager.getInstance().setStatContext(null);
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_basic() throws Exception {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Properties;
|
||||
|
||||
import javax.security.auth.callback.PasswordCallback;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -34,7 +35,7 @@ import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
import com.alibaba.druid.stat.JdbcStatContext;
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
|
||||
public class DataSourceTest3 extends TestCase {
|
||||
public class DataSourceTest3 extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
@@ -68,6 +69,8 @@ public class DataSourceTest3 extends TestCase {
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
JdbcStatManager.getInstance().setStatContext(null);
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_prepareStatement_error() throws Exception {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.sql.Statement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import org.junit.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -30,13 +31,13 @@ import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.alibaba.druid.pool.vendor.NullExceptionSorter;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
public class TestDataSourceBasic extends TestCase {
|
||||
public class TestDataSourceBasic extends PoolTestCase {
|
||||
|
||||
private MockDriver driver;
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
DruidDataSourceStatManager.clear();
|
||||
super.setUp();
|
||||
|
||||
driver = new MockDriver();
|
||||
|
||||
@@ -67,6 +68,8 @@ public class TestDataSourceBasic extends TestCase {
|
||||
}
|
||||
dataSource.close();
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_toCompositeData() throws Exception {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.alibaba.druid.bvt.pool.basic;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.PoolTestCase;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -26,7 +27,7 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
public class TestDataSourceBasic2 extends TestCase {
|
||||
public class TestDataSourceBasic2 extends PoolTestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DruidDataSourceStatManager.clear();
|
||||
@@ -126,6 +127,8 @@ public class TestDataSourceBasic2 extends TestCase {
|
||||
for (DruidDataSource dataSource : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user