Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fangyeqing
/
xkl-interface-example-all
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
zhaoyue
8 years ago
Commit
b5040eaceccbb0635a14e07b16e62a9e2254a233
1 parent
3c0aca86
Can read local report
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
3 deletions
docs/uspih/xkl-interface-test For USPIH.docx
push.sh
src/test/java/com/xkl/upsoft/Data.java
src/test/java/com/xkl/upsoft/ReportTest.java
docs/uspih/xkl-interface-test For USPIH.docx
View file @
b5040ea
No preview for this file type
push.sh
View file @
b5040ea
git pull
git add --all src/
*
#
git add --all src/*
git add --all lib/
*
git add push.sh
git add pom.xml
git commit -m
"
Add admin info tes
t"
git commit -m
"
Can read local repor
t"
git push origin master
git status
git pull
...
...
src/test/java/com/xkl/upsoft/Data.java
View file @
b5040ea
...
...
@@ -4,6 +4,10 @@ package com.xkl.upsoft;
import
org.json.JSONObject
;
import
org.junit.Test
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStreamReader
;
import
java.text.DecimalFormat
;
/**
...
...
@@ -21,6 +25,31 @@ public class Data {
data
.
generateJsonFormatReport
();
}
public
static
String
readTxtFile
(
String
filePath
)
{
String
line
=
""
;
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
;
while
((
lineTxt
=
bufferedReader
.
readLine
())
!=
null
&&
!
lineTxt
.
equals
(
""
))
{
line
=
lineTxt
;
break
;
}
read
.
close
();
}
else
{
System
.
out
.
println
(
"找不到指定的文件"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"读取文件内容出错"
);
e
.
printStackTrace
();
}
return
line
;
}
@Test
public
void
generateJsonFormatReport
()
{
JSONObject
report
=
new
JSONObject
();
...
...
src/test/java/com/xkl/upsoft/ReportTest.java
View file @
b5040ea
...
...
@@ -36,7 +36,11 @@ public class ReportTest {
public
void
testAddReport
()
{
String
token
=
loginAndGetToken
(
Data
.
ADMIN_ACCOUNT
,
Data
.
ADMIN_PWD
);
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"json_report"
,
Data
.
AMP_REPORT
);
// 程序自动生成json报告。
// String report =Data.AMP_REPORT;
// 从本地加载json报告。
String
report
=
Data
.
readTxtFile
(
"C:\\Users\\zhaoyue\\Desktop\\report.txt"
);
params
.
put
(
"json_report"
,
report
);
String
response
=
HttpTools
.
requestByMapWithToken
(
URL_REPORT
,
"POST"
,
params
,
token
);
System
.
out
.
println
(
"add report success:"
+
response
);
}
...
...
Please
register
or
login
to post a comment