mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
支持DoPrivileged
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallUtils;
|
||||
|
||||
public class DoPrivilegedTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
Assert.assertFalse(WallUtils.isValidateMySql("select @@version_compile_os"));
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
WallProvider.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql("select @@version_compile_os"));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.alibaba.druid.sql;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
|
||||
|
||||
public class SQLExprParserTest extends TestCase {
|
||||
public void test_binary() throws Exception {
|
||||
SQLExprParser exprParser = new SQLExprParser("AGE > 5");
|
||||
SQLBinaryOpExpr binaryOpExpr = (SQLBinaryOpExpr) exprParser.expr();
|
||||
|
||||
Assert.assertEquals(SQLBinaryOperator.GreaterThan, binaryOpExpr.getOperator());
|
||||
|
||||
SQLIdentifierExpr left = (SQLIdentifierExpr) binaryOpExpr.getLeft();
|
||||
SQLIntegerExpr right = (SQLIntegerExpr) binaryOpExpr.getRight();
|
||||
|
||||
Assert.assertEquals("AGE", left.getName());
|
||||
Assert.assertEquals(5, right.getNumber().intValue());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user