use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.
the class TenantSelectTest3 method testMySql.
public void testMySql() throws Exception {
WallConfig config = new WallConfig();
WallConfig config_callback = new WallConfig();
config.setTenantTablePattern("*");
config.setTenantColumn("tenant");
config_callback.setTenantCallBack(new TenantTestCallBack());
WallProvider.setTenantValue(123);
MySqlWallProvider provider = new MySqlWallProvider(config);
WallCheckResult checkResult = provider.check(sql);
Assert.assertEquals(0, checkResult.getViolations().size());
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
Assert.assertEquals(expect_sql, resultSql);
}
use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.
the class TenantSelectTest3 method testMySql2.
public void testMySql2() throws Exception {
WallConfig config = new WallConfig();
WallConfig config_callback = new WallConfig();
config.setTenantTablePattern("*");
config.setTenantColumn("tenant");
config_callback.setTenantCallBack(new TenantTestCallBack());
MySqlWallProvider provider = new MySqlWallProvider(config_callback);
WallCheckResult checkResult = provider.check(sql);
Assert.assertEquals(0, checkResult.getViolations().size());
String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
Assert.assertEquals(expect_sql, resultSql);
}
use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.
the class WallSelectLimitTest_2 method testOracle.
public void testOracle() throws Exception {
String sql = PagerUtils.limit("select * from t", JdbcConstants.ORACLE, 0, 10);
WallProvider provider = new OracleWallProvider(config);
WallCheckResult checkResult = provider.check(sql);
String resultSql = checkResult.getSql();
System.out.println(resultSql);
assertEquals("SELECT *\n" + "FROM t\n" + "WHERE ROWNUM <= 10", resultSql);
sql = PagerUtils.limit("select * from t", JdbcConstants.OCEANBASE_ORACLE, 0, 10);
provider = new OracleWallProvider(config);
checkResult = provider.check(sql);
resultSql = checkResult.getSql();
System.out.println(resultSql);
assertEquals("SELECT *\n" + "FROM t\n" + "WHERE ROWNUM <= 10", resultSql);
}
use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.
the class WallSelectLimitTest_2 method testMySql.
public void testMySql() throws Exception {
String sql = "select * from t limit 10";
WallProvider provider = new MySqlWallProvider(config);
WallCheckResult checkResult = provider.check(sql);
String resultSql = checkResult.getSql();
System.out.println(resultSql);
assertEquals("SELECT *\n" + "FROM t\n" + "LIMIT 10", resultSql);
}
use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.
the class WallSelectLimitTest method testOracle.
public void testOracle() throws Exception {
WallProvider provider = new OracleWallProvider(config);
WallCheckResult checkResult = provider.check(sql);
String resultSql = checkResult.getSql();
System.out.println(resultSql);
assertEquals("SELECT *\n" + "FROM t\n" + "WHERE ROWNUM <= 1000", resultSql);
}
Aggregations