Search in sources :

Example 6 with PreparedStatementKey

use of com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey in project druid by alibaba.

the class PreparedStatementKeyTest method test_equals_0.

public void test_equals_0() throws Exception {
    PreparedStatementKey k1 = new PreparedStatementKey("x1", "c1", MethodType.M1);
    PreparedStatementKey k2 = new PreparedStatementKey("x1", "c2", MethodType.M1);
    PreparedStatementKey k3 = new PreparedStatementKey("x1", "c3", MethodType.M1);
    Assert.assertFalse(k1.equals(k2));
    Assert.assertFalse(k1.equals(k3));
    Assert.assertFalse(k2.equals(k1));
    Assert.assertFalse(k2.equals(k3));
    Assert.assertFalse(k3.equals(k2));
    Assert.assertFalse(k3.equals(k1));
}
Also used : PreparedStatementKey(com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey)

Example 7 with PreparedStatementKey

use of com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey in project druid by alibaba.

the class PreparedStatementKeyTest method test_contains.

public void test_contains() throws Exception {
    DruidDataSource dataSource = new DruidDataSource();
    MockConnection conn = new MockConnection();
    PreparedStatementKey k1 = new PreparedStatementKey("x1", "c1", MethodType.M1);
    PreparedStatementPool pool = new PreparedStatementPool(new DruidConnectionHolder(dataSource, conn, 0));
    MockPreparedStatement raw = new MockPreparedStatement(null, null);
    pool.put(new PreparedStatementHolder(k1, raw));
    Assert.assertTrue(pool.get(k1) != null);
    Assert.assertTrue(pool.get(k1) != null);
}
Also used : PreparedStatementHolder(com.alibaba.druid.pool.PreparedStatementHolder) PreparedStatementPool(com.alibaba.druid.pool.PreparedStatementPool) PreparedStatementKey(com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey) DruidConnectionHolder(com.alibaba.druid.pool.DruidConnectionHolder) MockPreparedStatement(com.alibaba.druid.mock.MockPreparedStatement) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) MockConnection(com.alibaba.druid.mock.MockConnection)

Example 8 with PreparedStatementKey

use of com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey in project druid by alibaba.

the class PreparedStatementKeyTest method test_equals_2.

public void test_equals_2() throws Exception {
    PreparedStatementKey k1 = new PreparedStatementKey("x1", "c1", MethodType.M1);
    PreparedStatementKey k2 = new PreparedStatementKey("x2", "c1", MethodType.M1);
    PreparedStatementKey k3 = new PreparedStatementKey("x3", "c1", MethodType.M1);
    Assert.assertFalse(k1.equals(k2));
    Assert.assertFalse(k1.equals(k3));
    Assert.assertFalse(k2.equals(k1));
    Assert.assertFalse(k2.equals(k3));
    Assert.assertFalse(k3.equals(k2));
    Assert.assertFalse(k3.equals(k1));
}
Also used : PreparedStatementKey(com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey)

Example 9 with PreparedStatementKey

use of com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey in project druid by alibaba.

the class PreparedStatementKeyTest method test_equals_5.

public void test_equals_5() throws Exception {
    PreparedStatementKey k1 = new PreparedStatementKey("x1", null, MethodType.M1);
    PreparedStatementKey k2 = new PreparedStatementKey("x1", null, MethodType.M2);
    PreparedStatementKey k3 = new PreparedStatementKey("x1", null, MethodType.M3);
    k1.hashCode();
    Assert.assertFalse(k1.equals(k2));
    Assert.assertFalse(k1.equals(k3));
    Assert.assertFalse(k2.equals(k1));
    Assert.assertFalse(k2.equals(k3));
    Assert.assertFalse(k3.equals(k2));
    Assert.assertFalse(k3.equals(k1));
}
Also used : PreparedStatementKey(com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey)

Example 10 with PreparedStatementKey

use of com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey in project druid by alibaba.

the class PreparedStatementKeyTest method test_equals_7.

public void test_equals_7() throws Exception {
    PreparedStatementKey k1 = new PreparedStatementKey("x1", null, MethodType.M1, 0, 0);
    PreparedStatementKey k2 = new PreparedStatementKey("x1", null, MethodType.M1, 1, 0);
    PreparedStatementKey k3 = new PreparedStatementKey("x2", null, MethodType.M1, 0, 1);
    k1.hashCode();
    Assert.assertFalse(k1.equals(k2));
    Assert.assertFalse(k1.equals(k3));
    Assert.assertFalse(k2.equals(k1));
    Assert.assertFalse(k2.equals(k3));
    Assert.assertFalse(k3.equals(k2));
    Assert.assertFalse(k3.equals(k1));
}
Also used : PreparedStatementKey(com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey)

Aggregations

PreparedStatementKey (com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey)19 SQLException (java.sql.SQLException)8 MockConnection (com.alibaba.druid.mock.MockConnection)3 DruidConnectionHolder (com.alibaba.druid.pool.DruidConnectionHolder)3 PreparedStatementHolder (com.alibaba.druid.pool.PreparedStatementHolder)3 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)2 DruidPooledConnection (com.alibaba.druid.pool.DruidPooledConnection)2 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)1 DruidPooledCallableStatement (com.alibaba.druid.pool.DruidPooledCallableStatement)1 DruidPooledPreparedStatement (com.alibaba.druid.pool.DruidPooledPreparedStatement)1 PreparedStatementPool (com.alibaba.druid.pool.PreparedStatementPool)1