Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8175d9a2
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8175d9a2
编写于
12月 01, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change test cases for TS-601
上级
e4dc7cac
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
92 addition
and
135 deletion
+92
-135
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
...test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
+22
-42
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
...ava/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
+2
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
...test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
+10
-15
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
...c/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
+22
-30
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
...va/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
+11
-16
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
.../test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
+21
-27
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
...ctor/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
+4
-1
未找到文件。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
浏览文件 @
8175d9a2
...
...
@@ -57,53 +57,33 @@ public class AuthenticationTest {
@Ignore
@Test
public
void
test
()
{
public
void
test
()
throws
SQLException
{
// change password
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass '"
+
password
+
"'"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user="
+
user
+
"&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass '"
+
password
+
"'"
);
stmt
.
close
();
conn
.
close
();
// use new to login and execute query
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password="
+
password
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"show databases"
);
ResultSet
rs
=
stmt
.
getResultSet
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
":"
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user="
+
user
+
"&password="
+
password
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"show databases"
);
ResultSet
rs
=
stmt
.
getResultSet
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
":"
+
rs
.
getString
(
i
)
+
"\t"
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
();
}
// change password back
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password="
+
password
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass 'taosdata'"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Before
public
void
before
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
// change password back
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user="
+
user
+
"&password="
+
password
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass 'taosdata'"
);
stmt
.
close
();
conn
.
close
();
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
浏览文件 @
8175d9a2
...
...
@@ -18,9 +18,8 @@ public class InsertDbwithoutUseDbTest {
private
static
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
@Test
public
void
case001
()
throws
ClassNotFoundException
,
SQLException
{
public
void
case001
()
throws
SQLException
{
// prepare schema
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
...
...
@@ -51,9 +50,8 @@ public class InsertDbwithoutUseDbTest {
}
@Test
public
void
case002
()
throws
ClassNotFoundException
,
SQLException
{
public
void
case002
()
throws
SQLException
{
// prepare the schema
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
final
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/inWithoutDb?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
浏览文件 @
8175d9a2
...
...
@@ -374,22 +374,17 @@ public class RestfulConnectionTest {
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/log?user=root&password=taosdata"
,
properties
);
// create test database for test cases
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"create database if not exists test"
);
}
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
public
static
void
beforeClass
()
throws
SQLException
{
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
,
properties
);
// create test database for test cases
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"create database if not exists test"
);
}
}
@AfterClass
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
浏览文件 @
8175d9a2
...
...
@@ -9,12 +9,13 @@ import java.util.Random;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
RestfulJDBCTest
{
private
static
final
String
host
=
"127.0.0.1"
;
private
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
Connection
connection
;
// private static final String host = "127.0.0.1";
private
static
final
String
host
=
"master"
;
private
static
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
static
Connection
connection
;
@Test
public
void
testCase001
()
{
public
void
testCase001
()
throws
SQLException
{
// given
String
sql
=
"drop database if exists restful_test"
;
// when
...
...
@@ -38,7 +39,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase002
()
{
public
void
testCase002
()
throws
SQLException
{
// given
String
sql
=
"create table weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"
;
// when
...
...
@@ -48,7 +49,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase004
()
{
public
void
testCase004
()
throws
SQLException
{
for
(
int
i
=
1
;
i
<=
100
;
i
++)
{
// given
String
sql
=
"create table t"
+
i
+
" using weather tags('beijing', '"
+
i
+
"')"
;
...
...
@@ -60,7 +61,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase005
()
{
public
void
testCase005
()
throws
SQLException
{
int
rows
=
0
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
j
=
1
;
j
<=
100
;
j
++)
{
...
...
@@ -99,7 +100,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase007
()
{
public
void
testCase007
()
throws
SQLException
{
// given
String
sql
=
"drop database restful_test"
;
...
...
@@ -110,50 +111,41 @@ public class RestfulJDBCTest {
Assert
.
assertFalse
(
execute
);
}
private
int
executeUpdate
(
Connection
connection
,
String
sql
)
{
private
int
executeUpdate
(
Connection
connection
,
String
sql
)
throws
SQLException
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
return
stmt
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
0
;
}
private
boolean
execute
(
Connection
connection
,
String
sql
)
{
private
boolean
execute
(
Connection
connection
,
String
sql
)
throws
SQLException
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
return
stmt
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
private
ResultSet
executeQuery
(
Connection
connection
,
String
sql
)
{
private
ResultSet
executeQuery
(
Connection
connection
,
String
sql
)
throws
SQLException
{
try
(
Statement
statement
=
connection
.
createStatement
())
{
return
statement
.
executeQuery
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@Before
public
void
before
()
{
@Before
Class
public
static
void
beforeClass
()
{
try
{
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/
restful_test
?user=root&password=taosdata"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@After
public
void
after
()
{
try
{
if
(
connection
!=
null
)
connection
.
close
(
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrac
e
();
@After
Class
public
static
void
afterClass
()
throws
SQLException
{
if
(
connection
!=
null
)
{
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
close
();
connection
.
clos
e
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
浏览文件 @
8175d9a2
...
...
@@ -186,22 +186,17 @@ public class RestfulResultSetMetaDataTest {
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
meta
=
rs
.
getMetaData
();
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
public
static
void
beforeClass
()
throws
SQLException
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
meta
=
rs
.
getMetaData
();
}
@AfterClass
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
浏览文件 @
8175d9a2
...
...
@@ -17,7 +17,8 @@ import java.text.SimpleDateFormat;
public
class
RestfulResultSetTest
{
private
static
final
String
host
=
"127.0.0.1"
;
// private static final String host = "127.0.0.1";
private
static
final
String
host
=
"master"
;
private
static
Connection
conn
;
private
static
Statement
stmt
;
private
static
ResultSet
rs
;
...
...
@@ -658,36 +659,29 @@ public class RestfulResultSetTest {
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
public
static
void
beforeClass
()
throws
SQLException
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
}
@AfterClass
public
static
void
afterClass
()
{
try
{
if
(
rs
!=
null
)
rs
.
close
();
if
(
stmt
!=
null
)
stmt
.
close
();
if
(
conn
!=
null
)
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
public
static
void
afterClass
()
throws
SQLException
{
if
(
rs
!=
null
)
rs
.
close
();
if
(
stmt
!=
null
){
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
close
();
}
if
(
conn
!=
null
)
conn
.
close
();
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
浏览文件 @
8175d9a2
...
...
@@ -581,11 +581,14 @@ public class SQLTest {
@BeforeClass
public
static
void
before
()
throws
SQLException
{
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/
restful_test
?user=root&password=taosdata"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
}
@AfterClass
public
static
void
after
()
throws
SQLException
{
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
close
();
connection
.
close
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录