Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test
Commits
9651099a
提交
9651099a
authored
3月 26, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
路由规则
上级
e5dccc09
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
172 行增加
和
164 行删除
+172
-164
TestReportDao.java
src/main/java/com/zjty/autotest/dao/TestReportDao.java
+6
-0
TestTask.java
src/main/java/com/zjty/autotest/mq/TestTask.java
+76
-21
FileType.java
src/main/java/com/zjty/autotest/pojo/sjq/FileType.java
+13
-0
AutoResultSetServiceImpl.java
.../zjty/autotest/service/impl/AutoResultSetServiceImpl.java
+1
-0
TestReportServiceImpl.java
...com/zjty/autotest/service/impl/TestReportServiceImpl.java
+1
-15
FileHtmlUtil.java
src/main/java/com/zjty/autotest/util/FileHtmlUtil.java
+75
-128
没有找到文件。
src/main/java/com/zjty/autotest/dao/TestReportDao.java
浏览文件 @
9651099a
...
...
@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Modifying;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
javax.transaction.Transactional
;
import
java.beans.Transient
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -25,6 +27,10 @@ public interface TestReportDao extends JpaRepository<TestReport,String>, JpaSpec
TestReport
findByResultId
(
@Param
(
"resultId"
)
String
resultId
);
@Modifying
int
deleteByResultId
(
@Param
(
"resultId"
)
String
resultId
);
@Modifying
@Transactional
@Query
(
"update TestReport set outReport=:outReport,status=1 where resultId=:resultId"
)
void
updateOut
(
String
outReport
,
String
resultId
);
@Query
(
value
=
"select result_id,status from test_report "
,
nativeQuery
=
true
)
List
<
Map
<
String
,
Object
>>
findAllStatus
();
...
...
src/main/java/com/zjty/autotest/mq/TestTask.java
浏览文件 @
9651099a
...
...
@@ -17,6 +17,9 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.StringUtils
;
import
java.util.*
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
@Component
@Slf4j
...
...
@@ -29,10 +32,10 @@ public class TestTask {
@Scheduled
(
cron
=
"0/1 * * * * ?"
)
@Async
(
"asyncServiceExecutor"
)
public
void
getMessage
(){
public
void
getMessage
()
{
String
take
=
QueueManager
.
take
();
log
.
info
(
"获取到消息:{}"
,
take
);
if
(!
StringUtils
.
isEmpty
(
take
))
{
log
.
info
(
"获取到消息:{}"
,
take
);
if
(!
StringUtils
.
isEmpty
(
take
))
{
doBusiness
(
take
);
}
}
...
...
@@ -42,7 +45,7 @@ public class TestTask {
TestChannel
testChannel
=
(
TestChannel
)
CacheManager
.
getCache
(
id
);
if
(
testChannel
!=
null
)
{
log
.
info
(
"testChannel不为空:{}"
,
testChannel
);
log
.
info
(
"testChannel不为空:{}"
,
testChannel
);
try
{
EvaReport
evaReport
=
new
EvaReport
();
evaReport
.
setBrowser
(
testChannel
.
getBrowser
());
...
...
@@ -101,25 +104,34 @@ public class TestTask {
Thread
.
sleep
(
600
);
if
(
testChannel
.
getCodeUrl
()
!=
null
)
{
//解压上传得代码
String
fileRoutes
=
FileHtmlUtil
.
getFileRoutes
(
testChannel
.
getCodeUrl
());
FileHtmlUtil
.
getFiles
(
testChannel
.
getCodeUrl
(),
null
);
Map
<
String
,
List
<
FileBean
>>
alls
=
FileHtmlUtil
.
getAlls
();
//所有的路由
List
<
String
>
allRouters
=
new
ArrayList
<>();
Set
<
String
>
all
=
alls
.
keySet
();
for
(
String
s1
:
all
)
{
List
<
FileBean
>
fileBeans
=
alls
.
get
(
s1
);
if
(
fileRoutes
!=
null
)
{
if
(
s1
.
contains
(
"router"
))
{
for
(
FileBean
fileBean
:
fileBeans
)
{
allRouters
.
addAll
(
FileHtmlUtil
.
readTxtFile
(
fileBean
.
getUrl
(),
"(\\/:*[a-zA-Z0-9]*)+"
));
}
}
}
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"
;
}
for
(
String
allRouter
:
allRouters
)
{
System
.
out
.
println
(
"路由:"
+
allRouter
);
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
();
//获取前端代码中得网页路由地址
//比对黄承天代码中访问得地址和路由地址,黄承天是否访问全了。
...
...
@@ -141,4 +153,47 @@ public class TestTask {
}
}
private
List
<
String
>
getRouterList
(
Map
<
String
,
List
<
FileType
>>
alls
,
String
fileRoutes
)
{
List
<
String
>
allRouters
=
new
ArrayList
<>();
Set
<
String
>
all
=
alls
.
keySet
();
//所有的路由
if
(
fileRoutes
.
equals
(
"vue"
))
{
for
(
String
s1
:
all
)
{
List
<
FileType
>
fileBeans
=
alls
.
get
(
s1
);
if
(
fileRoutes
!=
null
)
{
if
(
s1
.
contains
(
"router"
))
{
for
(
FileType
fileBean
:
fileBeans
)
{
allRouters
.
addAll
(
FileHtmlUtil
.
readTxtFile
(
fileBean
.
getAddress
(),
"(\\/:*[a-zA-Z0-9]*)+"
));
}
}
}
}
}
else
if
(
fileRoutes
.
equals
(
"angular"
)||
fileRoutes
.
equals
(
"react"
)){
for
(
String
s1
:
all
)
{
List
<
FileType
>
fileBeans
=
alls
.
get
(
s1
);
if
(
fileRoutes
!=
null
)
{
if
(
s1
.
contains
(
"router"
)||
s1
.
contains
(
"js"
))
{
for
(
FileType
fileBean
:
fileBeans
)
{
allRouters
.
addAll
(
FileHtmlUtil
.
readTxtFile
(
fileBean
.
getAddress
(),
"(\\/:*[a-zA-Z0-9]*)+"
));
}
}
}
}
}
else
{
for
(
String
s1
:
all
)
{
List
<
FileType
>
fileBeans
=
alls
.
get
(
s1
);
if
(
fileRoutes
!=
null
)
{
for
(
FileType
fileBean
:
fileBeans
)
{
if
(
fileBean
.
getSuffix
().
equals
(
"jsp"
))
{
allRouters
.
addAll
(
FileHtmlUtil
.
readTxtFile
(
fileBean
.
getAddress
(),
"(\\/:*[a-zA-Z0-9]*)+"
));
}
}
}
}
}
return
allRouters
;
}
}
src/main/java/com/zjty/autotest/pojo/sjq/FileType.java
0 → 100644
浏览文件 @
9651099a
package
com
.
zjty
.
autotest
.
pojo
.
sjq
;
import
io.swagger.annotations.ApiModel
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
public
class
FileType
{
private
String
address
;
private
String
suffix
;
private
String
fileName
;
}
src/main/java/com/zjty/autotest/service/impl/AutoResultSetServiceImpl.java
浏览文件 @
9651099a
...
...
@@ -105,6 +105,7 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
AutoResultSet
save
=
autoResultSetDao
.
save
(
autoResultSet
);
String
in
=
JSON
.
toJSONString
(
testChannel
);
TestReport
testReport
=
new
TestReport
();
testReport
.
setId
(
idWorker
.
nextId
()+
""
);
testReport
.
setResultId
(
tid
);
testReport
.
setStatus
(
0
);
testReport
.
setInputReport
(
in
);
...
...
src/main/java/com/zjty/autotest/service/impl/TestReportServiceImpl.java
浏览文件 @
9651099a
...
...
@@ -76,12 +76,7 @@ public class TestReportServiceImpl implements TestReportService {
* @param testReport
*/
public
void
update
(
TestReport
testReport
)
{
TestReport
report
=
testReportDao
.
findByResultId
(
testReport
.
getResultId
());
if
(
report
!=
null
)
{
report
.
setStatus
(
1
);
report
.
setOutReport
(
testReport
.
getOutReport
());
testReportDao
.
save
(
testReport
);
}
testReportDao
.
updateOut
(
testReport
.
getOutReport
(),
testReport
.
getResultId
());
}
/**
...
...
@@ -96,17 +91,8 @@ public class TestReportServiceImpl implements TestReportService {
@Transient
@Override
public
ResponseResult
save
(
TestReport
testReport
)
{
System
.
out
.
println
(
testReport
);
if
(
testReport
!=
null
){
testReport
.
setId
(
idWorker
.
nextId
()+
""
);
// testReport.setOutReport(testReport.getOutReport());
testReport
.
setStatus
(
testReport
.
getStatus
());
testReport
.
setInputReport
(
testReport
.
getInputReport
());
testReport
.
setResultId
(
testReport
.
getResultId
());
testReportDao
.
save
(
testReport
);
return
ResponseResult
.
okResult
(
AppHttpCodeEnum
.
SUCCESS
);
}
return
ResponseResult
.
errorResult
(
AppHttpCodeEnum
.
ERROR
);
}
@Transient
@Override
...
...
src/main/java/com/zjty/autotest/util/FileHtmlUtil.java
浏览文件 @
9651099a
package
com
.
zjty
.
autotest
.
util
;
import
com.zjty.autotest.pojo.sjq.FileBean
;
import
com.zjty.autotest.pojo.sjq.FileType
;
import
org.springframework.util.StringUtils
;
import
java.io.BufferedReader
;
...
...
@@ -13,31 +14,43 @@ import java.util.regex.Pattern;
import
java.util.stream.Collectors
;
public
class
FileHtmlUtil
{
private
static
List
<
String
>
routes
=
new
ArrayList
<>(
80
);
private
static
List
<
String
>
urls
=
new
ArrayList
<>(
200
);
private
static
HashMap
<
String
,
List
<
FileBean
>>
alls
=
new
HashMap
<>(
200
);
public
static
int
count
=
0
;
public
static
int
angularNum
=
0
;
public
static
int
jsNum
=
0
;
public
static
int
jspNum
=
0
;
public
static
int
vueNum
=
0
;
private
static
List
<
String
>
routes
=
new
ArrayList
<>(
80
);
private
static
List
<
String
>
urls
=
new
ArrayList
<>(
200
);
private
static
HashMap
<
String
,
List
<
FileType
>>
alls
=
new
HashMap
<>(
200
);
public
static
HashMap
<
String
,
List
<
FileBean
>>
getAlls
()
{
public
static
HashMap
<
String
,
List
<
FileType
>>
getAlls
()
{
return
alls
;
}
public
static
void
clearAll
(){
if
(
routes
!=
null
)
{
public
static
void
clearAll
()
{
if
(
routes
!=
null
)
{
routes
.
clear
();
System
.
out
.
println
(
"routes:="
+
routes
);
System
.
out
.
println
(
"routes:="
+
routes
);
}
if
(
urls
!=
null
)
{
if
(
urls
!=
null
)
{
urls
.
clear
();
System
.
out
.
println
(
"urls:="
+
urls
);
System
.
out
.
println
(
"urls:="
+
urls
);
}
if
(
alls
!=
null
)
{
if
(
alls
!=
null
)
{
alls
.
clear
();
System
.
out
.
println
(
"alls:="
+
alls
);
System
.
out
.
println
(
"alls:="
+
alls
);
}
count
=
0
;
jspNum
=
0
;
jsNum
=
0
;
vueNum
=
0
;
angularNum
=
0
;
}
public
static
List
<
String
>
readTxtFile
(
String
filePath
,
String
pattern
)
{
Pattern
p
;
Matcher
m
;
Set
<
String
>
set
=
new
HashSet
<
String
>();
Set
<
String
>
set
=
new
HashSet
<
String
>();
try
{
String
encoding
=
"UTF-8"
;
File
file
=
new
File
(
filePath
);
...
...
@@ -46,18 +59,18 @@ public class FileHtmlUtil {
new
FileInputStream
(
file
),
encoding
);
// 考虑到编码格式
BufferedReader
bufferedReader
=
new
BufferedReader
(
read
);
String
lineTxt
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
if
(
pattern
!=
null
)
{
while
((
lineTxt
=
bufferedReader
.
readLine
())
!=
null
)
{
sb
.
append
(
lineTxt
);
}
}
String
s
=
sb
.
toString
();
p
=
Pattern
.
compile
(
pattern
);
m
=
p
.
matcher
(
s
);
while
(
m
.
find
())
{
p
=
Pattern
.
compile
(
pattern
);
m
=
p
.
matcher
(
s
);
while
(
m
.
find
())
{
String
pp
=
m
.
group
().
substring
(
0
,
m
.
group
().
length
());
if
(!
pp
.
equals
(
"//"
))
{
if
(!
pp
.
equals
(
"//"
))
{
set
.
add
(
pp
.
toLowerCase
());
}
}
...
...
@@ -75,83 +88,8 @@ public class FileHtmlUtil {
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"import Vue from 'vue'\n"
+
"import Router from 'vue-router'\n"
+
"import Index from '@/Index'\n"
+
"import SocialIndex from '@/SocialIndex'\n"
+
"import SocialDetail from '@/SocialDetail'\n"
+
"import SocialPost from '@/SocialPost'\n"
+
"\n"
+
"Vue.use(Router)\n"
+
"\n"
+
"export default new Router({\n"
+
" // mode: 'history',\n"
+
" // hashbang: false,\n"
+
" // history: false,\n"
+
" routes: [\n"
+
" {\n"
+
" path: '/',\n"
+
" name: 'index',\n"
+
" component: Index,\n"
+
" meta: {\n"
+
" title: '这是个圈子',\n"
+
" keepAlive: false\n"
+
" }\n"
+
" },\n"
+
" {\n"
+
" path: '/index',\n"
+
" name: 'index',\n"
+
" component: Index,\n"
+
" meta: {\n"
+
" title: '这是个圈子',\n"
+
" keepAlive: false\n"
+
" }\n"
+
" },\n"
+
" {\n"
+
" path: '/circle/:circleId',\n"
+
" name: 'circle',\n"
+
" component: SocialIndex,\n"
+
" meta: {\n"
+
" title: '这是个圈子',\n"
+
" keepAlive: false\n"
+
" }\n"
+
" },\n"
+
" {\n"
+
" path: '/post/:circleId/:postId/:onPage',\n"
+
" name: 'post',\n"
+
" component: SocialDetail,\n"
+
" meta: {\n"
+
" title: '这是个圈子',\n"
+
" keepAlive: false\n"
+
" }\n"
+
" },\n"
+
" {\n"
+
" path: '/SocialPost/:circleId',\n"
+
" name: 'SocialPost',\n"
+
" component: SocialPost,\n"
+
" meta: {\n"
+
" title: '这是个圈子',\n"
+
" keepAlive: false\n"
+
" }\n"
+
" }\n"
+
" ]\n"
+
"})\n"
;
Set
<
String
>
set
=
new
HashSet
<
String
>();
Pattern
p
=
Pattern
.
compile
(
"(\\/:*[a-zA-Z0-9]*)+"
);
Matcher
m
=
p
.
matcher
(
str
);
while
(
m
.
find
()){
String
substring
=
m
.
group
().
substring
(
0
,
m
.
group
().
length
());
if
(!
substring
.
equals
(
"//"
))
{
set
.
add
(
substring
.
toLowerCase
());
}
// System.out.println(m.group().substring(0, m.group().length()));
}
for
(
String
o
:
set
)
{
System
.
out
.
println
(
o
);
}
}
public
static
void
getFiles
(
String
path
,
String
dirName
){
public
static
void
getFiles
(
String
path
,
String
dirName
)
{
File
file
=
new
File
(
path
);
// 如果这个路径是文件夹
...
...
@@ -161,31 +99,34 @@ public class FileHtmlUtil {
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
// 如果还是文件夹 递归获取里面的文件 文件夹
if
(
files
[
i
].
isDirectory
())
{
if
(!
files
[
i
].
getName
().
equalsIgnoreCase
(
"img"
)||!
files
[
i
].
getName
().
equalsIgnoreCase
(
"plugins"
)
||!
files
[
i
].
getName
().
equalsIgnoreCase
(
"css"
)||!
files
[
i
].
getName
().
equalsIgnoreCase
(
"node_modules"
)
)
{
// System.out.println("routes:" + files[i].getPath());
if
(
files
[
i
].
getName
().
contains
(
"img"
)
||
files
[
i
].
getName
().
contains
(
"plugins"
)
||
files
[
i
].
getName
().
contains
(
"css"
)
||
files
[
i
].
getName
().
contains
(
"node_modules"
))
{
continue
;
}
else
{
System
.
out
.
println
(
"文件夹:"
+
files
[
i
].
getName
());
getFiles
(
files
[
i
].
getPath
(),
files
[
i
].
getName
());
}
}
else
{
if
(
alls
.
get
(
dirName
)!=
null
){
List
<
FileBean
>
fileBeans
=
alls
.
get
(
dirName
);
FileBean
fileBean
=
new
FileBean
();
fileBean
.
setFileType
(
files
[
i
].
getName
());
fileBean
.
setUrl
(
files
[
i
].
getAbsolutePath
());
fileBeans
.
add
(
fileBean
);
}
else
{
int
pos
=
files
[
i
].
getName
().
lastIndexOf
(
"."
);
String
extName
=
files
[
i
].
getName
().
substring
(
pos
+
1
).
toLowerCase
();
if
(
extName
.
equals
(
"js"
)||
extName
.
equals
(
"html"
)||
extName
.
equals
(
"jsp"
))
{
List
<
FileBean
>
fileBeans
=
new
ArrayList
<>();
FileBean
fileBean
=
new
FileBean
();
fileBean
.
setFileType
(
files
[
i
].
getName
());
fileBean
.
setUrl
(
files
[
i
].
getAbsolutePath
());
int
pos
=
files
[
i
].
getName
().
lastIndexOf
(
"."
);
String
extName
=
files
[
i
].
getName
().
substring
(
pos
+
1
).
toLowerCase
();
if
(
extName
.
equals
(
"js"
)
||
extName
.
equals
(
"html"
)
||
extName
.
equals
(
"jsp"
))
{
System
.
out
.
println
(
"文件:"
+
files
[
i
].
getName
());
if
(
alls
.
get
(
dirName
)
!=
null
)
{
List
<
FileType
>
fileBeans
=
alls
.
get
(
dirName
);
FileType
fileBean
=
new
FileType
();
fileBean
.
setFileName
(
files
[
i
].
getName
());
fileBean
.
setAddress
(
files
[
i
].
getAbsolutePath
());
fileBean
.
setSuffix
(
extName
);
fileBeans
.
add
(
fileBean
);
}
else
{
List
<
FileType
>
fileBeans
=
new
ArrayList
<>();
FileType
fileBean
=
new
FileType
();
fileBean
.
setFileName
(
files
[
i
].
getName
());
fileBean
.
setAddress
(
files
[
i
].
getAbsolutePath
());
fileBean
.
setSuffix
(
extName
);
fileBeans
.
add
(
fileBean
);
alls
.
put
(
dirName
,
fileBeans
);
// System.out.println("文件名:" + files[i].getName());
// System.out.println("文件:" + files[i].getAbsolutePath());
}
}
}
...
...
@@ -195,7 +136,9 @@ public class FileHtmlUtil {
System
.
out
.
println
(
"文件1:"
+
file
.
getPath
());
}
}
public
static
String
getFileRoutes
(
String
path
){
public
static
void
getFileRoutes
(
String
path
)
{
File
file
=
new
File
(
path
);
// 如果这个路径是文件夹
...
...
@@ -205,33 +148,37 @@ public class FileHtmlUtil {
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
// 如果还是文件夹 递归获取里面的文件 文件夹
if
(
files
[
i
].
isDirectory
())
{
if
(!
files
[
i
].
getName
().
equalsIgnoreCase
(
"img"
)
||!
files
[
i
].
getName
().
equalsIgnoreCase
(
"css"
)
||!
files
[
i
].
getName
().
equalsIgnoreCase
(
"node_modules"
)){
if
(
files
[
i
].
getName
().
contains
(
"angular"
)){
return
"angular"
;
}
if
(
files
[
i
].
getName
().
contains
(
"vue"
)){
return
"vue"
;
if
(
files
[
i
].
getName
().
contains
(
"img"
)
||
files
[
i
].
getName
().
contains
(
"css"
)
||
files
[
i
].
getName
().
contains
(
"node_modules"
))
{
continue
;
}
else
{
if
(
files
[
i
].
getName
().
contains
(
"angular"
))
{
angularNum
++;
}
// System.out.println("文件夹:"+files[i].getName());
getFileRoutes
(
files
[
i
].
getPath
());
}
}
else
{
// System.out.println("文件:"+files[i].getName());
int
pos
=
files
[
i
].
getName
().
lastIndexOf
(
"."
);
String
extName
=
files
[
i
].
getName
().
substring
(
pos
+
1
).
toLowerCase
();
if
(
extName
.
equals
(
"vue"
)){
return
"vue"
;
}
if
(
extName
.
equals
(
"jsp"
)){
return
"jsp"
;
if
(
extName
.
equals
(
"vue"
))
{
vueNum
++;
}
else
if
(
extName
.
equals
(
"jsp"
))
{
jspNum
++;
}
else
if
(
extName
.
equals
(
"html"
))
{
count
++;
}
else
if
(
extName
.
equals
(
"js"
))
{
jsNum
++;
}
}
}
}
else
{
System
.
out
.
println
(
"文件:"
+
file
.
getPath
());
}
return
null
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论