Skip to content

Commit 6044159

Browse files
committed
AJ-865:add test case about run special char
1 parent 2b03fe7 commit 6044159

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

test/com/xxdb/DBConnectionTest.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@
1717
import java.lang.reflect.*;
1818
import java.math.BigDecimal;
1919
import java.net.*;
20+
import java.nio.charset.StandardCharsets;
2021
import java.text.SimpleDateFormat;
2122
import java.time.*;
2223
import java.util.*;
2324
import java.util.Date;
2425
import java.util.concurrent.CountDownLatch;
26+
import java.util.concurrent.ExecutorService;
27+
import java.util.concurrent.Executors;
28+
import java.util.concurrent.TimeUnit;
29+
import java.util.concurrent.atomic.AtomicBoolean;
2530
import java.util.stream.DoubleStream;
2631
import java.util.stream.IntStream;
2732

@@ -31,6 +36,7 @@
3136
import static com.xxdb.data.Entity.DATA_TYPE.*;
3237
import static java.lang.Thread.sleep;
3338
import static org.junit.Assert.*;
39+
import static org.junit.Assert.assertEquals;
3440

3541
public class DBConnectionTest {
3642

@@ -5051,6 +5057,31 @@ public void test_DBConnection_upload_illegal_string() throws IOException {
50515057
assertEquals("", table2.getColumn(3).get(1).getString());
50525058
assertEquals("blob1AMZN", table2.getColumn(3).get(2).getString());
50535059
}
5060+
@Test
5061+
public void test_DBConnection_run_ASCII_char() throws IOException, InterruptedException {
5062+
DBConnection connection = new DBConnection();
5063+
connection.connect(HOST, PORT, "admin", "123456");
5064+
for (int i = 0; i <= 0x7F; i++) {
5065+
char c = (char) i;
5066+
System.out.printf("Unicode: \\u%04X | Dec: %3d | Char: %s%n",
5067+
i, i,
5068+
(i < 32 || i == 127) ? "[控制字符]" : c);
5069+
if((i == 9|| i == 10|| i == 32|| i == 33|| i == 36|| i == 37 || i == 38 || i == 42 || i == 43 || (i >= 45&&i <= 60)|| i == 62|| i == 64|| i == 92|| i == 94|| i == 96|| i == 101|| i == 124)){
5070+
Entity re = connection.run(String.valueOf(c));
5071+
System.out.println(re.getString());
5072+
}else{
5073+
String ex = null;
5074+
try{
5075+
connection.run(String.valueOf(c));
5076+
}catch(Exception e){
5077+
ex = e.getMessage();
5078+
System.out.println(ex);
5079+
}
5080+
assertNotNull(ex);
5081+
}
5082+
}
5083+
}
5084+
50545085
@Test
50555086
public void test_connection_enableSeqNo_true() throws Exception {
50565087
DBConnection connection = new DBConnection(false, false, false);
@@ -5072,10 +5103,10 @@ public void test_connection_enableSeqNo_true() throws Exception {
50725103
BasicTable res1 = (BasicTable) connection.run("select * from loadTable(\"dfs://tableUpsert_test\",\"pt\")");
50735104
BasicTable res2 = (BasicTable) connection.run("select * from loadTable(\"dfs://tableUpsert_test\",\"pt1\")");
50745105
assertEquals(30000, res1.rows());
5075-
assertEquals(30000, res1.rows());
5106+
assertEquals(30000, res2.rows());
50765107
connection.close();
50775108
}
5078-
5109+
50795110
@Test
50805111
public void test_connection_enableSeqNo_false() throws Exception {
50815112
DBConnection connection = new DBConnection(false, false, false);
@@ -5097,7 +5128,7 @@ public void test_connection_enableSeqNo_false() throws Exception {
50975128
BasicTable res1 = (BasicTable) connection.run("select * from loadTable(\"dfs://tableUpsert_test\",\"pt\")");
50985129
BasicTable res2 = (BasicTable) connection.run("select * from loadTable(\"dfs://tableUpsert_test\",\"pt1\")");
50995130
assertEquals(30000, res1.rows());
5100-
assertEquals(30000, res1.rows());
5131+
assertEquals(30000, res2.rows());
51015132
connection.close();
51025133
}
51035134
@Test

0 commit comments

Comments
 (0)