Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nwn_Api_auto_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuai
nwn_Api_auto_test
Commits
8e1eb2de
Commit
8e1eb2de
authored
Feb 22, 2019
by
wff66504
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2019-0222
parent
702705cd
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1142 additions
and
22 deletions
+1142
-22
RequestDataUtils.java
...pi_auto_test/src/com/offcn/TestUnti/RequestDataUtils.java
+353
-4
baseToImg.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/baseToImg.java
+123
-0
delOutline.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/delOutline.java
+214
-0
editPackage.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/editPackage.java
+204
-0
getPackageTree.java
...pi_auto_test/src/com/offcn/api/nwn/ht/getPackageTree.java
+127
-0
code.java
nwn_Api_auto_test/src/com/offcn/api/nwn/process/code.java
+8
-3
packagelist.java
..._auto_test/src/com/offcn/api/nwn/process/packagelist.java
+3
-0
MyRequest.java
nwn_Api_auto_test/src/com/offcn/system/MyRequest.java
+71
-0
APITest_nwn.java
nwn_Api_auto_test/src/com/offcn/test/APITest_nwn.java
+2
-2
MakeTestCases.java
nwn_Api_auto_test/src/makeTestCase/MakeTestCases.java
+20
-13
class.properties
nwn_Api_auto_test/src/resources/class.properties
+1
-0
system.xml
nwn_Api_auto_test/src/resources/system.xml
+16
-0
No files found.
nwn_Api_auto_test/src/com/offcn/TestUnti/RequestDataUtils.java
View file @
8e1eb2de
...
@@ -11,11 +11,13 @@ import io.restassured.path.json.JsonPath;
...
@@ -11,11 +11,13 @@ import io.restassured.path.json.JsonPath;
import
io.restassured.response.Response
;
import
io.restassured.response.Response
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
com.offcn.process.BasicsGM
;
import
com.offcn.process.BasicsGM
;
import
com.offcn.process.XYZB
;
import
com.offcn.process.XYZB
;
import
com.offcn.system.MyRequest
;
import
com.offcn.system.system
;
import
com.offcn.system.system
;
import
static
io
.
restassured
.
http
.
ContentType
.
JSON
;
import
static
io
.
restassured
.
http
.
ContentType
.
JSON
;
...
@@ -48,6 +50,281 @@ public class RequestDataUtils {
...
@@ -48,6 +50,281 @@ public class RequestDataUtils {
return
ra
;
return
ra
;
}
}
public
static
Response
RestAssuredApi
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
){
if
(
"get"
.
equals
(
myRequest
.
getRequest
())){
return
Get
(
data
,
myRequest
);
}
else
if
(
"post"
.
equals
(
myRequest
.
getRequest
())){
return
PostAll
(
data
,
myRequest
);
}
else
if
(
"put"
.
equals
(
myRequest
.
getRequest
())){
return
Put
(
data
,
myRequest
);
}
else
if
(
"del"
.
equals
(
myRequest
.
getRequest
())){
return
Del
(
data
,
myRequest
);
}
else
{
return
null
;
}
}
public
static
Response
PostAll
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
){
if
(
myRequest
.
getFormParameter
()!=
null
){
if
(
myRequest
.
getFile
()!=
null
){
return
Post_file
(
data
,
myRequest
);
}
else
{
return
Post_form_data
(
data
,
myRequest
);
}
}
else
if
(
myRequest
.
getParameter
()!=
null
){
return
Post_JSON
(
data
,
myRequest
);
}
return
null
;
}
public
static
Response
Post_file
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
)
{
// 设置参数格式
String
Parameter
=
(
String
)
data
.
get
(
"parameter"
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=
(
com
.
offcn
.
system
.
system
)
(
BasicsGM
.
map
.
get
(
system
));
String
path
=
tem
.
getRM_URI
()+
tem
.
getRM_port
()+
tem
.
getRM_basePath
()+
myRequest
.
getUrl
();
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()
+
","
+
data
.
get
(
"TCNO"
).
toString
()+
","
+
path
+
",Parameter="
+
Parameter
);
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
)
{
try
{
state
++;
File
filen
=
new
File
(
"out/"
+
myRequest
.
getFile
());
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
params
(
myRequest
.
getFormParameter
()).
when
().
multiPart
(
"image"
,
filen
)
.
post
(
myRequest
.
getUrl
()).
thenReturn
();
if
(!
"200"
.
equals
(
re
.
getStatusCode
()+
""
))
{
Log
.
logError
(
"请求返回:"
+
re
.
getStatusCode
()+
",第"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
public
static
Response
Post_form_data
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
)
{
//设置参数格式
String
parameter
=
MapUtil
.
getParameter
(
data
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
String
path
=
tem
.
getRM_URI
()+
tem
.
getRM_port
()+
tem
.
getRM_basePath
()+
myRequest
.
getUrl
();
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
","
+
path
+
",Parameter="
+
parameter
);
// 设置参数格式
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
)
{
try
{
state
++;
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
params
(
myRequest
.
getFormParameter
())
.
when
()
.
post
(
myRequest
.
getUrl
())
.
thenReturn
();
JsonPath
jp
=
re
.
body
().
jsonPath
();
if
(
"500"
.
equals
(
jp
.
getString
(
"status"
)))
{
Log
.
logError
(
"请求返回500,"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
//不带token的post请求
@SuppressWarnings
(
"static-access"
)
public
static
Response
Post_JSON
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
)
{
// 设置参数格式
String
Parameter
=
(
String
)
data
.
get
(
"parameter"
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=
(
com
.
offcn
.
system
.
system
)
(
BasicsGM
.
map
.
get
(
system
));
String
path
=
tem
.
getRM_URI
()+
tem
.
getRM_port
()+
tem
.
getRM_basePath
()+
myRequest
.
getUrl
();
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()
+
","
+
data
.
get
(
"TCNO"
).
toString
()
+
","
+
path
+
",Parameter="
+
Parameter
);
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
)
{
try
{
state
++;
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
contentType
(
JSON
).
body
(
"{"
+
Parameter
+
"}"
).
when
()
.
post
(
myRequest
.
getUrl
()).
thenReturn
();
if
(!
"200"
.
equals
(
re
.
getStatusCode
()+
""
))
{
Log
.
logError
(
"请求返回,"
+
re
.
getStatusCode
()
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
@SuppressWarnings
(
"deprecation"
)
public
static
Response
Put
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
)
{
//设置参数格式
String
parameter
=
MapUtil
.
getParameter
(
data
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
String
path
=
tem
.
getRM_URI
()+
tem
.
getRM_port
()+
tem
.
getRM_basePath
()+
myRequest
.
getUrl
();
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
","
+
path
+
",Parameter="
+
parameter
);
// 设置参数格式
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
)
{
try
{
state
++;
re
=
rdu
.
getRMEnv
(
tem
).
given
().
config
(
RestAssured
.
config
()
.
encoderConfig
(
EncoderConfig
.
encoderConfig
()
.
encodeContentTypeAs
(
"x-www-form-urlencoded"
,
ContentType
.
ANY
)
.
defaultContentCharset
(
"utf-8"
)))
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
formParameters
(
myRequest
.
getFormParameter
())
.
when
().
put
(
myRequest
.
getUrl
()).
thenReturn
();
JsonPath
jp
=
re
.
body
().
jsonPath
();
if
(
"500"
.
equals
(
jp
.
getString
(
"status"
)))
{
Log
.
logError
(
"请求返回500,"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
public
static
Response
Del
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
)
{
//设置参数格式
String
parameter
=
MapUtil
.
getParameter
(
data
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
String
path
=
tem
.
getRM_URI
()+
tem
.
getRM_port
()+
tem
.
getRM_basePath
()+
myRequest
.
getUrl
();
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
","
+
path
+
",Parameter="
+
parameter
);
// 设置参数格式
Log
.
logInfo
(
"serviceURL="
+
myRequest
.
getUrl
()
+
",Parameter="
+
myRequest
.
getParameter
());
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
)
{
try
{
state
++;
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
when
().
delete
(
myRequest
.
getUrl
()).
thenReturn
();
JsonPath
jp
=
re
.
body
().
jsonPath
();
if
(
"500"
.
equals
(
jp
.
getString
(
"status"
)))
{
Log
.
logError
(
"请求返回500,"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
@SuppressWarnings
(
"static-access"
)
public
static
Response
Get
(
HashMap
<
String
,
Object
>
data
,
MyRequest
myRequest
)
{
//设置参数格式
String
parameter
=
MapUtil
.
getParameter
(
data
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
String
path
=
tem
.
getRM_URI
()+
tem
.
getRM_port
()+
tem
.
getRM_basePath
()+
myRequest
.
getUrl
();
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
","
+
path
+
",Parameter="
+
parameter
);
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
3
){
try
{
state
++;
if
(
parameter
!=
null
&&
!
""
.
equals
(
parameter
))
{
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
get
(
myRequest
.
getUrl
()
+
"?"
+
parameter
).
andReturn
();
}
else
{
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
headers
(
myRequest
.
getHeaders
()!=
null
?
myRequest
.
getHeaders
():
new
HashMap
<
String
,
String
>())
.
cookies
(
myRequest
.
getCookies
()!=
null
?
myRequest
.
getCookies
():
new
HashMap
<
String
,
String
>())
.
get
(
myRequest
.
getUrl
()).
andReturn
();
}
if
(!
"200"
.
equals
(
re
.
statusCode
()+
""
)){
Log
.
logError
(
"请求返回"
+
re
.
statusCode
()+
"次。"
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
//不带token的post请求
//不带token的post请求
public
static
Response
Post_headers
(
HashMap
<
String
,
Object
>
data
,
String
serviceURL
,
String
zgl_clienttype
)
{
public
static
Response
Post_headers
(
HashMap
<
String
,
Object
>
data
,
String
serviceURL
,
String
zgl_clienttype
)
{
// 设置参数格式
// 设置参数格式
...
@@ -331,6 +608,43 @@ public class RequestDataUtils {
...
@@ -331,6 +608,43 @@ public class RequestDataUtils {
return
re
;
return
re
;
}
}
//需要添加token的post,json请求
@SuppressWarnings
(
"static-access"
)
public
static
Response
Post_file2
(
HashMap
<
String
,
Object
>
data
,
String
serviceURL
,
String
token
,
String
file
,
String
filename
,
Map
<
String
,
String
>
jsonAsMap
)
{
// 设置参数格式
String
Parameter
=
(
String
)
data
.
get
(
"parameter"
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=
(
com
.
offcn
.
system
.
system
)
(
BasicsGM
.
map
.
get
(
system
));
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()
+
","
+
data
.
get
(
"TCNO"
).
toString
()
+
",Parameter="
+
Parameter
);
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
)
{
try
{
state
++;
File
filen
=
new
File
(
"out/"
+
filename
);
// re = rdu.getRMEnv(tem).given().cookie("laravel_session", XYZB.laravel_session).when().get("http://live.offcncloud.com/web/admin").thenReturn();
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
header
(
"Authorization"
,
token
)
.
params
(
jsonAsMap
).
when
().
multiPart
(
file
,
filen
)
.
post
(
serviceURL
).
thenReturn
();
// System.out.println(re.asString());
if
(!
"200"
.
equals
(
re
.
getStatusCode
()+
""
))
{
Log
.
logError
(
"请求返回:"
+
re
.
getStatusCode
()+
",第"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
//发送get请求返回整个响应结果
//发送get请求返回整个响应结果
@SuppressWarnings
(
"static-access"
)
@SuppressWarnings
(
"static-access"
)
...
@@ -370,6 +684,43 @@ public class RequestDataUtils {
...
@@ -370,6 +684,43 @@ public class RequestDataUtils {
return
re
;
return
re
;
}
}
//发送get请求返回整个响应结果
@SuppressWarnings
(
"static-access"
)
public
static
Response
Get_token_all
(
HashMap
<
String
,
Object
>
data
,
String
serviceURL
,
String
token
)
{
//设置参数格式
String
parameter
=
MapUtil
.
getParameter
(
data
);
String
system
=
MapUtil
.
getValue
(
"system"
,
data
);
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
",Parameter="
+
parameter
);
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
3
){
try
{
state
++;
if
(
parameter
!=
null
&&
!
""
.
equals
(
parameter
))
{
re
=
rdu
.
getRMEnv
(
tem
).
given
().
header
(
"Authorization"
,
token
).
get
(
serviceURL
+
"?"
+
parameter
).
andReturn
();
}
else
{
re
=
rdu
.
getRMEnv
(
tem
).
given
().
header
(
"Authorization"
,
token
).
get
(
serviceURL
).
andReturn
();
}
if
(!
"200"
.
equals
(
re
.
statusCode
()+
""
)){
Log
.
logError
(
"请求返回"
+
re
.
statusCode
()+
"次。"
);
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
Log
.
logError
(
"请求超时,"
+
state
+
"次。"
);
}
}
return
re
;
}
//发送get请求返回整个响应结果
//发送get请求返回整个响应结果
@SuppressWarnings
(
"static-access"
)
@SuppressWarnings
(
"static-access"
)
...
@@ -681,17 +1032,15 @@ public class RequestDataUtils {
...
@@ -681,17 +1032,15 @@ public class RequestDataUtils {
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
com
.
offcn
.
system
.
system
tem
=(
com
.
offcn
.
system
.
system
)(
BasicsGM
.
map
.
get
(
system
));
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
parameter
=
parameter
.
substring
(
1
,
parameter
.
length
()-
1
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
",Parameter="
+
parameter
);
Log
.
logInfo
(
data
.
get
(
"Description"
).
toString
()+
","
+
data
.
get
(
"TCNO"
).
toString
()+
",Parameter="
+
parameter
);
int
state
=
0
;
int
state
=
0
;
Response
re
=
null
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
RequestDataUtils
rdu
=
new
RequestDataUtils
();
while
(
state
<
5
){
while
(
state
<
5
){
try
{
try
{
state
++;
state
++;
if
(
parameter
!=
null
&&
!
""
.
equals
(
parameter
))
{
if
(
parameter
!=
null
&&
!
""
.
equals
(
parameter
))
{
re
=
rdu
.
getRMEnv
(
tem
).
given
()
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
cookie
(
cookie1Name
,
cookie1value
)
.
cookie
(
cookie1Name
,
cookie1value
)
...
@@ -817,7 +1166,7 @@ public class RequestDataUtils {
...
@@ -817,7 +1166,7 @@ public class RequestDataUtils {
while
(
state
<
5
)
{
while
(
state
<
5
)
{
try
{
try
{
state
++;
state
++;
re
=
rdu
.
getRMEnv
(
tem
).
given
()
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
header
(
"Authorization"
,
token
)
.
params
(
jsonAsMap
)
.
params
(
jsonAsMap
)
.
when
()
.
when
()
.
post
(
serviceURL
)
.
post
(
serviceURL
)
...
...
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/baseToImg.java
0 → 100644
View file @
8e1eb2de
package
com
.
offcn
.
api
.
nwn
.
ht
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.NWN
;
import
com.offcn.system.MyRequest
;
/**
* 55.base64位转图片
*
* @author wufeifei
*
*/
public
class
baseToImg
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
base_code
;
//学习包id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
base_code
=
MapUtil
.
getParameter_get
(
parameter
,
"base_code"
).
trim
();
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookies
=
new
HashMap
<
String
,
String
>();
cookies
.
put
(
"admin_31_encode"
,
admin_31_encode
);
cookies
.
put
(
"PHPSESSID"
,
PHPSESSID
);
cookies
.
put
(
"admin_login_ssid"
,
admin_login_ssid
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setCookies
(
cookies
);
myRequest
.
setRequest
(
Request
);
myRequest
.
setParameter
(
parameter
);;
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"更新成功"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/delOutline.java
0 → 100644
View file @
8e1eb2de
package
com
.
offcn
.
api
.
nwn
.
ht
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.NWN
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 删除层级或组件
*
* @author wufeifei
*
*/
public
class
delOutline
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
template_id
;
//母版id
public
String
module_type
;
//组件类型
public
String
id_db
;
//组件id_db
public
String
id
;
//组件id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
String
sql
=
"SELECT id FROM n_template_menu_35 WHERE template_id = 35 AND level_name = \"飞飞飞\" "
+
"AND deleted_at is NULL ORDER BY id DESC LIMIT 1"
;
//
ResultSet
rs_bankcard
;
try
{
rs_bankcard
=
this
.
sqlFromDB_template
(
sql
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
id_db
=
rs_bankcard
.
getString
(
"id"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"id"
);
System
.
out
.
println
(
id
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
template_id
=
MapUtil
.
getParameter_get
(
parameter
,
"template_id"
).
trim
();
module_type
=
MapUtil
.
getParameter_get
(
parameter
,
"module_type"
).
trim
();
id
=
MapUtil
.
getParameter_get
(
parameter
,
"id"
).
trim
();
if
((!
template_id
.
equals
(
""
))
&&
template_id
.
equals
(
"code"
))
{
template_id
=
"35"
;
parameter
=
parameter
.
replace
(
"template_id=code"
,
"template_id="
+
template_id
);
}
if
((!
module_type
.
equals
(
""
))
&&
module_type
.
equals
(
"code"
))
{
module_type
=
"0"
;
parameter
=
parameter
.
replace
(
"module_type=code"
,
"module_type="
+
module_type
);
}
if
((!
id
.
equals
(
""
))
&&
id
.
equals
(
"code"
))
{
parameter
=
parameter
.
replace
(
"id=code"
,
"id="
+
id_db
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
// Response re = RequestDataUtils.Get_two_cookie2(data, Url,"admin_31_encode",admin_31_encode,"PHPSESSID",PHPSESSID);
// return re;
Map
<
String
,
String
>
cookies
=
new
HashMap
<
String
,
String
>();
cookies
.
put
(
"admin_31_encode"
,
admin_31_encode
);
cookies
.
put
(
"PHPSESSID"
,
PHPSESSID
);
cookies
.
put
(
"admin_login_ssid"
,
admin_login_ssid
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setCookies
(
cookies
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"更新成功"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
)
{
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
// remark = MapUtil.getParameter_get(parameter, "remark").trim();
// package_id = MapUtil.getParameter_get(parameter, "package_id").trim();
// intro = MapUtil.getParameter_get(parameter, "intro").trim();
// cover = MapUtil.getParameter_get(parameter, "cover").trim();
// pack_name = MapUtil.killQuotes(pack_name, "\"");
// for_year = MapUtil.killQuotes(for_year, "\"");
// product = MapUtil.killQuotes(product, "\"");
// intro = MapUtil.killQuotes(intro, "\"");
// cover = MapUtil.killQuotes(cover, "\"");
try
{
// String sql="select * from n_package where id='"+package_id+"'";
//
// ResultSet rs_bankcard = this.sqlFromDB(sql);
// rs_bankcard.last();
//
// if(rs_bankcard.getRow()>=1){
////
////
//// String atc_remark=rs_bankcard.getString("remark").equals("null ")?"null":rs_bankcard.getString("remark");
// String atc_package_id=rs_bankcard.getString("id").equals("null ")?"null":rs_bankcard.getString("id");
// String act_intro=rs_bankcard.getString("intro").equals("null ")?"null":rs_bankcard.getString("intro");
// String act_cover=rs_bankcard.getString("cover").equals("null ")?"null":rs_bankcard.getString("cover");
////
//// System.out.println("atc_remark==" + atc_remark);
// System.out.println("act_pack_name==" + atc_package_id);
// System.out.println("act_intro==" + act_intro);
// System.out.println("act_cover==" + act_cover);
// /*if(!(remark.equals(atc_remark)) && remark != null && !remark.equals("")){
// result = result && false;
// failReason = failReason + "t_exam_area info pack_name is not in DB;";
// }*/
//
// }
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify n_package info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/editPackage.java
0 → 100644
View file @
8e1eb2de
package
com
.
offcn
.
api
.
nwn
.
ht
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.NWN
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 编辑教务包
*
* @author wufeifei
*
*/
public
class
editPackage
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
remark
;
//备注
public
String
package_id
;
//学习包id
public
String
intro
;
//简介
public
String
cover
;
//封面
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
remark
=
MapUtil
.
getParameter_get
(
parameter
,
"remark"
).
trim
();
package_id
=
MapUtil
.
getParameter_get
(
parameter
,
"package_id"
).
trim
();
intro
=
MapUtil
.
getParameter_get
(
parameter
,
"intro"
).
trim
();
cover
=
MapUtil
.
getParameter_get
(
parameter
,
"cover"
).
trim
();
if
((!
package_id
.
equals
(
""
))
&&
package_id
.
equals
(
"code"
))
{
package_id
=
ListUtil
.
getListValue
(
n_package_idList
,
0
);
parameter
=
parameter
.
replace
(
"package_id=code"
,
"package_id="
+
package_id
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
// Response re = RequestDataUtils.Get_two_cookie2(data, Url,"admin_31_encode",admin_31_encode,"PHPSESSID",PHPSESSID);
// return re;
Map
<
String
,
String
>
cookies
=
new
HashMap
<
String
,
String
>();
cookies
.
put
(
"admin_31_encode"
,
admin_31_encode
);
cookies
.
put
(
"PHPSESSID"
,
PHPSESSID
);
cookies
.
put
(
"admin_login_ssid"
,
admin_login_ssid
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setCookies
(
cookies
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"更新成功"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
)
{
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
// remark = MapUtil.getParameter_get(parameter, "remark").trim();
package_id
=
MapUtil
.
getParameter_get
(
parameter
,
"package_id"
).
trim
();
intro
=
MapUtil
.
getParameter_get
(
parameter
,
"intro"
).
trim
();
cover
=
MapUtil
.
getParameter_get
(
parameter
,
"cover"
).
trim
();
// pack_name = MapUtil.killQuotes(pack_name, "\"");
// for_year = MapUtil.killQuotes(for_year, "\"");
// product = MapUtil.killQuotes(product, "\"");
// intro = MapUtil.killQuotes(intro, "\"");
// cover = MapUtil.killQuotes(cover, "\"");
try
{
String
sql
=
"select * from n_package where id='"
+
package_id
+
"'"
;
//
ResultSet
rs_bankcard
=
this
.
sqlFromDB
(
sql
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
//
//
// String atc_remark=rs_bankcard.getString("remark").equals("null ")?"null":rs_bankcard.getString("remark");
String
atc_package_id
=
rs_bankcard
.
getString
(
"id"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"id"
);
String
act_intro
=
rs_bankcard
.
getString
(
"intro"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"intro"
);
String
act_cover
=
rs_bankcard
.
getString
(
"cover"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"cover"
);
//
// System.out.println("atc_remark==" + atc_remark);
System
.
out
.
println
(
"act_pack_name=="
+
atc_package_id
);
System
.
out
.
println
(
"act_intro=="
+
act_intro
);
System
.
out
.
println
(
"act_cover=="
+
act_cover
);
/*if(!(remark.equals(atc_remark)) && remark != null && !remark.equals("")){
result = result && false;
failReason = failReason + "t_exam_area info pack_name is not in DB;";
}*/
if
(!(
package_id
.
equals
(
atc_package_id
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_exam_area info for_year is not in DB;"
;
}
if
(!(
intro
.
equals
(
act_intro
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_exam_area info intro is not in DB;"
;
}
if
(!(
cover
.
equals
(
act_cover
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_exam_area info intro is not in DB;"
;
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify n_package info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getPackageTree.java
0 → 100644
View file @
8e1eb2de
package
com
.
offcn
.
api
.
nwn
.
ht
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.NWN
;
import
com.offcn.system.MyRequest
;
/**
* 编辑教务包
*
* @author wufeifei
*
*/
public
class
getPackageTree
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
package_id
;
//学习包id
public
String
practice_id
;
//练习册id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
package_id
=
MapUtil
.
getParameter_get
(
parameter
,
"package_id"
).
trim
();
practice_id
=
MapUtil
.
getParameter_get
(
parameter
,
"practice_id"
).
trim
();
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookies
=
new
HashMap
<
String
,
String
>();
cookies
.
put
(
"admin_31_encode"
,
admin_31_encode
);
cookies
.
put
(
"PHPSESSID"
,
PHPSESSID
);
cookies
.
put
(
"admin_login_ssid"
,
admin_login_ssid
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setCookies
(
cookies
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
// Response re = RequestDataUtils.Get_two_cookie2(data, Url,"admin_31_encode",admin_31_encode,"PHPSESSID",PHPSESSID);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"更新成功"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/process/code.java
View file @
8e1eb2de
...
@@ -69,10 +69,15 @@ public class code extends NWN implements API {
...
@@ -69,10 +69,15 @@ public class code extends NWN implements API {
failReason
=
failReason
+
"custom is expected "
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
body
+
"."
;
+
body
+
"."
;
}
else
{
// admin_login_ssid=re.getCookie("admin_login_ssid");
MapUtil
.
showMap_String
(
re
.
getCookies
());
admin_login_ssid
=
re
.
getCookie
(
"admin_login_ssid"
);
admin_31_encode
=
re
.
getCookie
(
"admin_31_encode"
);
admin_31_encode
=
re
.
getCookie
(
"admin_31_encode"
);
}
else
{
System
.
out
.
println
(
re
.
asString
());
// System.out.println(MapUtil.showMap_String(re.getCookies()));
// System.out.println(re.getHeaders().toString());
// admin_login_ssid=re.getCookie("admin_login_ssid");
// admin_31_encode=re.getCookie("admin_31_encode");
}
}
}
}
...
...
nwn_Api_auto_test/src/com/offcn/api/nwn/process/packagelist.java
View file @
8e1eb2de
...
@@ -98,6 +98,9 @@ public class packagelist extends NWN implements API {
...
@@ -98,6 +98,9 @@ public class packagelist extends NWN implements API {
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"url"
)
+
"."
;
+
jp
.
getString
(
"url"
)
+
"."
;
}
else
{
}
else
{
// System.out.println(re.asString());
// System.out.println(MapUtil.showMap_String(re.getCookies()));
// System.out.println(re.getHeaders().toString());
nwn_url
=
url
;
nwn_url
=
url
;
PHPSESSID
=
re
.
getCookie
(
"PHPSESSID"
);
PHPSESSID
=
re
.
getCookie
(
"PHPSESSID"
);
}
}
...
...
nwn_Api_auto_test/src/com/offcn/system/MyRequest.java
0 → 100644
View file @
8e1eb2de
package
com
.
offcn
.
system
;
import
java.util.Map
;
public
class
MyRequest
{
private
String
Request
;
private
String
Url
;
private
Map
<
String
,
String
>
Cookies
;
private
Map
<
String
,
String
>
headers
;
private
String
Parameter
;
//json请求方式的参数
private
Map
<
String
,
String
>
formParameter
;
//form_data请求方式的参数、或file请求方式的参数
private
String
file
;
public
String
getRequest
()
{
return
Request
;
}
public
void
setRequest
(
String
request
)
{
Request
=
request
;
}
public
String
getUrl
()
{
return
Url
;
}
public
void
setUrl
(
String
url
)
{
Url
=
url
;
}
public
Map
<
String
,
String
>
getCookies
()
{
return
Cookies
;
}
public
void
setCookies
(
Map
<
String
,
String
>
cookies
)
{
Cookies
=
cookies
;
}
public
Map
<
String
,
String
>
getHeaders
()
{
return
headers
;
}
public
void
setHeaders
(
Map
<
String
,
String
>
headers
)
{
this
.
headers
=
headers
;
}
public
String
getParameter
()
{
return
Parameter
;
}
public
void
setParameter
(
String
parameter
)
{
Parameter
=
parameter
;
}
public
Map
<
String
,
String
>
getFormParameter
()
{
return
formParameter
;
}
public
void
setFormParameter
(
Map
<
String
,
String
>
formParameter
)
{
this
.
formParameter
=
formParameter
;
}
public
String
getFile
()
{
return
file
;
}
public
void
setFile
(
String
file
)
{
this
.
file
=
file
;
}
public
MyRequest
(
String
request
,
String
url
,
Map
<
String
,
String
>
cookies
,
Map
<
String
,
String
>
headers
,
String
parameter
,
Map
<
String
,
String
>
formParameter
,
String
file
)
{
super
();
Request
=
request
;
Url
=
url
;
Cookies
=
cookies
;
this
.
headers
=
headers
;
Parameter
=
parameter
;
this
.
formParameter
=
formParameter
;
this
.
file
=
file
;
}
public
MyRequest
()
{
}
}
nwn_Api_auto_test/src/com/offcn/test/APITest_nwn.java
View file @
8e1eb2de
...
@@ -113,7 +113,7 @@ public class APITest_nwn extends NWN{
...
@@ -113,7 +113,7 @@ public class APITest_nwn extends NWN{
//数据回写
//数据回写
// HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
// HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
/* SheetUtils sheet = new SheetUtils("DataAll
.xls", "Output");
SheetUtils
sheet
=
new
SheetUtils
(
"DataAllWff
.xls"
,
"Output"
);
sheet
.
writeExcel
(
sheet
.
writeExcel
(
data
.
get
(
"NO"
).
toString
(),
data
.
get
(
"NO"
).
toString
(),
data
.
get
(
"TCNO"
).
toString
()
+
"_Step"
+
data
.
get
(
"Step"
).
toString
(),
data
.
get
(
"TCNO"
).
toString
()
+
"_Step"
+
data
.
get
(
"Step"
).
toString
(),
...
@@ -127,7 +127,7 @@ public class APITest_nwn extends NWN{
...
@@ -127,7 +127,7 @@ public class APITest_nwn extends NWN{
msgORerrmsy
,
msgORerrmsy
,
result
,
result
,
time
time
);
*/
);
if
(
result
.
indexOf
(
"Fail"
)!=-
1
){
if
(
result
.
indexOf
(
"Fail"
)!=-
1
){
String
Expect1
=
data
.
get
(
"code"
)==
null
?
""
:
data
.
get
(
"code"
).
toString
();
String
Expect1
=
data
.
get
(
"code"
)==
null
?
""
:
data
.
get
(
"code"
).
toString
();
...
...
nwn_Api_auto_test/src/makeTestCase/MakeTestCases.java
View file @
8e1eb2de
...
@@ -35,11 +35,11 @@ public class MakeTestCases {
...
@@ -35,11 +35,11 @@ public class MakeTestCases {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
make
(
"TestData/CaseMake
.xls"
,
"Sheet1
"
);
make
(
"TestData/CaseMake
Wff.xls"
,
"Sheet1"
,
"get"
,
"nwngg
"
);
}
}
public
static
void
make
(
String
FilePath
,
String
SheetName
){
public
static
void
make
(
String
FilePath
,
String
SheetName
,
String
getOrPost
,
String
qudao
){
//获取用例
//获取用例
List
<
String
>
listSum
=
TestCase
(
FilePath
,
SheetName
);
List
<
String
>
listSum
=
TestCase
(
FilePath
,
SheetName
);
Set
<
String
>
set
=
new
HashSet
<
String
>();
Set
<
String
>
set
=
new
HashSet
<
String
>();
...
@@ -47,9 +47,9 @@ public class MakeTestCases {
...
@@ -47,9 +47,9 @@ public class MakeTestCases {
listSum
.
clear
();
listSum
.
clear
();
listSum
.
addAll
(
set
);
listSum
.
addAll
(
set
);
for
(
String
string
:
listSum
)
{
//
for (String string : listSum) {
System
.
out
.
println
(
string
);
//
System.out.println(string);
}
//
}
List
<
String
>
TeseName
=
TestCaseName
(
listSum
);
List
<
String
>
TeseName
=
TestCaseName
(
listSum
);
// System.out.println("用例数"+listSum.size());
// System.out.println("用例数"+listSum.size());
...
@@ -76,13 +76,20 @@ public class MakeTestCases {
...
@@ -76,13 +76,20 @@ public class MakeTestCases {
String
jieKouMing
=
apipath
[
0
];
String
jieKouMing
=
apipath
[
0
];
//生成测试用例
//生成测试用例
for
(
int
i
=
0
;
i
<
listSum
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
listSum
.
size
();
i
++){
outCase
(
i
,
leiming
,
jieKouMing
,
TeseName
.
get
(
i
),
path
,
listSum
.
get
(
i
),
name
,
"OutPage"
);
String
cases
=
listSum
.
get
(
i
);
if
(
"get"
.
equals
(
getOrPost
)){
cases
=
cases
.
replace
(
":"
,
"="
);
cases
=
cases
.
replace
(
"\""
,
""
);
cases
=
cases
.
replace
(
","
,
"&"
);
}
System
.
out
.
println
(
cases
);
outCase
(
i
,
leiming
,
jieKouMing
,
TeseName
.
get
(
i
),
path
,
cases
,
name
,
"OutPage"
,
getOrPost
,
qudao
);
}
}
}
}
//第一个参数是数量,第二个参数是接口类名,第三个参数是中文名
//第一个参数是数量,第二个参数是接口类名,第三个参数是中文名
public
static
void
outCase
(
int
i
,
String
leiming
,
String
jieKouMing
,
String
TeseName
,
String
path
,
String
cases
,
String
wenjianming
,
String
Sheet
){
public
static
void
outCase
(
int
i
,
String
leiming
,
String
jieKouMing
,
String
TeseName
,
String
path
,
String
cases
,
String
wenjianming
,
String
Sheet
,
String
getOrPost
,
String
qudao
){
Date
d
=
new
Date
();
Date
d
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
@@ -91,15 +98,15 @@ public class MakeTestCases {
...
@@ -91,15 +98,15 @@ public class MakeTestCases {
//数据回写
//数据回写
SheetUtils
sheet
=
new
SheetUtils
(
wenjianming
,
Sheet
);
SheetUtils
sheet
=
new
SheetUtils
(
wenjianming
,
Sheet
);
sheet
.
writeExcel
(
sheet
.
writeExcel
(
// s,
(
i
+
1
)+
""
,
(
i
+
1
)+
""
,
leiming
+
"_"
+
(
i
+
1
),
leiming
+
"_"
+
(
i
+
1
),
(
i
+
1
)+
""
,
(
i
+
1
)+
""
,
jieKouMing
+
"-"
+
TeseName
,
jieKouMing
+
"-"
+
TeseName
,
"nwn"
,
qudao
,
path
,
path
,
"N"
,
"N"
,
"post"
,
getOrPost
,
"200"
,
"200"
,
cases
cases
);
);
...
@@ -317,7 +324,7 @@ public class MakeTestCases {
...
@@ -317,7 +324,7 @@ public class MakeTestCases {
// System.out.println(nameList);
// System.out.println(nameList);
for
(
int
i
=
0
;
i
<
MakeTestCases
.
state
;
i
++){
for
(
int
i
=
0
;
i
<
MakeTestCases
.
state
;
i
++){
List
<
Set
<
String
>>
a
=
TestCase_N
(
"TestData/CaseMake.xls"
,
SheetList
.
get
(
i
),
nameList
.
get
(
i
));
List
<
Set
<
String
>>
a
=
TestCase_N
(
"TestData/CaseMake
Wff
.xls"
,
SheetList
.
get
(
i
),
nameList
.
get
(
i
));
listt
.
add
(
a
.
get
(
0
));
listt
.
add
(
a
.
get
(
0
));
listf
.
add
(
a
.
get
(
1
));
listf
.
add
(
a
.
get
(
1
));
}
}
...
@@ -545,7 +552,7 @@ public class MakeTestCases {
...
@@ -545,7 +552,7 @@ public class MakeTestCases {
if
(
w
!=
0
){
if
(
w
!=
0
){
linshi
=
"\""
+
name
+
"\""
+
":"
+
w
;
linshi
=
"\""
+
name
+
"\""
+
":"
+
w
;
}
else
{
}
else
{
linshi
=
"\""
+
name
+
"\""
+
":"
+
0
;
//字符串转换成int类型失败后,将字符串变为0
linshi
=
"\""
+
name
+
"\""
+
":"
+
1
;
//字符串转换成int类型失败后,将字符串变为0
// System.out.println(linshi);
// System.out.println(linshi);
}
}
}
else
if
(
"int"
.
equals
(
obj
[
j
])){
}
else
if
(
"int"
.
equals
(
obj
[
j
])){
...
...
nwn_Api_auto_test/src/resources/class.properties
View file @
8e1eb2de
...
@@ -2,6 +2,7 @@ xyzb=com.offcn.api.xyzb.
...
@@ -2,6 +2,7 @@ xyzb=com.offcn.api.xyzb.
tk
=
com.offcn.api.tk.
tk
=
com.offcn.api.tk.
nwn
=
com.offcn.api.nwn.
nwn
=
com.offcn.api.nwn.
nwn_service
=
com.offcn.api.nwn.service.
nwn_service
=
com.offcn.api.nwn.service.
nwn_ht
=
com.offcn.api.nwn.ht.
nwnht
=
com.offcn.api.nwn.
nwnht
=
com.offcn.api.nwn.
nwngg
=
com.offcn.api.nwn.
nwngg
=
com.offcn.api.nwn.
tkapp
=
com.offcn.api.tk.app
tkapp
=
com.offcn.api.tk.app
...
...
nwn_Api_auto_test/src/resources/system.xml
View file @
8e1eb2de
...
@@ -97,6 +97,22 @@
...
@@ -97,6 +97,22 @@
<sqlpwd>
Beta@
&
123
</sqlpwd>
<sqlpwd>
Beta@
&
123
</sqlpwd>
</system>
</system>
<system
name=
"nwn_ht"
>
<!-- nwn -->
<access_token_uri>
http://106.75.5.205:8082/uaa/oauth/token
</access_token_uri>
<client_id>
bestbuy-acceptance
</client_id>
<client_secret>
bestbuy-acceptance
</client_secret>
<grant_type>
client_credentials
</grant_type>
<isProduct>
false
</isProduct>
<RM_URI>
http://beta.alitest.eoffcn.com
</RM_URI>
<RM_port></RM_port>
<RM_basePath></RM_basePath>
<redis_URI>
10.10.229.48
</redis_URI>
<redis_db_index>
5
</redis_db_index>
<sqlurl>
jdbc:mysql://39.105.124.219:3312/nwn?useUnicode=true
&
characterEncoding=UTF-8
&
zeroDateTimeBehavior=convertToNull
</sqlurl>
<sqlname>
nwnBeta
</sqlname>
<sqlpwd>
Beta@
&
123
</sqlpwd>
</system>
<system
name=
"nwn_template"
>
<!-- nwn -->
<system
name=
"nwn_template"
>
<!-- nwn -->
<access_token_uri>
http://106.75.5.205:8082/uaa/oauth/token
</access_token_uri>
<access_token_uri>
http://106.75.5.205:8082/uaa/oauth/token
</access_token_uri>
<client_id>
bestbuy-acceptance
</client_id>
<client_id>
bestbuy-acceptance
</client_id>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment