mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add testcase & remove unused code
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.alibaba.druid.bvt.sql.postgresql;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGExportParameterVisitor;
|
||||
|
||||
|
||||
public class PGExportParameterVisitorTest extends TestCase {
|
||||
public void test_pg() throws Exception {
|
||||
String sql = "select fname, count(*) from t where fid = 1 group by fname order by 1";
|
||||
|
||||
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
|
||||
List<Object> parameters = new ArrayList<Object>();
|
||||
PGExportParameterVisitor visitor = new PGExportParameterVisitor(parameters);
|
||||
stmt.accept(visitor);
|
||||
|
||||
Assert.assertEquals(1, parameters.size());
|
||||
Assert.assertEquals(1, parameters.get(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.alibaba.druid.bvt.sql.postgresql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGExportParameterVisitor;
|
||||
|
||||
|
||||
public class PGExportParameterVisitorTest1 extends TestCase {
|
||||
public void test_pg() throws Exception {
|
||||
String sql = "select fname, count(*) from t where fid = 1 group by fname order by 1";
|
||||
|
||||
PGSQLStatementParser parser = new PGSQLStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
|
||||
PGExportParameterVisitor visitor = new PGExportParameterVisitor();
|
||||
stmt.accept(visitor);
|
||||
|
||||
List<Object> parameters = visitor.getParameters();
|
||||
|
||||
Assert.assertEquals(1, parameters.size());
|
||||
Assert.assertEquals(1, parameters.get(0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user