use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class DataSourceTest3 method test_error_5.
public void test_error_5() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.close();
dataSource.setInitialSize(dataSource.getInitialSize());
{
Exception error = null;
try {
dataSource.setInitialSize(10);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class DataSourceTest3 method test_error_4.
@SuppressWarnings("deprecation")
public void test_error_4() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.close();
dataSource.setMaxIdle(1);
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class DataSourceTest3 method test_setConnectionInitSqls.
public void test_setConnectionInitSqls() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.close();
dataSource.setConnectionInitSqls(null);
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class TestDataSourceBasic method test_prepare.
public void test_prepare() throws Exception {
Connection conn = dataSource.getConnection();
{
DruidPooledConnection wrap = conn.unwrap(DruidPooledConnection.class);
Assert.assertTrue(conn.isWrapperFor(DruidPooledConnection.class));
Assert.assertNotNull(wrap);
}
{
Statement wrap = conn.unwrap(Statement.class);
Assert.assertTrue(!conn.isWrapperFor(Statement.class));
Assert.assertNull(wrap);
}
conn.setAutoCommit(false);
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
stmt.execute("SELECT 1");
stmt.close();
Assert.assertEquals(1, dataSource.getActiveConnectionStackTrace().size());
Assert.assertEquals(1, dataSource.getActiveConnections().size());
conn.commit();
conn.close();
Assert.assertEquals(1, dataSource.getStartTransactionCount());
Assert.assertEquals(1, dataSource.getCommitCount());
Assert.assertEquals(0, dataSource.getRollbackCount());
Assert.assertEquals(0, dataSource.getActiveConnectionStackTrace().size());
Assert.assertEquals(0, dataSource.getActiveConnections().size());
}
use of com.alibaba.druid.pool.DruidPooledConnection in project druid by alibaba.
the class ConnectionTest5 method test_setClientInfo_1.
public void test_setClientInfo_1() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
conn.close();
{
SQLException error = null;
try {
conn.setClientInfo(new Properties());
} catch (SQLException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
Aggregations