Skip to content

Commit 7cf57c3

Browse files
committed
回退相关测试用例 #5771 #4885
回退相关测试用例 #5771 #4885
1 parent 8483fca commit 7cf57c3

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

core/src/test/java/com/alibaba/druid/bvt/pool/Case1.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,8 @@ public Connection connect(String url, Properties info) throws SQLException {
5252
dataSource.setMinIdle(0);
5353
dataSource.setMaxActive(2);
5454
dataSource.setMaxIdle(2);
55-
56-
Exception error = null;
57-
try {
58-
Connection conn = dataSource.getConnection();
59-
conn.close();
60-
} catch (Exception e) {
61-
error = e;
62-
}
63-
64-
Assert.assertTrue(error instanceof DataSourceDisableException);
55+
Connection conn = dataSource.getConnection();
56+
conn.close();
57+
dataSource.close();
6558
}
6659
}

core/src/test/java/com/alibaba/druid/bvt/pool/DruidDataSourceTest5.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class DruidDataSourceTest5 extends TestCase {
1717

1818
private final AtomicBoolean validate = new AtomicBoolean(true);
1919

20-
@Before
20+
2121
protected void setUp() throws Exception {
2222
validate.set(true);
2323

@@ -34,8 +34,8 @@ public boolean isValidConnection(Connection c, String query, int validationQuery
3434
});
3535
}
3636

37-
@After
38-
protected void tearDown() throws Exception {
37+
38+
public void tearDown() throws Exception {
3939
dataSource.close();
4040
}
4141

@@ -49,6 +49,11 @@ public void testValidate() throws Exception {
4949
error = e;
5050
}
5151
Assert.assertNotNull(error);
52+
53+
validate.set(true);
54+
55+
Connection conn = dataSource.getConnection();
56+
conn.close();
5257
}
5358

5459
public void testValidate_1() throws Exception {
@@ -61,6 +66,11 @@ public void testValidate_1() throws Exception {
6166
error = e;
6267
}
6368
Assert.assertNotNull(error);
69+
70+
validate.set(true);
71+
72+
Connection conn = dataSource.getConnection();
73+
conn.close();
6474
}
6575

6676
public void testValidate_3() throws Exception {
@@ -73,6 +83,11 @@ public void testValidate_3() throws Exception {
7383
error = e;
7484
}
7585
Assert.assertNotNull(error);
86+
87+
validate.set(true);
88+
89+
Connection conn = dataSource.getConnection();
90+
conn.close();
7691
}
7792

7893
}

core/src/test/java/com/alibaba/druid/bvt/pool/TestConnectError.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected void setUp() throws Exception {
3737

3838
public Connection connect(String url, Properties info) throws SQLException {
3939
// create first connection successfully.
40-
if (count.incrementAndGet() % 2 == 0) {
40+
if (count.getAndIncrement() % 2 == 0) {
4141
throw new SQLException();
4242
}
4343

@@ -76,17 +76,13 @@ public void test_connect_error() throws Exception {
7676
int count = 10;
7777
Connection[] connections = new Connection[count];
7878
for (int i = 0; i < count; ++i) {
79-
try {
80-
connections[i] = dataSource.getConnection();
81-
} catch (Exception e) {
82-
// do nothing
83-
}
79+
connections[i] = dataSource.getConnection();
8480
}
8581

8682
for (int i = 0; i < count; ++i) {
8783
connections[i].close();
8884
}
8985

90-
Assert.assertEquals(9, dataSource.getCreateErrorCount());
86+
Assert.assertEquals(10, dataSource.getCreateErrorCount());
9187
}
9288
}

core/src/test/java/com/alibaba/druid/bvt/pool/profile/FailFastTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.alibaba.druid.PoolTestCase;
1111
import org.junit.Assert;
1212
import com.alibaba.druid.pool.DataSourceDisableException;
13+
import com.alibaba.druid.pool.DataSourceNotAvailableException;
1314
import com.alibaba.druid.pool.DruidDataSource;
1415

1516
public class FailFastTest extends PoolTestCase {
@@ -81,7 +82,7 @@ public void run() {
8182
latch.countDown();
8283
connectEndLatch.await(3, TimeUnit.SECONDS);
8384
SQLException ex = errorHolder.get();
84-
Assert.assertTrue(ex instanceof DataSourceDisableException);
85+
Assert.assertTrue(ex instanceof DataSourceNotAvailableException);
8586

8687
for (int i = 0; i < 300; ++i) {
8788
if (!dataSource.isFailContinuous()) {

0 commit comments

Comments
 (0)