This commit is contained in:
温少
2012-03-22 19:18:04 +08:00
parent d3a2ac1c68
commit 663474384d
11 changed files with 108 additions and 60 deletions
@@ -9,8 +9,6 @@ import com.alibaba.druid.wall.WallUtils;
public class MustParameterizedTest3 extends TestCase {
private String sql = "select * from t where id not in (3, 5)";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
@@ -18,11 +16,10 @@ public class MustParameterizedTest3 extends TestCase {
}
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
Assert.assertFalse(WallUtils.isValidateMySql("select * from t where id = (3 + 5 - 2 - 1)", config));
Assert.assertFalse(WallUtils.isValidateMySql("select * from t where id != id + 3", config));
Assert.assertTrue(WallUtils.isValidateMySql("select * from t where id = ? ORDER BY 1", config));
Assert.assertTrue(WallUtils.isValidateMySql("select 1, 2, 3 from t where id = ?", config));
}
public void testORACLE() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
}
}
@@ -0,0 +1,28 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.wall.WallConfig;
import com.alibaba.druid.wall.WallUtils;
public class MustParameterizedTest4 extends TestCase {
private String sql = "select * from t where id not in (3, 5)";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setMustParameterized(true);
}
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
}
}