Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
auto-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
auto-test
Commits
7dbc4c6b
提交
7dbc4c6b
authored
3月 26, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
遍历文件
上级
f716a04c
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
416 行增加
和
33 行删除
+416
-33
AutotestApplication.java
src/main/java/com/zjty/autotest/AutotestApplication.java
+2
-0
ProjectInitRun.java
src/main/java/com/zjty/autotest/config/ProjectInitRun.java
+1
-6
AutoResultSetDao.java
src/main/java/com/zjty/autotest/dao/AutoResultSetDao.java
+3
-0
TestTask.java
src/main/java/com/zjty/autotest/mq/TestTask.java
+144
-0
TestReportService.java
...ain/java/com/zjty/autotest/service/TestReportService.java
+1
-1
AsyncServiceImpl.java
...java/com/zjty/autotest/service/impl/AsyncServiceImpl.java
+2
-0
AutoResultSetServiceImpl.java
.../zjty/autotest/service/impl/AutoResultSetServiceImpl.java
+7
-4
TestReportServiceImpl.java
...com/zjty/autotest/service/impl/TestReportServiceImpl.java
+8
-2
UploadCodeServiceImpl.java
...com/zjty/autotest/service/impl/UploadCodeServiceImpl.java
+20
-9
FileHtmlUtil.java
src/main/java/com/zjty/autotest/util/FileHtmlUtil.java
+215
-5
FileUtil.java
src/main/java/com/zjty/autotest/util/FileUtil.java
+3
-0
UnZipRarUtil.java
src/main/java/com/zjty/autotest/util/UnZipRarUtil.java
+4
-2
application.properties
src/main/resources/application.properties
+6
-4
没有找到文件。
src/main/java/com/zjty/autotest/AutotestApplication.java
浏览文件 @
7dbc4c6b
...
...
@@ -5,10 +5,12 @@ import com.zjty.autotest.util.IdWorker;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
javax.annotation.PostConstruct
;
@SpringBootApplication
@EnableScheduling
public
class
AutotestApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
AutotestApplication
.
class
,
args
);
...
...
src/main/java/com/zjty/autotest/config/ProjectInitRun.java
浏览文件 @
7dbc4c6b
...
...
@@ -10,13 +10,8 @@ import org.springframework.stereotype.Component;
@Component
public
class
ProjectInitRun
implements
CommandLineRunner
{
@Autowired
private
AutoResultSetDao
autoResultSetDao
;
@Autowired
private
TestReportService
testReportService
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
PushBlockQueue
queue
=
new
PushBlockQueue
(
autoResultSetDao
,
testReportService
);
queue
.
start
();
}
}
src/main/java/com/zjty/autotest/dao/AutoResultSetDao.java
浏览文件 @
7dbc4c6b
...
...
@@ -6,8 +6,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
javax.transaction.Transactional
;
public
interface
AutoResultSetDao
extends
JpaRepository
<
AutoResultSet
,
String
>,
JpaSpecificationExecutor
<
AutoResultSet
>
{
@Modifying
@Transactional
@Query
(
value
=
"update auto_result_set set status=1 where id=:id"
,
nativeQuery
=
true
)
int
updateStatus
(
String
id
);
}
src/main/java/com/zjty/autotest/mq/TestTask.java
0 → 100644
浏览文件 @
7dbc4c6b
package
com
.
zjty
.
autotest
.
mq
;
import
com.alibaba.fastjson.JSON
;
import
com.zjty.autotest.dao.AutoResultSetDao
;
import
com.zjty.autotest.pojo.sjq.*
;
import
com.zjty.autotest.service.AutoResultSetService
;
import
com.zjty.autotest.service.TestReportService
;
import
com.zjty.autotest.util.FileHtmlUtil
;
import
com.zjty.autotest.util.IdWorker
;
import
com.zjty.autotest.util.UnZipRarUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
java.util.*
;
@Component
@Slf4j
public
class
TestTask
{
@Autowired
private
AutoResultSetService
autoResultSetService
;
@Autowired
private
TestReportService
testReportService
;
@Scheduled
(
cron
=
"0/1 * * * * ?"
)
@Async
(
"asyncServiceExecutor"
)
public
void
getMessage
(){
String
take
=
QueueManager
.
take
();
log
.
info
(
"获取到消息:{}"
,
take
);
if
(!
StringUtils
.
isEmpty
(
take
)){
doBusiness
(
take
);
}
}
private
void
doBusiness
(
String
id
)
{
TestChannel
testChannel
=
(
TestChannel
)
CacheManager
.
getCache
(
id
);
if
(
testChannel
!=
null
)
{
log
.
info
(
"testChannel不为空:{}"
,
testChannel
);
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
);
//调用黄承天代码
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]*)+"
));
}
}
}
}
for
(
String
allRouter
:
allRouters
)
{
System
.
out
.
println
(
"路由:"
+
allRouter
);
}
FileHtmlUtil
.
clearAll
();
//获取前端代码中得网页路由地址
//比对黄承天代码中访问得地址和路由地址,黄承天是否访问全了。
}
System
.
out
.
println
(
"修改状态"
);
//改变报告状态
String
out
=
JSON
.
toJSONString
(
evaReport
);
System
.
out
.
println
(
id
);
TestReport
testReport
=
new
TestReport
();
testReport
.
setResultId
(
id
);
testReport
.
setOutReport
(
out
);
testReportService
.
update
(
testReport
);
autoResultSetService
.
updateByid
(
id
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/main/java/com/zjty/autotest/service/TestReportService.java
浏览文件 @
7dbc4c6b
...
...
@@ -11,7 +11,7 @@ public interface TestReportService{
ResponseResult
deleteByResultId
(
String
id
);
ResponseResult
save
(
TestReport
testReport
);
ResponseResult
addInReport
(
String
id
,
String
inReport
);
void
update
(
TestReport
testReport
);
/**
* 根据id查询输入
*/
...
...
src/main/java/com/zjty/autotest/service/impl/AsyncServiceImpl.java
浏览文件 @
7dbc4c6b
...
...
@@ -11,9 +11,11 @@ import com.zjty.autotest.service.AsyncService;
import
com.zjty.autotest.service.AutoResultSetService
;
import
com.zjty.autotest.service.TestReportService
;
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
;
...
...
src/main/java/com/zjty/autotest/service/impl/AutoResultSetServiceImpl.java
浏览文件 @
7dbc4c6b
...
...
@@ -103,13 +103,16 @@ public class AutoResultSetServiceImpl implements AutoResultSetService {
autoResultSet
.
setUpdateTime
(
new
Date
());
autoResultSet
.
setStatus
(
0
);
AutoResultSet
save
=
autoResultSetDao
.
save
(
autoResultSet
);
String
in
=
JSON
.
toJSONString
(
testChannel
);
TestReport
testReport
=
new
TestReport
();
testReport
.
setResultId
(
tid
);
testReport
.
setStatus
(
0
);
testReport
.
setInputReport
(
in
);
testReportService
.
save
(
testReport
);
CacheManager
.
putCache
(
tid
,
testChannel
);
//将数据保存到队列
try
{
asyncService
.
executeAsync
(
tid
);
// PushBlockQueue pushBlockQueue=new PushBlockQueue(autoResultSetDao,testReportService);
// QueueManager.put(tid);
QueueManager
.
put
(
tid
);
return
ResponseResult
.
okResult
(
save
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/com/zjty/autotest/service/impl/TestReportServiceImpl.java
浏览文件 @
7dbc4c6b
...
...
@@ -76,7 +76,12 @@ public class TestReportServiceImpl implements TestReportService {
* @param testReport
*/
public
void
update
(
TestReport
testReport
)
{
testReportDao
.
save
(
testReport
);
TestReport
report
=
testReportDao
.
findByResultId
(
testReport
.
getResultId
());
if
(
report
!=
null
)
{
report
.
setStatus
(
1
);
report
.
setOutReport
(
testReport
.
getOutReport
());
testReportDao
.
save
(
testReport
);
}
}
/**
...
...
@@ -94,7 +99,8 @@ public class TestReportServiceImpl implements TestReportService {
System
.
out
.
println
(
testReport
);
if
(
testReport
!=
null
){
testReport
.
setId
(
idWorker
.
nextId
()+
""
);
testReport
.
setOutReport
(
testReport
.
getOutReport
());
// testReport.setOutReport(testReport.getOutReport());
testReport
.
setStatus
(
testReport
.
getStatus
());
testReport
.
setInputReport
(
testReport
.
getInputReport
());
testReport
.
setResultId
(
testReport
.
getResultId
());
testReportDao
.
save
(
testReport
);
...
...
src/main/java/com/zjty/autotest/service/impl/UploadCodeServiceImpl.java
浏览文件 @
7dbc4c6b
...
...
@@ -4,7 +4,9 @@ import com.zjty.autotest.pojo.sjq.FileBean;
import
com.zjty.autotest.pojo.sjq.common.AppHttpCodeEnum
;
import
com.zjty.autotest.pojo.sjq.common.ResponseResult
;
import
com.zjty.autotest.service.UploadCodeService
;
import
com.zjty.autotest.util.FileHtmlUtil
;
import
com.zjty.autotest.util.IdWorker
;
import
com.zjty.autotest.util.UnZipRarUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -12,14 +14,19 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
@Service
public
class
UploadCodeServiceImpl
implements
UploadCodeService
{
@Value
(
"${upload
Un
File}"
)
private
String
upload
Un
File
;
@Value
(
"${uploadFile}"
)
private
String
uploadFile
;
@Autowired
private
IdWorker
idWorker
;
@Value
(
"${uploadUnFile}"
)
private
String
uploadUnFile
;
@Override
public
ResponseResult
uploadCodeFile
(
MultipartFile
file
)
{
try
{
...
...
@@ -27,19 +34,23 @@ public class UploadCodeServiceImpl implements UploadCodeService {
return
ResponseResult
.
errorResult
(
AppHttpCodeEnum
.
File_Empty
);
}
String
fileName
=
file
.
getOriginalFilename
();
String
fileType
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
File
dest
=
new
File
(
upload
UnFile
+
"/"
+
idWorker
.
nextId
()+
"/"
+
fileName
);
//
String fileType = fileName.substring(fileName.lastIndexOf("."));
File
dest
=
new
File
(
upload
File
+
File
.
separator
+
idWorker
.
nextId
()+
File
.
separator
+
fileName
);
if
(!
dest
.
getParentFile
().
exists
())
{
dest
.
getParentFile
().
mkdirs
();
}
file
.
transferTo
(
dest
);
FileBean
bean
=
new
FileBean
(
dest
.
getAbsolutePath
(),
fileType
);
String
toUrl
=
uploadUnFile
+
File
.
separator
+
idWorker
.
nextId
()+
File
.
separator
+
fileName
;
String
s
=
UnZipRarUtil
.
zipRarToFile
(
fileName
,
dest
.
getPath
(),
toUrl
);
FileBean
bean
=
new
FileBean
(
s
,
fileName
);
return
ResponseResult
.
okResult
(
bean
);
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ResponseResult
.
errorResult
(
AppHttpCodeEnum
.
File_UPLOAD_ERROR
,
e
.
getMessage
());
}
return
ResponseResult
.
errorResult
(
AppHttpCodeEnum
.
File_UPLOAD_ERROR
);
}
}
src/main/java/com/zjty/autotest/util/FileHtmlUtil.java
浏览文件 @
7dbc4c6b
package
com
.
zjty
.
autotest
.
util
;
import
com.zjty.autotest.pojo.sjq.FileBean
;
import
org.springframework.util.StringUtils
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStreamReader
;
import
java.util.*
;
import
java.util.regex.Matcher
;
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
HashMap
<
String
,
List
<
FileBean
>>
getAlls
(){
return
alls
;
}
public
static
void
clearAll
(){
if
(
routes
!=
null
)
{
routes
.
clear
();
System
.
out
.
println
(
"routes:="
+
routes
);
}
if
(
urls
!=
null
)
{
urls
.
clear
();
System
.
out
.
println
(
"urls:="
+
urls
);
}
if
(
alls
!=
null
)
{
alls
.
clear
();
System
.
out
.
println
(
"alls:="
+
alls
);
}
}
public
static
List
<
String
>
readTxtFile
(
String
filePath
,
String
pattern
)
{
Pattern
p
;
Matcher
m
;
Set
<
String
>
set
=
new
HashSet
<
String
>();
try
{
String
encoding
=
"UTF-8"
;
File
file
=
new
File
(
filePath
);
if
(
file
.
isFile
()
&&
file
.
exists
())
{
// 判断文件是否存在
InputStreamReader
read
=
new
InputStreamReader
(
new
FileInputStream
(
file
),
encoding
);
// 考虑到编码格式
BufferedReader
bufferedReader
=
new
BufferedReader
(
read
);
String
lineTxt
=
null
;
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
()){
String
pp
=
m
.
group
().
substring
(
0
,
m
.
group
().
length
());
if
(!
pp
.
equals
(
"//"
))
{
set
.
add
(
pp
.
toLowerCase
());
}
}
List
<
String
>
collect
=
set
.
stream
().
collect
(
Collectors
.
toList
());
read
.
close
();
return
collect
;
}
else
{
System
.
out
.
println
(
"找不到指定的文件"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"读取文件内容出错"
);
e
.
printStackTrace
();
}
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
getFileRoutes
(
String
path
){
File
file
=
new
File
(
path
);
// 如果这个路径是文件夹
if
(
file
.
isDirectory
())
{
...
...
@@ -13,16 +161,78 @@ public class FileHtmlUtil {
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
// 如果还是文件夹 递归获取里面的文件 文件夹
if
(
files
[
i
].
isDirectory
())
{
System
.
out
.
println
(
"目录:"
+
files
[
i
].
getPath
());
getFileRoutes
(
files
[
i
].
getPath
());
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());
getFiles
(
files
[
i
].
getPath
(),
files
[
i
].
getName
());
}
}
else
{
System
.
out
.
println
(
"文件名:"
+
files
[
i
].
getName
());
System
.
out
.
println
(
"文件:"
+
files
[
i
].
getPath
());
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
());
fileBeans
.
add
(
fileBean
);
alls
.
put
(
dirName
,
fileBeans
);
// System.out.println("文件名:" + files[i].getName());
// System.out.println("文件:" + files[i].getAbsolutePath());
}
}
}
}
}
else
{
System
.
out
.
println
(
"文件1:"
+
file
.
getPath
());
}
}
public
static
String
getFileRoutes
(
String
path
){
File
file
=
new
File
(
path
);
// 如果这个路径是文件夹
if
(
file
.
isDirectory
())
{
// 获取路径下的所有文件
File
[]
files
=
file
.
listFiles
();
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"
;
}
getFileRoutes
(
files
[
i
].
getPath
());
}
}
else
{
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"
;
}
}
}
}
else
{
System
.
out
.
println
(
"文件:"
+
file
.
getPath
());
}
return
null
;
}
}
src/main/java/com/zjty/autotest/util/FileUtil.java
浏览文件 @
7dbc4c6b
...
...
@@ -18,6 +18,9 @@ public class FileUtil {
public
static
void
output
(
byte
[]
bytes
,
String
path
)
{
File
file
=
new
File
(
path
);
if
(!
file
.
getParentFile
().
exists
()){
file
.
getParentFile
().
mkdirs
();
}
try
{
OutputStream
output
=
new
FileOutputStream
(
file
);
output
.
write
(
bytes
);
...
...
src/main/java/com/zjty/autotest/util/UnZipRarUtil.java
浏览文件 @
7dbc4c6b
...
...
@@ -26,13 +26,15 @@ public class UnZipRarUtil {
descFile
.
mkdirs
();
}
//解压目的文件
String
descDir
=
toFolder
+
"\\"
+
fileName
.
substring
(
0
,
pos
)
+
"\\"
;
String
descDir
=
toFolder
+
File
.
separator
+
fileName
.
substring
(
0
,
pos
)
+
File
.
separator
;
//开始解压zip
if
(
extName
.
equals
(
"zip"
))
{
UnZipRarUtil
.
unZipFiles
(
pushFile
,
descDir
);
}
else
if
(
extName
.
equals
(
"rar"
))
{
//开始解压rar
UnZipRarUtil
.
unRarFile
(
pushFile
.
getAbsolutePath
(),
descDir
);
}
else
{
return
sourceFile
;
}
return
descDir
;
...
...
@@ -105,7 +107,7 @@ public class UnZipRarUtil {
continue
;
}
//输出文件路径信息
System
.
out
.
println
(
outPath
);
//
System.out.println(outPath);
OutputStream
out
=
new
FileOutputStream
(
outPath
);
byte
[]
buf1
=
new
byte
[
1024
];
...
...
src/main/resources/application.properties
浏览文件 @
7dbc4c6b
...
...
@@ -10,15 +10,16 @@ spring.jpa.show-sql=false
spring.resources.static-locations
=
classpath:/adapter/
uploadUnFile
=
E:/opt/auto/test/zr/
uploadFile
=
E:/opt/auto/test/zr/
uploadUnFile
=
E:/opt/auto/test/un/
# spring-http-\u6587\u4EF6\u4E0A\u4F20\u76F8\u5173\u914D\u7F6E
spring.servlet.multipart.max-file-size
=
500MB
spring.servlet.multipart.max-request-size
=
500MB
# Selenium
每次点击操作后的等待时间(毫秒)(0为不等待)
# Selenium
\u00FF\uFFFD\u03B5\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0135\u0234\uFFFD\u02B1\uFFFD\u48E8\uFFFD\uFFFD\uFFFD\uB8E9\uFFFD\uFFFD0\u03AA\uFFFD\uFFFD\uFFFD\u0234\uFFFD\uFFFD\uFFFD
selenium.executor.wait-after-click
=
0
#
提供截图URL的地址前缀(ip)
#
\uFFFD\u1E69\uFFFD\uFFFD\u037CURL\uFFFD\u0135\uFFFD\u05B7\u01F0\u05FA\uFFFD\uFFFDip\uFFFD\uFFFD
selenium.executor.screenshot.url-host
=
localhost
#
提供截图URL的地址前缀(ip)
#
\uFFFD\u1E69\uFFFD\uFFFD\u037CURL\uFFFD\u0135\uFFFD\u05B7\u01F0\u05FA\uFFFD\uFFFDip\uFFFD\uFFFD
selenium.executor.screenshot.url-port
=
13500
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论