mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql parser
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.alibaba.druid.test.wall;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import com.alibaba.druid.wall.Violation;
|
||||
import com.alibaba.druid.wall.WallCheckResult;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
|
||||
public class ResourceTest extends TestCase {
|
||||
|
||||
private String[] items;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
File file = new File("D:\\error_sql");
|
||||
FileInputStream is = new FileInputStream(file);
|
||||
String all = Utils.read(is);
|
||||
is.close();
|
||||
|
||||
items = all.split("\\|\\n\\|");
|
||||
}
|
||||
|
||||
public void test_xx() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
String sql = items[i];
|
||||
|
||||
WallCheckResult result = provider.check(sql);
|
||||
if (result.getViolations().size() > 0) {
|
||||
Violation violation = result.getViolations().get(0);
|
||||
System.err.println("error (" + i + ") : " + violation.getMessage());
|
||||
System.out.println(sql);
|
||||
System.out.println();
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("violaionCount : " + provider.getViolationCount());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user