mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
package com.alibaba.druid.bvt.pool;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.SQLException;
|
|
import java.util.Properties;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
import com.alibaba.druid.filter.FilterAdapter;
|
|
import com.alibaba.druid.filter.FilterChain;
|
|
import com.alibaba.druid.pool.DruidDataSource;
|
|
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
|
|
|
|
/**
|
|
* 这个场景测试defaultAutoCommit
|
|
*
|
|
* @author wenshao<szujobs@hotmail.com>
|
|
*/
|
|
public class DruidDataSourceTest6 extends TestCase {
|
|
|
|
private DruidDataSource dataSource;
|
|
|
|
protected void setUp() throws Exception {
|
|
dataSource = new DruidDataSource();
|
|
dataSource.setUrl("jdbc:mock:xxx");
|
|
dataSource.setTestOnBorrow(false);
|
|
dataSource.setDefaultAutoCommit(true);
|
|
dataSource.getProxyFilters().add(new FilterAdapter() {
|
|
public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
|
|
ConnectionProxy conn = chain.connection_connect(info);
|
|
conn.setAutoCommit(false);
|
|
return conn;
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
protected void tearDown() throws Exception {
|
|
dataSource.close();
|
|
}
|
|
|
|
public void test_autoCommit() throws Exception {
|
|
Connection conn = dataSource.getConnection();
|
|
|
|
Assert.assertTrue(conn.getAutoCommit());
|
|
|
|
conn.close();
|
|
}
|
|
}
|