添加测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@477 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-07-19 08:06:22 +00:00
parent 3e0482da51
commit babcee9b43
@@ -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();
}
}