mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve wall filter
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* SQLServerWallTest
|
||||
*
|
||||
* @author RaymondXiu
|
||||
* @version 1.0, 2012-3-18
|
||||
* @see
|
||||
*/
|
||||
public class MySqlWallTest_var_autoincrement extends TestCase {
|
||||
|
||||
|
||||
public void test_true() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(//
|
||||
"/* mysql-connector-java-5.? ( Revision: bzr.revision-id ) */SELECT @@session.auto_increment_increment", config)); //
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class WallDropTest1 extends TestCase {
|
||||
private WallConfig config = new WallConfig();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
config.setNoneBaseStatementAllow(true);
|
||||
config.setDropTableAllow(true);
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
|
||||
public class WallStatTest_alter_table extends TestCase {
|
||||
public void testMySql() throws Exception {
|
||||
String sql = "alter table t add column fname varchar(50)";
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
provider.getConfig().setAlterTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getAlterCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
String sql = "alter table t add (fname varchar(50))";
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
provider.getConfig().setAlterTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getAlterCount());
|
||||
}
|
||||
|
||||
// public void testPG() throws Exception {
|
||||
// WallProvider provider = new PGWallProvider();
|
||||
// provider.getConfig().setAlterTableAllow(true);
|
||||
//
|
||||
// Assert.assertTrue(provider.checkValid(sql));
|
||||
// WallTableStat tableStat = provider.getTableStat("t");
|
||||
// Assert.assertEquals(1, tableStat.getAlterCount());
|
||||
// }
|
||||
//
|
||||
// public void testSQLServer() throws Exception {
|
||||
// WallProvider provider = new SQLServerWallProvider();
|
||||
// provider.getConfig().setAlterTableAllow(true);
|
||||
//
|
||||
// Assert.assertTrue(provider.checkValid(sql));
|
||||
// WallTableStat tableStat = provider.getTableStat("t");
|
||||
// Assert.assertEquals(1, tableStat.getAlterCount());
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
|
||||
public class WallStatTest_blacklist extends TestCase {
|
||||
|
||||
private String sql = "select * from t where id = ? and 1 = 1";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
Assert.assertFalse(provider.checkValid(sql));
|
||||
}
|
||||
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(10, tableStat.getSelectCount());
|
||||
Assert.assertEquals(0, provider.getWhiteListHitCount());
|
||||
Assert.assertEquals(9, provider.getBlackListHitCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
|
||||
public class WallStatTest_create_table extends TestCase {
|
||||
private String sql = "create table t (fid int, fname varchar(50))";
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
provider.getConfig().setCreateTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getCreateCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
provider.getConfig().setCreateTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getCreateCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
provider.getConfig().setCreateTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getCreateCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
provider.getConfig().setCreateTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getCreateCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
public class WallStatTest_delete extends TestCase {
|
||||
|
||||
private String sql = "delete from t where fid = ?";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDeleteCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDeleteCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDeleteCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDeleteCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
public class WallStatTest_drop_table extends TestCase {
|
||||
|
||||
private String sql = "drop table t";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
provider.getConfig().setDropTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDropCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
provider.getConfig().setDropTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDropCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
provider.getConfig().setDropTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDropCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
provider.getConfig().setDropTableAllow(true);
|
||||
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getDropCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
|
||||
public class WallStatTest_insert extends TestCase {
|
||||
private String sql = "insert into t (fid, fname) values (?, ?)";
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getInsertCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getInsertCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getInsertCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getInsertCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
public class WallStatTest_select extends TestCase {
|
||||
|
||||
private String sql = "select * from t where id = ?";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
public class WallStatTest_select_1 extends TestCase {
|
||||
|
||||
private String sql = "SELECT b.* FROM lhwbbs_posts_reply a LEFT JOIN lhwbbs_posts b ON a.pid=b.pid WHERE a.rpid=? AND b.disabled=? ORDER BY a.pid DESC";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts_reply");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts_reply");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts_reply");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts_reply");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
public class WallStatTest_select_into extends TestCase {
|
||||
|
||||
private String sql = "select * into x from t where id = ?";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
Assert.assertEquals(0, tableStat.getSelectIntoCount());
|
||||
}
|
||||
{
|
||||
WallTableStat tableStat = provider.getTableStat("x");
|
||||
Assert.assertEquals(0, tableStat.getSelectCount());
|
||||
Assert.assertEquals(1, tableStat.getSelectIntoCount());
|
||||
}
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getSelectCount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.alibaba.druid.bvt.filter.wall;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.wall.WallContext;
|
||||
import com.alibaba.druid.wall.WallProvider;
|
||||
import com.alibaba.druid.wall.WallTableStat;
|
||||
import com.alibaba.druid.wall.spi.MySqlWallProvider;
|
||||
import com.alibaba.druid.wall.spi.OracleWallProvider;
|
||||
import com.alibaba.druid.wall.spi.PGWallProvider;
|
||||
import com.alibaba.druid.wall.spi.SQLServerWallProvider;
|
||||
|
||||
|
||||
public class WallStatTest_update extends TestCase {
|
||||
private String sql = "update t set fname = ? where fid = ?";
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
WallContext.clearContext();
|
||||
}
|
||||
|
||||
public void testMySql() throws Exception {
|
||||
WallProvider provider = new MySqlWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getUpdateCount());
|
||||
}
|
||||
|
||||
public void testOracle() throws Exception {
|
||||
WallProvider provider = new OracleWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getUpdateCount());
|
||||
}
|
||||
|
||||
public void testPG() throws Exception {
|
||||
WallProvider provider = new PGWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getUpdateCount());
|
||||
}
|
||||
|
||||
public void testSQLServer() throws Exception {
|
||||
WallProvider provider = new SQLServerWallProvider();
|
||||
Assert.assertTrue(provider.checkValid(sql));
|
||||
WallTableStat tableStat = provider.getTableStat("t");
|
||||
Assert.assertEquals(1, tableStat.getUpdateCount());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user