mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
仿照JBOSS实现PreparedStatementCache
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@912 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -7,6 +7,7 @@ import java.sql.ResultSet;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockStatement;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
@@ -38,9 +39,9 @@ public class TestClose_1 extends TestCase {
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
PreparedStatement stmt2 = conn.prepareStatement(sql);
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
|
||||
Assert.assertEquals(stmt, stmt2);
|
||||
Assert.assertEquals(stmt.unwrap(MockStatement.class), stmt2.unwrap(MockStatement.class));
|
||||
|
||||
conn.close();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.sql.ResultSet;
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockStatement;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
@@ -37,9 +38,9 @@ public class TestClose_2 extends TestCase {
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
CallableStatement stmt2 = conn.prepareCall(sql);
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
|
||||
Assert.assertEquals(stmt, stmt2);
|
||||
Assert.assertEquals(stmt.unwrap(MockStatement.class), stmt2.unwrap(MockStatement.class));
|
||||
|
||||
conn.close();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.mock.MockPreparedStatement;
|
||||
import com.alibaba.druid.pool.PoolablePreparedStatement;
|
||||
import com.alibaba.druid.pool.PoolablePreparedStatement.PreparedStatementKey;
|
||||
import com.alibaba.druid.pool.PreparedStatementPool;
|
||||
@@ -96,7 +97,7 @@ public class PreparedStatementKeyTest extends TestCase {
|
||||
public void test_contains() throws Exception {
|
||||
PreparedStatementKey k1 = new PreparedStatementKey("x1", "c1", MethodType.M1);
|
||||
PreparedStatementPool pool = new PreparedStatementPool();
|
||||
pool.put(new PoolablePreparedStatement(null, null, k1, null));
|
||||
pool.put(new PoolablePreparedStatement(null, new MockPreparedStatement(null, null), k1, null));
|
||||
Assert.assertTrue(pool.get(k1) != null);
|
||||
Assert.assertTrue(pool.get(k1) == null);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public class StatFilterTest extends TestCase {
|
||||
if (url.equals((String) row.get("URL"))) {
|
||||
count++;
|
||||
}
|
||||
Assert.assertEquals(0L, row.get("ExecuteCount_30_more_Minutes"));
|
||||
long[] histogram = (long[]) row.get("Histogram");
|
||||
Assert.assertEquals(0L, histogram[histogram.length - 1]);
|
||||
}
|
||||
Assert.assertEquals(true, count > 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user