Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test
Commits
3d7353d6
提交
3d7353d6
authored
3月 30, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
路由规则
上级
e9810394
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
0 行增加
和
307 行删除
+0
-307
PushBlockQueue.java
src/main/java/com/zjty/autotest/mq/PushBlockQueue.java
+0
-6
PushBlockQueueHandler.java
...main/java/com/zjty/autotest/mq/PushBlockQueueHandler.java
+0
-14
AsyncService.java
src/main/java/com/zjty/autotest/service/AsyncService.java
+0
-8
AsyncServiceImpl.java
...java/com/zjty/autotest/service/impl/AsyncServiceImpl.java
+0
-273
AutoResultSetServiceImpl.java
.../zjty/autotest/service/impl/AutoResultSetServiceImpl.java
+0
-6
没有找到文件。
src/main/java/com/zjty/autotest/mq/PushBlockQueue.java
浏览文件 @
3d7353d6
package
com
.
zjty
.
autotest
.
mq
;
import
com.zjty.autotest.dao.AutoResultSetDao
;
import
com.zjty.autotest.service.AsyncService
;
import
com.zjty.autotest.service.TestReportService
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.concurrent.ExecutorService
;
...
...
src/main/java/com/zjty/autotest/mq/PushBlockQueueHandler.java
浏览文件 @
3d7353d6
package
com
.
zjty
.
autotest
.
mq
;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.autotest.pojo.sjq.*
;
import
com.zjty.autotest.service.AsyncService
;
import
com.zjty.autotest.service.AutoResultSetService
;
import
com.zjty.autotest.service.TestReportService
;
import
com.zjty.autotest.util.TimeUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Component
public
class
PushBlockQueueHandler
implements
Runnable
{
@Autowired
private
AsyncService
asyncService
;
//消费的对象
private
Object
obj
;
...
...
src/main/java/com/zjty/autotest/service/AsyncService.java
deleted
100644 → 0
浏览文件 @
e9810394
package
com
.
zjty
.
autotest
.
service
;
public
interface
AsyncService
{
/**
* 执行异步任务
*/
void
executeAsync
(
String
id
);
}
src/main/java/com/zjty/autotest/service/impl/AsyncServiceImpl.java
deleted
100644 → 0
浏览文件 @
e9810394
package
com
.
zjty
.
autotest
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.autotest.mq.CacheManager
;
import
com.zjty.autotest.pojo.report.Measure
;
import
com.zjty.autotest.pojo.report.Report
;
import
com.zjty.autotest.pojo.sjq.*
;
import
com.zjty.autotest.pojo.test.Input
;
import
com.zjty.autotest.pojo.test.Project
;
import
com.zjty.autotest.service.AsyncService
;
import
com.zjty.autotest.service.AutoResultSetService
;
import
com.zjty.autotest.service.TestReportService
;
import
com.zjty.autotest.util.FileHtmlUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
AsyncServiceImpl
implements
AsyncService
{
@Autowired
private
AutoResultSetService
autoResultSetService
;
@Autowired
private
TestReportService
testReportService
;
@Autowired
private
SeleniumExecutor
seleniumExecutor
;
@Override
@Async
public
void
executeAsync
(
String
id
)
{
System
.
out
.
println
(
"id:"
+
id
);
TestChannel
testChannel
=
(
TestChannel
)
CacheManager
.
getCache
(
id
);
if
(
testChannel
!=
null
)
{
try
{
Project
project
=
new
Project
();
project
.
setBrowser
(
testChannel
.
getBrowser
());
project
.
setName
(
testChannel
.
getName
());
project
.
setUrl
(
testChannel
.
getUrl
());
List
<
RuleSet
>
ruleSets
=
testChannel
.
getRuleSets
();
List
<
Input
>
inputs
=
new
ArrayList
<>();
project
.
setInputs
(
null
);
if
(
ruleSets
!=
null
)
{
for
(
RuleSet
ruleSet
:
ruleSets
)
{
Input
input
=
new
Input
();
input
.
setKey
(
ruleSet
.
getDes
());
input
.
setAttrName
(
ruleSet
.
getCommand
());
input
.
setAttrValue
(
ruleSet
.
getTarget
());
input
.
setValue
(
ruleSet
.
getValue
());
inputs
.
add
(
input
);
}
project
.
setInputs
(
inputs
);
}
//调用黄承天代码
Report
report
=
seleniumExecutor
.
execute
(
project
);
List
<
Measure
>
measures
=
report
.
getMeasures
();
if
(
measures
!=
null
)
{
long
count
=
measures
.
stream
().
filter
(
m
->
!
m
.
getSuccess
()).
count
();
System
.
out
.
println
(
report
);
EvaReport
evaReport
=
new
EvaReport
();
evaReport
.
setBrowser
(
report
.
getBrowser
());
if
(
count
>
0
)
{
evaReport
.
setFailCount
(
testChannel
.
getName
()
+
"系统未通过测试,"
+
"未通过测试点共"
+
count
+
"个"
);
}
evaReport
.
setFailCount
(
testChannel
.
getName
()
+
"系统通过测试,"
+
"未通过测试点共0个"
);
evaReport
.
setProjectName
(
report
.
getProjectName
());
evaReport
.
setCreateTime
(
new
Date
());
evaReport
.
setSystem
(
"中标麒麟v7龙芯版"
);
evaReport
.
setUrl
(
testChannel
.
getUrl
());
List
<
FailMessage
>
failMessages
=
new
ArrayList
<>();
List
<
Measure
>
measureList
=
measures
.
stream
().
filter
(
m
->
!
m
.
getSuccess
()).
collect
(
Collectors
.
toList
());
for
(
Measure
measure
:
measureList
)
{
FailMessage
failMessage
=
new
FailMessage
();
failMessage
.
setUrl
(
measure
.
getUrl
());
failMessage
.
setMessage
(
measure
.
getMessage
());
failMessage
.
setPicture
(
measure
.
getScreenshot
());
failMessages
.
add
(
failMessage
);
}
evaReport
.
setFailMessages
(
failMessages
);
evaReport
.
setPageRoutes
(
null
);
HashMap
<
String
,
List
<
Measure
>>
map
=
new
HashMap
<>();
for
(
Measure
measure
:
measures
)
{
if
(
map
.
get
(
measure
.
getUrl
())!=
null
){
List
<
Measure
>
measures1
=
map
.
get
(
measure
.
getUrl
());
measures1
.
add
(
measure
);
map
.
put
(
measure
.
getUrl
(),
measures1
);
}
else
{
List
<
Measure
>
mss
=
new
ArrayList
<>();
mss
.
add
(
measure
);
map
.
put
(
measure
.
getUrl
(),
mss
);
}
}
List
<
PageContentTest
>
pageContents
=
new
ArrayList
<>();
Set
<
String
>
strings
=
map
.
keySet
();
for
(
String
url
:
strings
)
{
PageContentTest
pageContentTest
=
new
PageContentTest
();
pageContentTest
.
setUrl
(
url
);
List
<
Measure
>
measures1
=
map
.
get
(
url
);
List
<
PageContent
>
contents
=
new
ArrayList
<>();
for
(
Measure
measure
:
measures1
)
{
PageContent
pageContent
=
new
PageContent
();
pageContent
.
setParms
(
null
);
pageContent
.
setMessage
(
measure
.
getMessage
());
pageContent
.
setResponseTime
(
measure
.
getResponseTime
());
pageContent
.
setSuccess
(
0
);
if
(
measure
.
getSuccess
())
{
pageContent
.
setSuccess
(
1
);
}
contents
.
add
(
pageContent
);
}
pageContentTest
.
setContents
(
contents
);
pageContents
.
add
(
pageContentTest
);
}
evaReport
.
setPageContents
(
pageContents
);
/*List<PageRoute> pageRoutes = new ArrayList<>();
PageRoute pageRoute = new PageRoute();
pageRoute.setPageName("https://www.baidu.com/");
pageRoute.setAddress("/baidu");
pageRoute.setMessage("");
pageRoute.setResponseTime(300);
pageRoute.setSuccess(0);
pageRoute.setPicture("https://pics4.baidu.com/feed/500fd9f9d72a6059aecf87d92406529d013bbaca.jpeg?token=53433060d4d120e00d8ac6612d2303fd");
PageRoute pageRoute1 = new PageRoute();
pageRoute1.setPageName("https://www.baidu.com/");
pageRoute1.setAddress("/baidu");
pageRoute1.setMessage("不能访问");
pageRoute1.setResponseTime(300);
pageRoute1.setSuccess(1);
pageRoute1.setPicture("https://pics4.baidu.com/feed/500fd9f9d72a6059aecf87d92406529d013bbaca.jpeg?token=53433060d4d120e00d8ac6612d2303fd");
pageRoutes.add(pageRoute);
pageRoutes.add(pageRoute1);*/
// evaReport.setPageRoutes(pageRoutes);
if
(
testChannel
.
getCodeUrl
()
!=
null
)
{
if
(
testChannel
.
getCodeUrl
()
!=
null
)
{
//解压上传得代码
FileHtmlUtil
.
getFiles
(
testChannel
.
getCodeUrl
(),
null
);
Map
<
String
,
List
<
FileType
>>
alls
=
FileHtmlUtil
.
getAlls
();
//获取项目类型
FileHtmlUtil
.
getFileRoutes
(
testChannel
.
getCodeUrl
());
int
jspcount
=
FileHtmlUtil
.
jspNum
;
int
jscount
=
FileHtmlUtil
.
jsNum
;
int
vuecount
=
FileHtmlUtil
.
vueNum
;
int
angularcount
=
FileHtmlUtil
.
angularNum
;
int
htmlcount
=
FileHtmlUtil
.
count
;
String
fileRoutes
=
null
;
if
(
jspcount
>
0
){
fileRoutes
=
"jsp"
;
}
else
if
(
vuecount
>
0
){
fileRoutes
=
"vue"
;
}
else
if
(
jscount
>
0
){
fileRoutes
=
"react"
;
}
else
if
(
angularcount
>
0
){
fileRoutes
=
"angular"
;
}
if
(
fileRoutes
!=
null
)
{
// List<String> routerList = getRouterList(alls, fileRoutes);
// List<String> collect = routerList.stream().map(String::toLowerCase).distinct().collect(Collectors.toList());
// System.out.println(collect.toString());
}
FileHtmlUtil
.
clearAll
();
//获取前端代码中得网页路由地址
//比对黄承天代码中访问得地址和路由地址,黄承天是否访问全了。
}
//比对黄承天代码中访问得地址和路由地址,黄承天是否访问全了。
}
System
.
out
.
println
(
"修改状态"
);
//改变报告状态
String
out
=
JSON
.
toJSONString
(
evaReport
);
String
in
=
JSON
.
toJSONString
(
testChannel
);
System
.
out
.
println
(
id
);
System
.
out
.
println
(
"输出:"
+
out
);
System
.
out
.
println
(
"输入:"
+
in
);
TestReport
testReport
=
new
TestReport
();
testReport
.
setResultId
(
id
);
testReport
.
setOutReport
(
out
);
testReport
.
setInputReport
(
in
);
testReport
.
setStatus
(
1
);
testReportService
.
save
(
testReport
);
CacheManager
.
removeCache
(
id
);
}
// autoResultSetService.updateByid(id);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
private
void
doBusiness
(
String
id
)
{
System
.
out
.
println
(
"doBusiness id:"
+
id
);
TestChannel
testChannel
=
(
TestChannel
)
CacheManager
.
getCache
(
id
);
if
(
testChannel
!=
null
)
{
try
{
EvaReport
evaReport
=
new
EvaReport
();
evaReport
.
setBrowser
(
testChannel
.
getBrowser
());
evaReport
.
setFailCount
(
testChannel
.
getName
()
+
"系统未通过测试,"
+
"未通过测试点共"
+
"10"
+
"个"
);
evaReport
.
setProjectName
(
testChannel
.
getName
());
evaReport
.
setCreateTime
(
new
Date
());
evaReport
.
setSystem
(
"中标麒麟v7龙芯版"
);
evaReport
.
setUrl
(
testChannel
.
getUrl
());
List
<
FailMessage
>
failMessages
=
new
ArrayList
<>();
FailMessage
failMessage
=
new
FailMessage
();
failMessage
.
setUrl
(
"https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=osari_pc_1"
);
failMessage
.
setMessage
(
"抗击疫情打不开响应超时"
);
failMessage
.
setPicture
(
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584955247760&di=f073d6fd65cf71798843c6e4634358dd&imgtype=0&src=http%3A%2F%2Fa0.att.hudong.com%2F78%2F52%2F01200000123847134434529793168.jpg"
);
failMessages
.
add
(
failMessage
);
evaReport
.
setFailMessages
(
failMessages
);
List
<
PageRoute
>
pageRoutes
=
new
ArrayList
<>();
PageRoute
pageRoute
=
new
PageRoute
();
pageRoute
.
setPageName
(
"https://www.baidu.com/"
);
pageRoute
.
setAddress
(
"/baidu"
);
pageRoute
.
setMessage
(
""
);
pageRoute
.
setResponseTime
(
300
);
pageRoute
.
setSuccess
(
0
);
pageRoute
.
setPicture
(
"https://pics4.baidu.com/feed/500fd9f9d72a6059aecf87d92406529d013bbaca.jpeg?token=53433060d4d120e00d8ac6612d2303fd"
);
PageRoute
pageRoute1
=
new
PageRoute
();
pageRoute1
.
setPageName
(
"https://www.baidu.com/"
);
pageRoute1
.
setAddress
(
"/baidu"
);
pageRoute1
.
setMessage
(
"不能访问"
);
pageRoute1
.
setResponseTime
(
300
);
pageRoute1
.
setSuccess
(
1
);
pageRoute1
.
setPicture
(
"https://pics4.baidu.com/feed/500fd9f9d72a6059aecf87d92406529d013bbaca.jpeg?token=53433060d4d120e00d8ac6612d2303fd"
);
pageRoutes
.
add
(
pageRoute
);
pageRoutes
.
add
(
pageRoute1
);
evaReport
.
setPageRoutes
(
pageRoutes
);
List
<
PageContentTest
>
pageContents
=
new
ArrayList
<>();
PageContentTest
pageContentTest
=
new
PageContentTest
();
pageContentTest
.
setUrl
(
"http://news.baidu.com/"
);
List
<
PageContent
>
contents
=
new
ArrayList
<>();
PageContent
pageContent
=
new
PageContent
();
pageContent
.
setParms
(
"国内"
);
pageContent
.
setMessage
(
""
);
pageContent
.
setResponseTime
(
300
);
pageContent
.
setSuccess
(
0
);
PageContent
pageContent1
=
new
PageContent
();
pageContent1
.
setParms
(
"国外"
);
pageContent1
.
setMessage
(
"响应时间过长"
);
pageContent1
.
setResponseTime
(
30000
);
pageContent1
.
setSuccess
(
1
);
contents
.
add
(
pageContent
);
contents
.
add
(
pageContent1
);
pageContentTest
.
setContents
(
contents
);
pageContents
.
add
(
pageContentTest
);
evaReport
.
setPageContents
(
pageContents
);
System
.
out
.
println
(
"修改状态"
);
//改变报告状态
String
out
=
JSON
.
toJSONString
(
evaReport
);
String
in
=
JSON
.
toJSONString
(
testChannel
);
System
.
out
.
println
(
out
);
System
.
out
.
println
(
in
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/main/java/com/zjty/autotest/service/impl/AutoResultSetServiceImpl.java
浏览文件 @
3d7353d6
...
...
@@ -3,19 +3,15 @@ package com.zjty.autotest.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.autotest.dao.AutoResultSetDao
;
import
com.zjty.autotest.mq.CacheManager
;
import
com.zjty.autotest.mq.PushBlockQueue
;
import
com.zjty.autotest.mq.QueueManager
;
import
com.zjty.autotest.pojo.sjq.AutoResultSet
;
import
com.zjty.autotest.pojo.sjq.TestChannel
;
import
com.zjty.autotest.pojo.sjq.TestReport
;
import
com.zjty.autotest.pojo.sjq.common.AppHttpCodeEnum
;
import
com.zjty.autotest.pojo.sjq.common.ResponseResult
;
import
com.zjty.autotest.service.AsyncService
;
import
com.zjty.autotest.service.AutoResultSetService
;
import
com.zjty.autotest.service.TestReportService
;
import
com.zjty.autotest.util.IdWorker
;
import
com.zjty.autotest.util.TimeUtil
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
...
...
@@ -37,8 +33,6 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
private
TestReportService
testReportService
;
@Autowired
private
IdWorker
idWorker
;
@Autowired
private
AsyncService
asyncService
;
@Override
public
Page
<
AutoResultSet
>
findSearch
(
Map
whereMap
,
int
page
,
int
size
)
{
Specification
<
AutoResultSet
>
specification
=
createSpecification
(
whereMap
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论