Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
68c14bb6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
68c14bb6
编写于
12月 15, 2021
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/taosdata/TDengine
into develop
上级
d69cfa45
25da4240
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
443 addition
and
68 deletion
+443
-68
src/connector/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java
...tor/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java
+119
-68
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java
...src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java
+9
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogClass.java
.../test/java/com/taosdata/jdbc/annotation/CatalogClass.java
+86
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogListener.java
...st/java/com/taosdata/jdbc/annotation/CatalogListener.java
+104
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogMethod.java
...test/java/com/taosdata/jdbc/annotation/CatalogMethod.java
+52
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogRunner.java
...test/java/com/taosdata/jdbc/annotation/CatalogRunner.java
+36
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/Description.java
...c/test/java/com/taosdata/jdbc/annotation/Description.java
+19
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/TestTarget.java
...rc/test/java/com/taosdata/jdbc/annotation/TestTarget.java
+18
-0
未找到文件。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java
浏览文件 @
68c14bb6
此差异已折叠。
点击以展开。
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SchemalessInsertTest.java
浏览文件 @
68c14bb6
...
...
@@ -2,17 +2,23 @@ package com.taosdata.jdbc;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.taosdata.jdbc.annotation.CatalogRunner
;
import
com.taosdata.jdbc.annotation.Description
;
import
com.taosdata.jdbc.annotation.TestTarget
;
import
com.taosdata.jdbc.enums.SchemalessProtocolType
;
import
com.taosdata.jdbc.enums.SchemalessTimestampType
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.List
;
@RunWith
(
CatalogRunner
.
class
)
@TestTarget
(
alias
=
"Schemaless"
,
author
=
"huolibo"
,
version
=
"2.0.36"
)
public
class
SchemalessInsertTest
{
private
final
String
dbname
=
"test_schemaless_insert"
;
private
Connection
conn
;
...
...
@@ -23,6 +29,7 @@ public class SchemalessInsertTest {
* @throws SQLException execute error
*/
@Test
@Description
(
"line insert"
)
public
void
schemalessInsert
()
throws
SQLException
{
// given
String
[]
lines
=
new
String
[]{
...
...
@@ -53,6 +60,7 @@ public class SchemalessInsertTest {
* @throws SQLException execute error
*/
@Test
@Description
(
"telnet insert"
)
public
void
telnetInsert
()
throws
SQLException
{
// given
String
[]
lines
=
new
String
[]{
...
...
@@ -87,6 +95,7 @@ public class SchemalessInsertTest {
* @throws SQLException execute error
*/
@Test
@Description
(
"json insert"
)
public
void
jsonInsert
()
throws
SQLException
{
// given
String
json
=
"[\n"
+
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogClass.java
0 → 100644
浏览文件 @
68c14bb6
package
com.taosdata.jdbc.annotation
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Test class
*/
public
class
CatalogClass
{
private
String
name
;
private
String
alias
;
private
String
author
;
private
String
version
;
private
List
<
CatalogMethod
>
methods
=
new
ArrayList
<>();
private
int
total
;
private
int
failure
;
public
void
setTotal
(
int
total
)
{
this
.
total
=
total
;
}
public
void
setFailure
(
int
failure
)
{
this
.
failure
=
failure
;
}
public
void
setAuthor
(
String
author
)
{
this
.
author
=
author
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setAlias
(
String
alias
)
{
this
.
alias
=
alias
;
}
public
void
setMethods
(
List
<
CatalogMethod
>
methods
)
{
this
.
methods
=
methods
;
}
@Override
public
String
toString
()
{
if
(
methods
.
size
()
<
1
)
return
null
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"ClassName: "
).
append
(
name
);
String
msg
=
trim
(
alias
);
if
(
null
!=
msg
)
sb
.
append
(
"\tAlias:"
).
append
(
alias
);
sb
.
append
(
"\tTotal:"
).
append
(
total
)
.
append
(
"\tFailure:"
).
append
(
failure
).
append
(
"\n"
);
for
(
CatalogMethod
method
:
methods
)
{
sb
.
append
(
"\t"
).
append
(
method
.
getName
());
sb
.
append
(
"\t"
).
append
(
method
.
isSuccess
());
sb
.
append
(
"\t"
).
append
(
method
.
getMessage
());
String
mAuthor
=
trim
(
method
.
getAuthor
());
if
(
null
==
mAuthor
)
{
sb
.
append
(
"\t"
).
append
(
author
);
}
else
{
sb
.
append
(
"\t"
).
append
(
method
.
getAuthor
());
}
String
mVersion
=
trim
(
method
.
getVersion
());
if
(
null
==
mVersion
)
{
sb
.
append
(
"\t"
).
append
(
version
);
}
else
{
sb
.
append
(
"\t"
).
append
(
mVersion
);
}
sb
.
append
(
"\n"
);
}
return
sb
.
toString
();
}
private
String
trim
(
String
s
)
{
if
(
null
==
s
||
s
.
trim
().
equals
(
""
))
{
return
null
;
}
else
{
return
s
.
trim
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogListener.java
0 → 100644
浏览文件 @
68c14bb6
package
com.taosdata.jdbc.annotation
;
import
org.junit.runner.Description
;
import
org.junit.runner.Result
;
import
org.junit.runner.notification.Failure
;
import
org.junit.runner.notification.RunListener
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.util.LinkedList
;
public
class
CatalogListener
extends
RunListener
{
public
static
final
String
CATALOG_FILE
=
"target/TestCaseCatalog.txt"
;
CatalogClass
catalogClass
=
null
;
private
final
LinkedList
<
CatalogMethod
>
methods
=
new
LinkedList
<>();
@Override
public
void
testRunStarted
(
Description
description
)
throws
Exception
{
catalogClass
=
new
CatalogClass
();
TestTarget
target
=
description
.
getAnnotation
(
TestTarget
.
class
);
if
(
target
!=
null
)
{
catalogClass
.
setAlias
(
target
.
alias
());
catalogClass
.
setAuthor
(
target
.
author
());
catalogClass
.
setVersion
(
target
.
version
());
}
catalogClass
.
setName
(
getClassName
(
description
.
getClassName
()));
}
private
String
getClassName
(
String
name
)
{
if
(
null
==
name
||
name
.
trim
().
equals
(
""
))
{
return
null
;
}
name
=
name
.
trim
();
int
pos
=
name
.
lastIndexOf
(
"."
);
if
(-
1
==
pos
)
{
return
name
;
}
return
name
.
substring
(
pos
+
1
);
}
@Override
public
void
testRunFinished
(
Result
result
)
throws
Exception
{
catalogClass
.
setMethods
(
methods
);
catalogClass
.
setTotal
(
result
.
getRunCount
());
catalogClass
.
setFailure
(
result
.
getFailureCount
());
File
file
=
new
File
(
CATALOG_FILE
);
if
(!
file
.
exists
())
{
synchronized
(
CatalogListener
.
class
)
{
if
(!
file
.
exists
())
{
file
.
createNewFile
();
try
(
FileWriter
writer
=
new
FileWriter
(
file
,
true
))
{
writer
.
write
(
"\tName\tPass\tMessage\tAuthor\tVersion\n"
);
writer
.
write
(
catalogClass
.
toString
());
}
}
}
}
else
{
try
(
FileWriter
writer
=
new
FileWriter
(
file
,
true
))
{
writer
.
write
(
catalogClass
.
toString
());
}
}
}
@Override
public
void
testStarted
(
Description
description
)
throws
Exception
{
}
@Override
public
void
testFinished
(
Description
description
)
throws
Exception
{
com
.
taosdata
.
jdbc
.
annotation
.
Description
annotation
=
description
.
getAnnotation
(
com
.
taosdata
.
jdbc
.
annotation
.
Description
.
class
);
if
(
annotation
!=
null
)
{
CatalogMethod
method
=
new
CatalogMethod
();
method
.
setMessage
(
annotation
.
value
());
method
.
setAuthor
(
annotation
.
author
());
method
.
setVersion
(
annotation
.
version
());
method
.
setSuccess
(
true
);
method
.
setName
(
description
.
getMethodName
());
methods
.
addLast
(
method
);
}
}
@Override
public
void
testFailure
(
Failure
failure
)
throws
Exception
{
com
.
taosdata
.
jdbc
.
annotation
.
Description
annotation
=
failure
.
getDescription
().
getAnnotation
(
com
.
taosdata
.
jdbc
.
annotation
.
Description
.
class
);
CatalogMethod
method
=
new
CatalogMethod
();
method
.
setMessage
(
annotation
.
value
());
method
.
setAuthor
(
annotation
.
author
());
method
.
setVersion
(
annotation
.
version
());
method
.
setSuccess
(
false
);
method
.
setName
(
failure
.
getDescription
().
getMethodName
());
methods
.
addFirst
(
method
);
}
@Override
public
void
testAssumptionFailure
(
Failure
failure
)
{
}
@Override
public
void
testIgnored
(
Description
description
)
throws
Exception
{
super
.
testIgnored
(
description
);
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogMethod.java
0 → 100644
浏览文件 @
68c14bb6
package
com.taosdata.jdbc.annotation
;
/**
* Test method
*/
public
class
CatalogMethod
{
private
String
name
;
private
boolean
success
;
private
String
message
;
private
String
author
;
private
String
version
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
boolean
isSuccess
()
{
return
success
;
}
public
void
setSuccess
(
boolean
success
)
{
this
.
success
=
success
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getAuthor
()
{
return
author
;
}
public
void
setAuthor
(
String
author
)
{
this
.
author
=
author
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/CatalogRunner.java
0 → 100644
浏览文件 @
68c14bb6
package
com.taosdata.jdbc.annotation
;
import
org.junit.internal.AssumptionViolatedException
;
import
org.junit.internal.runners.model.EachTestNotifier
;
import
org.junit.runner.notification.RunNotifier
;
import
org.junit.runner.notification.StoppedByUserException
;
import
org.junit.runners.BlockJUnit4ClassRunner
;
import
org.junit.runners.model.InitializationError
;
import
org.junit.runners.model.Statement
;
public
class
CatalogRunner
extends
BlockJUnit4ClassRunner
{
public
CatalogRunner
(
Class
<?>
testClass
)
throws
InitializationError
{
super
(
testClass
);
}
@Override
public
void
run
(
RunNotifier
notifier
)
{
//add user-defined listener
notifier
.
addListener
(
new
CatalogListener
());
EachTestNotifier
testNotifier
=
new
EachTestNotifier
(
notifier
,
getDescription
());
notifier
.
fireTestRunStarted
(
getDescription
());
try
{
Statement
statement
=
classBlock
(
notifier
);
statement
.
evaluate
();
}
catch
(
AssumptionViolatedException
av
)
{
testNotifier
.
addFailedAssumption
(
av
);
}
catch
(
StoppedByUserException
exception
)
{
throw
exception
;
}
catch
(
Throwable
e
)
{
testNotifier
.
addFailure
(
e
);
}
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/Description.java
0 → 100644
浏览文件 @
68c14bb6
package
com.taosdata.jdbc.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
METHOD
})
public
@interface
Description
{
String
value
();
// git blame author
String
author
()
default
""
;
// since which version;
String
version
()
default
""
;
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/annotation/TestTarget.java
0 → 100644
浏览文件 @
68c14bb6
package
com.taosdata.jdbc.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
})
public
@interface
TestTarget
{
String
alias
()
default
""
;
String
author
();
String
version
()
default
""
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录