Package com.alibaba.druid.wall

Examples of com.alibaba.druid.wall.WallCheckResult


        String insert_sql = "INSERT INTO orders (ID, NAME) VALUES (1, \"KIKI\")";
        String expect_sql = "INSERT INTO orders (ID, NAME, tenant)" + //
                            "\nVALUES (1, 'KIKI', 123)";
        {
            MySqlWallProvider provider = new MySqlWallProvider(config_callback);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }

        {
            WallProvider.setTenantValue(123);
            MySqlWallProvider provider = new MySqlWallProvider(config);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }

    }
View Full Code Here


                            "\nVALUES (1, 'KIKI', 123)," + //
                            "\n\t(1, 'CICI', 123)";

        {
            MySqlWallProvider provider = new MySqlWallProvider(config_callback);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }

        {
            WallProvider.setTenantValue(123);
            MySqlWallProvider provider = new MySqlWallProvider(config);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }

    }
View Full Code Here

                            "\nFROM temp" + //
                            "\nWHERE age = 18";

        {
            MySqlWallProvider provider = new MySqlWallProvider(config_callback);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }

        {
            WallProvider.setTenantValue(123);
            MySqlWallProvider provider = new MySqlWallProvider(config);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }
    }
View Full Code Here

                            "\nSELECT ID, NAME, 123" + //
                            "\nFROM temp3";

        {
            MySqlWallProvider provider = new MySqlWallProvider(config_callback);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }

        {
            WallProvider.setTenantValue(123);
            MySqlWallProvider provider = new MySqlWallProvider(config);
            WallCheckResult checkResult = provider.check(insert_sql);
            Assert.assertEquals(0, checkResult.getViolations().size());

            String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
            Assert.assertEquals(expect_sql, resultSql);
        }
    }
View Full Code Here

    }

    public void testMySql() throws Exception {
        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("DELETE FROM orders" + //
                            "\nWHERE FID = ?", resultSql);
    }
View Full Code Here

    }

    public void testMySql() throws Exception {
        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);
    }
View Full Code Here

        Assert.assertEquals(expect_sql, resultSql);
    }

    public void testMySql2() throws Exception {
        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);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.wall.WallCheckResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.