增强测试

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@964 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-10-14 08:04:40 +00:00
parent 7dc402e29d
commit 5fc5e94e92
@@ -0,0 +1,32 @@
package com.alibaba.druid.bvt.sql.oracle;
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
import com.alibaba.druid.sql.test.TestUtils;
import junit.framework.Assert;
import junit.framework.TestCase;
public class OracleFlashbackQueryTest3 extends TestCase {
public void test_isEmpty() throws Exception {
String sql = "SELECT DECODE(GROUPING(department_name), 1, 'All Departments', department_name) AS department,"
+ "DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job, COUNT(*) AS \"Total Empl\", AVG(salary) * 12 AS \"Average Sal\" "
+ "FROM employees e, departments d\n" + "WHERE d.department_id = e.department_id\n"
+ "GROUP BY ROLLUP (department_name, job_id);\n";
String expect = "SELECT DECODE(GROUPING(department_name), 1, 'All Departments', department_name) AS department, "
+ "DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job, COUNT(*) AS \"Total Empl\", AVG(salary) * 12 AS \"Average Sal\"\n"
+ "FROM employees e, departments d\n" + "WHERE d.department_id = e.department_id\n"
+ "GROUP BY ROLLUP(department_name, job_id);\n";
OracleStatementParser parser = new OracleStatementParser(sql);
SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);
String text = TestUtils.output(stmt);
Assert.assertEquals(expect, text);
System.out.println(text);
}
}