Skip to content

Commit 009002f

Browse files
author
chengyitian
committed
Merge remote-tracking branch 'origin/release130' into release130
2 parents d994c54 + a49aa81 commit 009002f

File tree

1 file changed

+100
-1
lines changed

1 file changed

+100
-1
lines changed

test/com/xxdb/data/BasicTableTest.java

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2506,5 +2506,104 @@ public void Test_BasicTable_replaceColumn_DECIMAL128_array() throws Exception {
25062506
assertEquals("DT_DECIMAL128_ARRAY",bt.getColumn(0).getDataType().toString());
25072507
assertEquals("[[],[9999999999.399999999999999999,-99999999999999.999999900000000000]]",bt.getColumn(0).getString());
25082508
}
2509-
2509+
@Test
2510+
public void Test_BasicTable_replaceColName_originalName_null() throws Exception {
2511+
DBConnection conn = new DBConnection(false, false, false);
2512+
conn.connect(HOST, PORT, "admin", "123456");
2513+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1);select * from t");
2514+
String re = null;
2515+
try{
2516+
bt.replaceColName(null,"int123");
2517+
}catch(Exception e){
2518+
re = e.getMessage();
2519+
}
2520+
assertEquals("The param originalColName 'null' does not exist in table.",re);
2521+
}
2522+
@Test
2523+
public void Test_BasicTable_replaceColName_originalName_null_1() throws Exception {
2524+
DBConnection conn = new DBConnection(false, false, false);
2525+
conn.connect(HOST, PORT, "admin", "123456");
2526+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1);select * from t");
2527+
String re = null;
2528+
try{
2529+
bt.replaceColName("","int123");
2530+
}catch(Exception e){
2531+
re = e.getMessage();
2532+
}
2533+
assertEquals("The param originalColName '' does not exist in table.",re);
2534+
}
2535+
@Test
2536+
public void Test_BasicTable_replaceColName_originalName_not_exist() throws Exception {
2537+
DBConnection conn = new DBConnection(false, false, false);
2538+
conn.connect(HOST, PORT, "admin", "123456");
2539+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1);select * from t");
2540+
String re = null;
2541+
try{
2542+
bt.replaceColName("int123","int123");
2543+
}catch(Exception e){
2544+
re = e.getMessage();
2545+
}
2546+
assertEquals("The param originalColName 'int123' does not exist in table.",re);
2547+
}
2548+
@Test
2549+
public void Test_BasicTable_replaceColName_newColName_null() throws Exception {
2550+
DBConnection conn = new DBConnection(false, false, false);
2551+
conn.connect(HOST, PORT, "admin", "123456");
2552+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1);select * from t");
2553+
String re = null;
2554+
try{
2555+
bt.replaceColName("int1","");
2556+
}catch(Exception e){
2557+
re = e.getMessage();
2558+
}
2559+
assertEquals("The param 'newColName' cannot be null or empty.",re);
2560+
}
2561+
@Test
2562+
public void Test_BasicTable_replaceColName_newColName_null_1() throws Exception {
2563+
DBConnection conn = new DBConnection(false, false, false);
2564+
conn.connect(HOST, PORT, "admin", "123456");
2565+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1);select * from t");
2566+
String re = null;
2567+
try{
2568+
bt.replaceColName("int1",null);
2569+
}catch(Exception e){
2570+
re = e.getMessage();
2571+
}
2572+
assertEquals("The param 'newColName' cannot be null or empty.",re);
2573+
}
2574+
@Test
2575+
public void Test_BasicTable_replaceColName_newColName_same() throws Exception {
2576+
DBConnection conn = new DBConnection(false, false, false);
2577+
conn.connect(HOST, PORT, "admin", "123456");
2578+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1);select * from t");
2579+
bt.replaceColName("int1","int1");
2580+
assertEquals("int1",bt.getColumnName(0));
2581+
}
2582+
@Test
2583+
public void Test_BasicTable_replaceColName_newColName_exist() throws Exception {
2584+
DBConnection conn = new DBConnection(false, false, false);
2585+
conn.connect(HOST, PORT, "admin", "123456");
2586+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1,`aa`dd`ff as string1);select * from t");
2587+
String re = null;
2588+
try{
2589+
bt.replaceColName("int1","string1");
2590+
}catch(Exception e){
2591+
re = e.getMessage();
2592+
}
2593+
assertEquals("The newColName 'string1' already exists in table. Column names cannot be duplicated.",re);
2594+
}
2595+
@Test
2596+
public void Test_BasicTable_replaceColName_newColName() throws Exception {
2597+
DBConnection conn = new DBConnection(false, false, false);
2598+
conn.connect(HOST, PORT, "admin", "123456");
2599+
BasicTable bt = (BasicTable) conn.run("t = table(1 2 3 as int1,`aa`dd`ff as string1);select * from t");
2600+
bt.replaceColName("int1","string123456789900");
2601+
assertEquals("string123456789900",bt.getColumnName(0));
2602+
bt.replaceColName("string123456789900","1212345678909876555555555");
2603+
assertEquals("1212345678909876555555555",bt.getColumnName(0));
2604+
bt.replaceColName("1212345678909876555555555","值收到回复核实对方回复收到回复哈代发");
2605+
assertEquals("值收到回复核实对方回复收到回复哈代发",bt.getColumnName(0));
2606+
bt.replaceColName("值收到回复核实对方回复收到回复哈代发","q!@#$%^&*()_+-={}[]:;'.,/`12345ddfsfSSSx测试");
2607+
assertEquals("q!@#$%^&*()_+-={}[]:;'.,/`12345ddfsfSSSx测试",bt.getColumnName(0));
2608+
}
25102609
}

0 commit comments

Comments
 (0)