mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor for filter
This commit is contained in:
+2
-2
@@ -49,13 +49,13 @@ public class FilterDatasourceConnectAndRecycleFilterTest extends TestCase {
|
||||
private AtomicLong dataSourceRecycleCount = new AtomicLong();
|
||||
|
||||
@Override
|
||||
public void dataSource_recycle(FilterChain chain, DruidPooledConnection connection) throws SQLException {
|
||||
public void dataSource_releaseConnection(FilterChain chain, DruidPooledConnection connection) throws SQLException {
|
||||
chain.dataSource_recycle(connection);
|
||||
dataSourceRecycleCount.incrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DruidPooledConnection dataSource_connect(FilterChain chain, DruidDataSource dataSource,
|
||||
public DruidPooledConnection dataSource_getConnection(FilterChain chain, DruidDataSource dataSource,
|
||||
long maxWaitMillis) throws SQLException {
|
||||
dataSourceConnectCount.incrementAndGet();
|
||||
return chain.dataSource_connect(dataSource, maxWaitMillis);
|
||||
|
||||
@@ -799,7 +799,7 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
filter.dataSource_recycle(chain, null);
|
||||
filter.dataSource_releaseConnection(chain, null);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
@@ -816,7 +816,7 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
filter.dataSource_recycle(chain, null);
|
||||
filter.dataSource_releaseConnection(chain, null);
|
||||
} catch (RuntimeException ex) {
|
||||
error = ex;
|
||||
}
|
||||
@@ -833,7 +833,7 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
filter.dataSource_recycle(chain, null);
|
||||
filter.dataSource_releaseConnection(chain, null);
|
||||
} catch (Error ex) {
|
||||
error = ex;
|
||||
}
|
||||
@@ -853,7 +853,7 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
filter.dataSource_connect(chain, null, 0L);
|
||||
filter.dataSource_getConnection(chain, null, 0L);
|
||||
} catch (SQLException ex) {
|
||||
error = ex;
|
||||
}
|
||||
@@ -871,7 +871,7 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
filter.dataSource_connect(chain, null, 0L);
|
||||
filter.dataSource_getConnection(chain, null, 0L);
|
||||
} catch (RuntimeException ex) {
|
||||
error = ex;
|
||||
}
|
||||
@@ -889,7 +889,7 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
|
||||
Throwable error = null;
|
||||
try {
|
||||
filter.dataSource_connect(chain, null, 0L);
|
||||
filter.dataSource_getConnection(chain, null, 0L);
|
||||
} catch (Error ex) {
|
||||
error = ex;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,24 @@ package com.alibaba.druid.bvt.sql.mysql;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
public class CobarHintsTest extends TestCase {
|
||||
public void test_0 () throws Exception {
|
||||
String sql = "/*!cobar: select,4,ireport.dm_mdm_mem_prod_noeff_sdt0.admin_member_seq=45654723*/ select * from t";
|
||||
|
||||
SQLUtils.formatMySql(sql);
|
||||
String sql = "/*!cobar: select,4,ireport.dm_mdm_mem_prod_noeff_sdt0.admin_member_seq=45654723*/ " +
|
||||
"select product_id, noeff_days,total_cnt from (" +
|
||||
"select product_id," +
|
||||
" noeff_days," +
|
||||
" count(*) over() as total_cnt " +
|
||||
" from ( " +
|
||||
" select product_id," +
|
||||
" noeff_days " +
|
||||
" from ireport.dm_mdm_mem_prod_noeff_sdt0" +
|
||||
" where admin_member_seq = 45654723" +
|
||||
") b Order by product_id desc ) a limit 25 offset (1-1)*20";
|
||||
|
||||
String mergedSql = ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.POSTGRESQL);
|
||||
System.out.println(mergedSql);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user