mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
添加测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@477 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class TestClose_2 extends TestCase {
|
||||
|
||||
public void test_close() throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setPoolPreparedStatements(true);
|
||||
dataSource.setUrl("jdbc:mock:xxx");
|
||||
|
||||
String sql = "SELECT 1";
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
CallableStatement stmt = conn.prepareCall(sql);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
Assert.assertEquals(false, rs.isClosed());
|
||||
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
stmt.close();
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
CallableStatement stmt2 = conn.prepareCall(sql);
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
|
||||
Assert.assertEquals(stmt, stmt2);
|
||||
|
||||
conn.close();
|
||||
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user