Skip to content

Commit 91c9e54

Browse files
committed
[Test] modify test cases after observer changed
1 parent ac04d6a commit 91c9e54

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/test/java/com/alipay/oceanbase/hbase/OHTableAdminInterfaceTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,43 +1067,43 @@ public void testHTableDDLDefense() throws Exception {
10671067
String sql = "alter table testHTableDefense$cf1 ADD CONSTRAINT cons1 CHECK(T < 0)";
10681068
System.out.println("execute sql: " + sql);
10691069
conn.createStatement().execute(sql);
1070+
fail();
10701071
} catch (SQLException e) {
1071-
e.printStackTrace();
10721072
Assert.assertEquals(1235, e.getErrorCode());
1073-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1073+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
10741074
}
10751075

10761076
// 5. alter table add index
10771077
try {
10781078
String sql = "alter table testHTableDefense$cf1 ADD INDEX idx_1(T)";
10791079
System.out.println("execute sql: " + sql);
10801080
conn.createStatement().execute(sql);
1081+
fail();
10811082
} catch (SQLException e) {
1082-
e.printStackTrace();
10831083
Assert.assertEquals(1235, e.getErrorCode());
1084-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1084+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
10851085
}
10861086

10871087
// 5. alter table add fk
10881088
try {
10891089
String sql = "alter table testHTableDefense$cf1 MODIFY COLUMN V LONGTEXT";
10901090
System.out.println("execute sql: " + sql);
10911091
conn.createStatement().execute(sql);
1092+
fail();
10921093
} catch (SQLException e) {
1093-
e.printStackTrace();
10941094
Assert.assertEquals(1235, e.getErrorCode());
1095-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1095+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
10961096
}
10971097

10981098
// 6. alter table modify column to lob
10991099
try {
11001100
String sql = "alter table testHTableDefense$cf1 ADD CONSTRAINT hbase_fk_1 FOREIGN KEY(K) REFERENCES testHTableDefense$cf2(K)";
11011101
System.out.println("execute sql: " + sql);
11021102
conn.createStatement().execute(sql);
1103+
fail();
11031104
} catch (SQLException e) {
1104-
e.printStackTrace();
11051105
Assert.assertEquals(1235, e.getErrorCode());
1106-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1106+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
11071107
}
11081108

11091109
// 7. create trigger
@@ -1113,67 +1113,67 @@ public void testHTableDDLDefense() throws Exception {
11131113
" BEGIN END";
11141114
System.out.println("execute sql: " + sql);
11151115
conn.createStatement().execute(sql);
1116+
fail();
11161117
} catch (SQLException e) {
1117-
e.printStackTrace();
11181118
Assert.assertEquals(1235, e.getErrorCode());
1119-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1119+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
11201120
}
11211121

11221122
// 8. create view
11231123
try {
11241124
String sql = " CREATE VIEW hbase_view_1 as select * from testHTableDefense$cf1";
11251125
System.out.println("execute sql: " + sql);
11261126
conn.createStatement().execute(sql);
1127+
fail();
11271128
} catch (SQLException e) {
1128-
e.printStackTrace();
11291129
Assert.assertEquals(1235, e.getErrorCode());
1130-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1130+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
11311131
}
11321132

11331133
// 9. alter view
11341134
try {
11351135
String sql = "ALTER VIEW hbase_view_1 as select * from testHTableDefense$cf1";
11361136
System.out.println("execute sql: " + sql);
11371137
conn.createStatement().execute(sql);
1138+
fail();
11381139
} catch (SQLException e) {
1139-
e.printStackTrace();
11401140
Assert.assertEquals(1235, e.getErrorCode());
1141-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1141+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
11421142
}
11431143

11441144
// 10. create index
11451145
try {
11461146
String sql = " CREATE INDEX testHTableDefense$cf1_idx_T on testHTableDefense$cf1(T)";
11471147
System.out.println("execute sql: " + sql);
11481148
conn.createStatement().execute(sql);
1149+
fail();
11491150
} catch (SQLException e) {
1150-
e.printStackTrace();
11511151
Assert.assertEquals(1235, e.getErrorCode());
1152-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1152+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
11531153
}
11541154

11551155

11561156
// 11. explicit create table and specify created_by:admin, should be prohibited
11571157
try {
1158-
String sql = "CREATE TABLE testHTableDefense$cf3(a int primary key) kv_attributes ='{\"Hbase\": {\"CREATED_BY\": \"ADMIN\"}}'";
1158+
String sql = "CREATE TABLE testHTableDefense$cf3(a int primary key) kv_attributes ='{\"Hbase\": {\"CreatedBy\": \"Admin\"}}'";
11591159
System.out.println("execute sql: " + sql);
11601160
conn.createStatement().execute(sql);
1161+
fail();
11611162
} catch (SQLException e) {
1162-
e.printStackTrace();
11631163
Assert.assertEquals(1235, e.getErrorCode());
1164-
Assert.assertEquals("user ddl with created_by attribute not supported", e.getMessage());
1164+
Assert.assertEquals("table kv_attribute with '\"CreateBy\": \"Admin\"' not supported", e.getMessage());
11651165
}
11661166

11671167
// 12. alter table to created_by:admin, should be prohibited
11681168
try {
11691169
String sql1 = "CREATE TABLE testHTableDefense$cf3(a int primary key)";
11701170
System.out.println("execute sql: " + sql1);
11711171
conn.createStatement().execute(sql1);
1172-
String sql2 = "alter table testHTableDefense$cf3 kv_attributes ='{\"Hbase\": {\"CREATED_BY\": \"ADMIN\"}}'";
1172+
String sql2 = "alter table testHTableDefense$cf3 kv_attributes ='{\"Hbase\": {\"CreatedBy\": \"Admin\"}}'";
11731173
System.out.println("execute sql: " + sql2);
11741174
conn.createStatement().execute(sql2);
1175+
fail();
11751176
} catch (SQLException e) {
1176-
e.printStackTrace();
11771177
Assert.assertEquals(1235, e.getErrorCode());
11781178
Assert.assertEquals("alter table kv attributes to created by admin not supported", e.getMessage());
11791179
// clean table
@@ -1191,8 +1191,8 @@ public void testHTableDDLDefense() throws Exception {
11911191
System.out.println("execute sql: " + sql2);
11921192
conn.createStatement().execute(sql2);
11931193
admin.disableTable(TableName.valueOf("testHTableDefense2"));
1194+
fail();
11941195
} catch (Exception e) {
1195-
e.printStackTrace();
11961196
Assert.assertEquals(-4007, ((ObTableException)e.getCause()).getErrorCode());
11971197

11981198
}
@@ -1206,8 +1206,8 @@ public void testHTableDDLDefense() throws Exception {
12061206
System.out.println("execute sql: " + sql2);
12071207
conn.createStatement().execute(sql2);
12081208
admin.deleteTable(TableName.valueOf("testHTableDefense2"));
1209+
fail();
12091210
} catch (Exception e) {
1210-
e.printStackTrace();
12111211
Assert.assertEquals(-4007, ((ObTableException)e.getCause()).getErrorCode());
12121212
}
12131213

0 commit comments

Comments
 (0)