Skip to content

Commit

Permalink
refactor testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Oct 3, 2021
1 parent f19f3aa commit 3f1ef84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.alibaba.druid.bvt.sql.mysql.issues;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor;
import com.alibaba.druid.sql.parser.SQLParserUtils;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.stat.TableStat;
import org.junit.Test;

Expand All @@ -12,12 +17,14 @@
import static org.junit.Assert.assertFalse;

public class Issue4444 {
protected final DbType dbType = DbType.mysql;

@Test
public void test_idle2() throws Exception {
String sql = "create role 'role1'";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
SQLStatement statement = parser.parseStatement();
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(dbType);
statement.accept(visitor);
assertEquals("CREATE ROLE 'role1'", statement.toString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.alibaba.druid.bvt.sql.mysql.issues;

import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor;
import com.alibaba.druid.sql.parser.SQLParserUtils;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.stat.TableStat;
import org.junit.Test;

Expand All @@ -12,17 +17,20 @@
import static org.junit.Assert.assertFalse;

public class Issue4454 {
protected final DbType dbType = DbType.mysql;

@Test
public void test_idle2() throws Exception {
String sql = "CREATE TABLE `test_trigger` (\n" +
" `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'trigger id',\n" +
" `test` int(11) signed NOT NULL DEFAULT '0' COMMENT 'trigger test',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement statement = parser.parseStatement();
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
statement.accept(visitor);
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType);
SQLStatement stmt = parser.parseStatement();
SchemaStatVisitor visitor = SQLUtils.createSchemaStatVisitor(dbType);

stmt.accept(visitor);
Map<TableStat.Name, TableStat> tableMap = visitor.getTables();
assertFalse(tableMap.isEmpty());
}
Expand Down

0 comments on commit 3f1ef84

Please sign in to comment.