mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
重构测试并且删除多余代码
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@965 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -19,6 +19,7 @@ public class HADataSource extends MultiDataSource implements DataSource {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(HADataSource.class);
|
||||
|
||||
protected DruidDataSource master;
|
||||
protected ArrayList<DruidDataSource> dataSources = new ArrayList<DruidDataSource>();
|
||||
protected final List<DruidDataSource> notAvailableDatasources = new CopyOnWriteArrayList<DruidDataSource>();
|
||||
|
||||
@@ -28,6 +29,14 @@ public class HADataSource extends MultiDataSource implements DataSource {
|
||||
|
||||
}
|
||||
|
||||
public DruidDataSource getMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public void setMaster(DruidDataSource master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
public List<DruidDataSource> getDataSources() {
|
||||
return Collections.unmodifiableList(dataSources);
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLTimeLiteralExpr extends SQLLiteralExpr {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SQLTimeLiteralValue time;
|
||||
private SQLTimeZoneIntervalValue timeZone;
|
||||
|
||||
public SQLTimeLiteralExpr(){
|
||||
|
||||
}
|
||||
|
||||
public SQLTimeLiteralValue getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(SQLTimeLiteralValue time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public SQLTimeZoneIntervalValue getTimeZone() {
|
||||
return timeZone;
|
||||
}
|
||||
|
||||
public void setTimeZone(SQLTimeZoneIntervalValue timeZone) {
|
||||
this.timeZone = timeZone;
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("TIME'");
|
||||
this.time.output(buf);
|
||||
if (timeZone != null) {
|
||||
timeZone.output(buf);
|
||||
}
|
||||
buf.append("'");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.expr;
|
||||
|
||||
public class SQLTimeLiteralValue {
|
||||
|
||||
private int hours;
|
||||
private int minutes;
|
||||
private int seconds;
|
||||
private int secondsFraction;
|
||||
|
||||
public int getHours() {
|
||||
return hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours) {
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public int getMinutes() {
|
||||
return minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes) {
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public int getSeconds() {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds) {
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public int getSecondsFraction() {
|
||||
return secondsFraction;
|
||||
}
|
||||
|
||||
public void setSecondsFraction(int secondsFraction) {
|
||||
this.secondsFraction = secondsFraction;
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append(hours);
|
||||
buf.append(':');
|
||||
buf.append(minutes);
|
||||
buf.append(':');
|
||||
buf.append(seconds);
|
||||
if (secondsFraction > 0) {
|
||||
buf.append('.');
|
||||
buf.append(secondsFraction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.expr;
|
||||
|
||||
public class SQLTimeZoneIntervalValue {
|
||||
|
||||
private SQLUnaryOperator sign = SQLUnaryOperator.Plus;
|
||||
private int hours;
|
||||
private int minutes;
|
||||
|
||||
public SQLUnaryOperator getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(SQLUnaryOperator sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public int getHours() {
|
||||
return hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours) {
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public int getMinutes() {
|
||||
return minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes) {
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
if (sign == SQLUnaryOperator.Plus) {
|
||||
buf.append('+');
|
||||
} else {
|
||||
buf.append('-');
|
||||
}
|
||||
buf.append(hours);
|
||||
buf.append(':');
|
||||
buf.append(minutes);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.expr;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLTimestampLiteralExpr extends SQLLiteralExpr {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SQLDateLiteralValue dateValue;
|
||||
private SQLTimeLiteralValue timeValue;
|
||||
private SQLTimeZoneIntervalValue timeZoneValue;
|
||||
|
||||
public SQLTimestampLiteralExpr(){
|
||||
|
||||
}
|
||||
|
||||
public SQLDateLiteralValue getDateValue() {
|
||||
return dateValue;
|
||||
}
|
||||
|
||||
public void setDateValue(SQLDateLiteralValue dateValue) {
|
||||
this.dateValue = dateValue;
|
||||
}
|
||||
|
||||
public SQLTimeLiteralValue getTimeValue() {
|
||||
return timeValue;
|
||||
}
|
||||
|
||||
public void setTimeValue(SQLTimeLiteralValue timeValue) {
|
||||
this.timeValue = timeValue;
|
||||
}
|
||||
|
||||
public SQLTimeZoneIntervalValue getTimeZoneValue() {
|
||||
return timeZoneValue;
|
||||
}
|
||||
|
||||
public void setTimeZoneValue(SQLTimeZoneIntervalValue timeZoneValue) {
|
||||
this.timeZoneValue = timeZoneValue;
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("TIMESTAMP'");
|
||||
this.dateValue.output(buf);
|
||||
buf.append(' ');
|
||||
this.timeValue.output(buf);
|
||||
if (timeZoneValue != null) {
|
||||
timeZoneValue.output(buf);
|
||||
}
|
||||
buf.append("'");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,8 +47,6 @@ import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLSomeExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLTimeLiteralExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLTimestampLiteralExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLUnaryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.NotNullConstraint;
|
||||
@@ -194,14 +192,6 @@ public interface SQLASTVisitor {
|
||||
|
||||
void endVisit(SQLDateLiteralExpr x);
|
||||
|
||||
boolean visit(SQLTimeLiteralExpr x);
|
||||
|
||||
void endVisit(SQLTimeLiteralExpr x);
|
||||
|
||||
boolean visit(SQLTimestampLiteralExpr x);
|
||||
|
||||
void endVisit(SQLTimestampLiteralExpr x);
|
||||
|
||||
boolean visit(SQLSelect x);
|
||||
|
||||
void endVisit(SQLSelect select);
|
||||
|
||||
@@ -47,8 +47,6 @@ import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLSomeExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLTimeLiteralExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLTimestampLiteralExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLUnaryExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.NotNullConstraint;
|
||||
@@ -267,20 +265,6 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
|
||||
public void endVisit(SQLDateLiteralExpr x) {
|
||||
}
|
||||
|
||||
public boolean visit(SQLTimeLiteralExpr x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void endVisit(SQLTimeLiteralExpr x) {
|
||||
}
|
||||
|
||||
public boolean visit(SQLTimestampLiteralExpr x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void endVisit(SQLTimestampLiteralExpr x) {
|
||||
}
|
||||
|
||||
public boolean visit(SQLSelect x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class CursorTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT department_name, CURSOR(SELECT salary, commission_pct\n"
|
||||
+ "\tFROM employees e\n" + "\tWHERE e.department_id = d.department_id)\n"
|
||||
|
||||
@@ -23,7 +23,7 @@ public class OracleAnyTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class OracleEXTRACTTest extends TestCase {
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser
|
||||
.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class OracleFlashbackQueryTest extends TestCase {
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser
|
||||
.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class OracleFlashbackQueryTest2 extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class OracleFlashbackQueryTest3 extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT INTERVAL '123-2' YEAR(3) TO MONTH\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT INTERVAL '123' YEAR(3)\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT INTERVAL '5-3' YEAR TO MONTH + INTERVAL '20' MONTH\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT INTERVAL '6-11' YEAR TO MONTH\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT INTERVAL '4 5:12:10.222' DAY TO SECOND(3)\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT INTERVAL '30.12345' SECOND(2, 4)\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class OracleIntervalTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT (SYSTIMESTAMP - order_date) DAY(9) TO SECOND\n" + "FROM orders\n"
|
||||
+ "WHERE order_id = 2458;\n", text);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class OracleIsASetTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT customer_id, cust_address_ntab\n" + "FROM customers_demo\n"
|
||||
+ "WHERE cust_address_ntab IS A SET;\n", text);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class OracleIsEmptyTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.alibaba.druid.bvt.sql.oracle;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
|
||||
import com.alibaba.druid.sql.parser.SQLStatementParser;
|
||||
import com.alibaba.druid.sql.test.TestUtils;
|
||||
|
||||
public class OracleIsLiteralTest extends TestCase {
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
String sql = "SELECT FROM_TZ(TIMESTAMP '2007-11-20 08:00:00', '3:00') FROM DUAL;";
|
||||
|
||||
String expect = "SELECT FROM_TZ(TIMESTAMP '2007-11-20 08:00:00', '3:00')\n" + "FROM DUAL;\n";
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
System.out.println(text);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class OracleNumberLiteralTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT 7, 255, 0.5, 6.34, 0.025\n\t, 6.34F, 0.5D, -1.0D\nFROM DUAL;\n", text);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class OracleNumberLiteralTest extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals("SELECT BINARY_FLOAT_INFINITY\nFROM DUAL;\n", text);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class OracleSQLParserResourceTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(1, statementList.size());
|
||||
|
||||
String text = TestUtils.output(statementList);
|
||||
String text = TestUtils.outputOracle(statementList);
|
||||
System.out.println(text);
|
||||
Assert.assertEquals(expect, text.trim());
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class OracleTest2 extends TestCase {
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
|
||||
|
||||
String text = TestUtils.output(stmt);
|
||||
String text = TestUtils.outputOracle(stmt);
|
||||
|
||||
Assert.assertEquals(expect, text);
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
|
||||
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
public static String output(List<SQLStatement> stmtList) {
|
||||
public static String outputOracle(List<SQLStatement> stmtList) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
OracleOutputVisitor visitor = new OracleOutputVisitor(out);
|
||||
|
||||
@@ -20,7 +21,22 @@ public class TestUtils {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static String outputOracle(SQLStatement... stmtList) {
|
||||
return outputOracle(Arrays.asList(stmtList));
|
||||
}
|
||||
|
||||
public static String output(SQLStatement... stmtList) {
|
||||
return output(Arrays.asList(stmtList));
|
||||
}
|
||||
|
||||
public static String output(List<SQLStatement> stmtList) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
SQLASTOutputVisitor visitor = new SQLASTOutputVisitor(out);
|
||||
|
||||
for (SQLStatement stmt : stmtList) {
|
||||
stmt.accept(visitor);
|
||||
}
|
||||
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user