Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
06b09d75
提交
06b09d75
authored
1月 19, 2022
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(base): 新增了TestCase执行器
上级
3022de6c
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
152 行增加
和
7 行删除
+152
-7
CheckPointActuator.java
...src/main/java/org/matrix/actuator/CheckPointActuator.java
+2
-1
HttpClientActuator.java
...src/main/java/org/matrix/actuator/HttpClientActuator.java
+9
-3
TestCaseActuator.java
...e/src/main/java/org/matrix/actuator/TestCaseActuator.java
+71
-0
TestCase.java
...se/src/main/java/org/matrix/database/entity/TestCase.java
+0
-1
HttpRequestDetail.java
...java/org/matrix/entity/httpRequest/HttpRequestDetail.java
+0
-1
HttpResponseDetail.java
...ava/org/matrix/entity/httpRequest/HttpResponseDetail.java
+5
-1
RequestHeader.java
...ain/java/org/matrix/entity/httpRequest/RequestHeader.java
+3
-0
BaseTestCaseResponseDetail.java
...rg/matrix/entity/testCase/BaseTestCaseResponseDetail.java
+10
-0
TestCaseExecuteResult.java
...ava/org/matrix/entity/testCase/TestCaseExecuteResult.java
+20
-0
TestCaseTypeEnum.java
...ain/java/org/matrix/entity/testCase/TestCaseTypeEnum.java
+23
-0
pom.xml
pom.xml
+9
-0
没有找到文件。
kt-base/src/main/java/org/matrix/actuator/CheckPointActuator.java
浏览文件 @
06b09d75
...
...
@@ -50,7 +50,7 @@ public class CheckPointActuator {
this
.
env
=
env
;
}
public
void
httpCheck
(
HttpResponseDetail
httpResponseDetail
,
CheckPoint
checkPoint
)
{
public
CheckPointResult
httpCheck
(
HttpResponseDetail
httpResponseDetail
,
CheckPoint
checkPoint
)
{
CheckPointResult
checkPointResult
=
new
CheckPointResult
();
//根据checkPoint里的细节数据开始检测
//异常检查点检测
...
...
@@ -72,6 +72,7 @@ public class CheckPointActuator {
checkPointResult
.
addCheckPointResultDetail
(
jsonPathCheck
(
jsonPathCheckPoint
,
jsonObject
));
}
}
return
checkPointResult
;
}
public
CheckPointResultDetail
jsonPathCheck
(
JsonPathCheckPoint
jsonPathCheckPoint
,
Object
jsonObject
)
{
...
...
kt-base/src/main/java/org/matrix/actuator/HttpClientActuator.java
浏览文件 @
06b09d75
...
...
@@ -48,11 +48,17 @@ public class HttpClientActuator {
CloseableHttpClient
client
;
private
int
projectId
;
public
HttpClientActuator
(
HttpRequestConfig
config
)
throws
KeyStoreException
,
NoSuchAlgorithmException
,
KeyManagementException
{
private
String
env
;
public
HttpClientActuator
(
HttpRequestConfig
config
,
String
env
,
int
projectId
)
throws
KeyStoreException
,
NoSuchAlgorithmException
,
KeyManagementException
{
this
.
config
=
config
;
this
.
cookieStore
=
config
.
cookieStore
();
this
.
client
=
config
.
client
();
this
.
projectId
=
projectId
;
this
.
env
=
env
;
}
public
CloseableHttpClient
getClient
()
{
...
...
@@ -62,7 +68,7 @@ public class HttpClientActuator {
/**
* 初始化请求内数据并补全动态变量
*/
p
ublic
void
completeHttpRequestDetail
(
HttpRequestDetail
httpRequestDetail
){
p
rivate
void
completeHttpRequestDetail
(
HttpRequestDetail
httpRequestDetail
){
for
(
RequestHeader
header
:
httpRequestDetail
.
getHeaders
())
{
//获取动态变量,并将动态变量替换进去
//todo 李迪凡 将header中的key和value里的 动态变量补全
...
...
@@ -81,7 +87,7 @@ public class HttpClientActuator {
* 发起Http请求
*
*/
p
rivate
HttpResponseDetail
sendHttpRequest
(
HttpRequestDetail
httpRequestDetail
)
{
p
ublic
HttpResponseDetail
sendHttpRequest
(
HttpRequestDetail
httpRequestDetail
)
{
completeHttpRequestDetail
(
httpRequestDetail
);
CloseableHttpResponse
response
=
null
;
Date
startTime
=
new
Date
();
...
...
kt-base/src/main/java/org/matrix/actuator/TestCaseActuator.java
0 → 100644
浏览文件 @
06b09d75
package
org
.
matrix
.
actuator
;
import
com.alibaba.fastjson.JSON
;
import
org.matrix.config.HttpRequestConfig
;
import
org.matrix.database.entity.TestCase
;
import
org.matrix.entity.checkPoint.CheckPoint
;
import
org.matrix.entity.checkPoint.CheckPointResult
;
import
org.matrix.entity.httpRequest.HttpRequestDetail
;
import
org.matrix.entity.httpRequest.HttpResponseDetail
;
import
org.matrix.entity.testCase.BaseTestCaseResponseDetail
;
import
org.matrix.entity.testCase.TestCaseExecuteResult
;
import
org.matrix.entity.testCase.TestCaseTypeEnum
;
import
java.security.KeyManagementException
;
import
java.security.KeyStoreException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.function.Function
;
/**
* 测试用例执行器
* todo 打印LOG
*
* @author huangxiahao
*/
public
class
TestCaseActuator
{
private
int
projectId
;
private
String
env
;
private
CheckPointActuator
checkPointActuator
;
private
HttpClientActuator
httpClientActuator
;
private
final
String
baseJsPath
=
"baseJs.js"
;
public
TestCaseActuator
(
String
env
,
int
projectId
)
throws
KeyStoreException
,
NoSuchAlgorithmException
,
KeyManagementException
{
this
.
projectId
=
projectId
;
this
.
env
=
env
;
checkPointActuator
=
new
CheckPointActuator
(
baseJsPath
,
env
,
projectId
);
httpClientActuator
=
new
HttpClientActuator
(
new
HttpRequestConfig
(),
env
,
projectId
);
}
/**
* 执行测试用例
*/
public
TestCaseExecuteResult
executeTestCase
(
TestCase
testCase
)
{
//todo 李迪凡 执行前置动作
//执行测试用例的本体内容
BaseTestCaseResponseDetail
baseTestCaseResponseDetail
=
null
;
if
(
testCase
.
getType
().
equals
(
TestCaseTypeEnum
.
HTTP
.
getValue
()))
{
HttpRequestDetail
httpRequestDetail
=
JSON
.
parseObject
(
testCase
.
getDetail
(),
HttpRequestDetail
.
class
);
baseTestCaseResponseDetail
=
httpClientActuator
.
sendHttpRequest
(
httpRequestDetail
);
}
//todo 李迪凡 执行测试后动作
//进行检验
CheckPointResult
checkPointResult
=
null
;
if
(
testCase
.
getType
().
equals
(
TestCaseTypeEnum
.
HTTP
.
getValue
()))
{
checkPointResult
=
checkPointActuator
.
httpCheck
((
HttpResponseDetail
)
baseTestCaseResponseDetail
,
getCheckPointEntity
(
testCase
));
}
//todo 李迪凡 执行后置动作
return
new
TestCaseExecuteResult
(
baseTestCaseResponseDetail
,
checkPointResult
);
}
private
CheckPoint
getCheckPointEntity
(
TestCase
testCase
)
{
return
new
CheckPoint
();
}
}
kt-base/src/main/java/org/matrix/database/entity/TestCase.java
浏览文件 @
06b09d75
...
...
@@ -67,5 +67,4 @@ public class TestCase extends BaseEntity {
@ApiModelProperty
(
"详细参数"
)
private
String
detail
;
}
kt-base/src/main/java/org/matrix/entity/httpRequest/HttpRequestDetail.java
浏览文件 @
06b09d75
...
...
@@ -14,7 +14,6 @@ import java.util.List;
@Data
public
class
HttpRequestDetail
{
@ApiModelProperty
(
"请求头"
)
private
List
<
RequestHeader
>
headers
=
new
ArrayList
<>();
...
...
kt-base/src/main/java/org/matrix/entity/httpRequest/HttpResponseDetail.java
浏览文件 @
06b09d75
...
...
@@ -5,12 +5,16 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.matrix.entity.testCase.BaseTestCaseResponseDetail
;
import
org.springframework.http.HttpStatus
;
/**
* @author huangxiahao
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
HttpResponseDetail
{
public
class
HttpResponseDetail
extends
BaseTestCaseResponseDetail
{
@ApiModelProperty
(
"HttpClient响应体"
)
private
CloseableHttpResponse
response
;
...
...
kt-base/src/main/java/org/matrix/entity/httpRequest/RequestHeader.java
浏览文件 @
06b09d75
...
...
@@ -5,6 +5,9 @@ import lombok.Data;
import
lombok.NoArgsConstructor
;
import
org.apache.http.message.BasicHeader
;
/**
* @author huangxiahao
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
...
...
kt-base/src/main/java/org/matrix/entity/testCase/BaseTestCaseResponseDetail.java
0 → 100644
浏览文件 @
06b09d75
package
org
.
matrix
.
entity
.
testCase
;
import
lombok.Data
;
/**
* @author huangxiahao
*/
@Data
public
class
BaseTestCaseResponseDetail
{
}
kt-base/src/main/java/org/matrix/entity/testCase/TestCaseExecuteResult.java
0 → 100644
浏览文件 @
06b09d75
package
org
.
matrix
.
entity
.
testCase
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.matrix.entity.checkPoint.CheckPointResult
;
/**
* @author huangxiahao
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
TestCaseExecuteResult
{
BaseTestCaseResponseDetail
baseTestCaseRequestDetail
;
CheckPointResult
checkPointResult
;
}
kt-base/src/main/java/org/matrix/entity/testCase/TestCaseTypeEnum.java
0 → 100644
浏览文件 @
06b09d75
package
org
.
matrix
.
entity
.
testCase
;
/**
* @author huangxiahao
*/
public
enum
TestCaseTypeEnum
{
/**
* Http类型
*/
HTTP
(
1
);
private
Integer
value
;
TestCaseTypeEnum
(
Integer
value
)
{
this
.
value
=
value
;
}
public
Integer
getValue
()
{
return
value
;
}
}
pom.xml
浏览文件 @
06b09d75
...
...
@@ -72,6 +72,14 @@
<version>
2.4.5
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.79
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论