|
14 | 14 | * @date 2016/7/19 |
15 | 15 | */ |
16 | 16 | public class RouterUtilTest { |
| 17 | + |
| 18 | + |
| 19 | + |
17 | 20 | @Test |
18 | 21 | public void testBatchInsert() { |
19 | 22 | String sql = "insert into hotnews(title,name) values('test1',\"name\"),('(test)',\"(test)\"),('\\\"',\"\\'\"),(\")\",\"\\\"\\')\");"; |
@@ -45,10 +48,34 @@ public void testRemoveSchemaSelect() { |
45 | 48 |
|
46 | 49 | @Test |
47 | 50 | public void testRemoveSchemaSelect2() { |
48 | | - String sql = "select id as 'aa' from testx.test where name='abcd testx.aa' and id=1 and testx=123"; |
| 51 | + String sql = "select id as 'aa' from testx.test where name='abcd testx.aa' and id=1 and testx=123"; |
49 | 52 |
|
50 | 53 | String afterAql= RouterUtil.removeSchema(sql,"testx"); |
51 | 54 | Assert.assertNotSame(sql.indexOf("testx."),afterAql.indexOf("testx.")); |
52 | 55 |
|
53 | 56 | } |
| 57 | + |
| 58 | + @Test |
| 59 | + public void testRemoveSchema2(){ |
| 60 | + String sql = "update testx.test set name='abcd \\' testx.aa' where id=1"; |
| 61 | + String sqltrue = "update test set name='abcd \\' testx.aa' where id=1"; |
| 62 | + String sqlnew = RouterUtil.removeSchema(sql, "testx"); |
| 63 | + Assert.assertEquals("处理错误:", sqltrue, sqlnew); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void testRemoveSchema3(){ |
| 68 | + String sql = "update testx.test set testx.name='abcd testx.aa' where testx.id=1"; |
| 69 | + String sqltrue = "update test set name='abcd testx.aa' where id=1"; |
| 70 | + String sqlnew = RouterUtil.removeSchema(sql, "testx"); |
| 71 | + Assert.assertEquals("处理错误:", sqltrue, sqlnew); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void testRemoveSchema4(){ |
| 76 | + String sql = "update testx.test set testx.name='abcd testx.aa' and testx.name2='abcd testx.aa' where testx.id=1"; |
| 77 | + String sqltrue = "update test set name='abcd testx.aa' and name2='abcd testx.aa' where id=1"; |
| 78 | + String sqlnew = RouterUtil.removeSchema(sql, "testx"); |
| 79 | + Assert.assertEquals("处理错误:", sqltrue, sqlnew); |
| 80 | + } |
54 | 81 | } |
0 commit comments