mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
move test
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.alibaba.druid.filter.stat;
|
||||
|
||||
public class MergeStatFilter extends StatFilter {
|
||||
public MergeStatFilter() {
|
||||
super.setMergeSql(true);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import junit.framework.TestCase;
|
||||
import oracle.jdbc.OracleConnection;
|
||||
import oracle.jdbc.internal.OraclePreparedStatement;
|
||||
|
||||
import com.alibaba.druid.bvt.util.OracleMockDriver;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.test.util.OracleMockDriver;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
public class TestOraclePrefetch extends TestCase {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.alibaba.druid.bvt.proxy.filter;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class MergeStatFilterTest extends TestCase {
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mock:xx");
|
||||
dataSource.setFilters("mergeStat");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
public void test_merge() throws Exception {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
String sql = "select * from t where id = " + i;
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(sql);
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
}
|
||||
|
||||
Assert.assertEquals(1, dataSource.getDataSourceStat().getSqlStatMap().size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.alibaba.druid.bvt.proxy.filter;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class MergeStatFilterTest2 extends TestCase {
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mock:xx");
|
||||
dataSource.setFilters("mergeStat");
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
public void test_merge() throws Exception {
|
||||
{
|
||||
String sql = "select * from t where id = 3 or id = 5 or id = 7";
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(sql);
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
}
|
||||
|
||||
{
|
||||
String sql = "select * from t where id = 122 or id = 55";
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute(sql);
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
}
|
||||
|
||||
Assert.assertEquals(1, dataSource.getDataSourceStat().getSqlStatMap()
|
||||
.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.alibaba.druid.bvt.sql.oracle;
|
||||
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class OracleFormatTest extends TestCase{
|
||||
public void test_formatOracle(){
|
||||
String sql = SQLUtils.formatOracle("select substr('123''''a''''bc',0,3) FROM dual");
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.druid.bvt.util;
|
||||
package com.alibaba.druid.test.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@@ -151,8 +151,8 @@ public class OracleMockConnection extends MockConnection implements oracle.jdbc.
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
public NUMBER createNUMBER(boolean arg0) throws SQLException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.druid.bvt.util;
|
||||
package com.alibaba.druid.test.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.druid.bvt.util;
|
||||
package com.alibaba.druid.test.util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.druid.bvt.util;
|
||||
package com.alibaba.druid.test.util;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
Reference in New Issue
Block a user