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
964319ae
Commit
964319ae
authored
Oct 17, 2019
by
wufeifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
直播测试用例
parent
33f23c6d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1140 additions
and
0 deletions
+1140
-0
CaseMakeyrj.xls
nwn_Api_auto_test/TestData/CaseMakeyrj.xls
+0
-0
DataAllyrj.xls
nwn_Api_auto_test/TestData/DataAllyrj.xls
+0
-0
checkStatus.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/checkStatus.java
+156
-0
getLiveInfo1.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getLiveInfo1.java
+158
-0
getStoreInfoFromId.java
...uto_test/src/com/offcn/api/nwn/ht/getStoreInfoFromId.java
+146
-0
getStoreList.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getStoreList.java
+154
-0
getUserLoginStoreRole.java
..._test/src/com/offcn/api/nwn/ht/getUserLoginStoreRole.java
+146
-0
saveLiveInfo.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/saveLiveInfo.java
+226
-0
storeLogin.java
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/storeLogin.java
+154
-0
No files found.
nwn_Api_auto_test/TestData/CaseMakeyrj.xls
0 → 100644
View file @
964319ae
File added
nwn_Api_auto_test/TestData/DataAllyrj.xls
0 → 100644
View file @
964319ae
File added
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/checkStatus.java
0 → 100644
View file @
964319ae
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.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 账号管理-启用/停用账号
*
* @author puhui
*
*/
public
class
checkStatus
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
level_id
;
//层级ID
public
String
package_id
;
//包id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
//从excel取出参数
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
level_id
=
MapUtil
.
getParameter_get
(
parameter
,
"level_id"
).
trim
();
package_id
=
MapUtil
.
getParameter_get
(
parameter
,
"package_id"
).
trim
();
if
((!
level_id
.
equals
(
""
))
&&
level_id
.
equals
(
"code"
))
{
level_id
=
"71"
;
parameter
=
parameter
.
replace
(
"level_id=code"
,
"level_id="
+
level_id
);
}
if
((!
package_id
.
equals
(
""
))
&&
package_id
.
equals
(
"code"
))
{
package_id
=
"4027667"
;
parameter
=
parameter
.
replace
(
"package_id=code"
,
"package_id="
+
package_id
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
/*@Override
public HashMap<String, Object> handleInput(HashMap<String, Object> data) {
// 获取parameter对应的内容
parameter = MapUtil.getValue("parameter", data);
level_id = MapUtil.getParameter(parameter, "id").trim();
//System.out.println(id);
if ((!id.equals("")) && id.equals("code")) {
id=ListUtil.getListValue(n_admin_id_List, 0);
parameter = parameter.replace("\"id\":code", "\"id\":\""+ id + "\"");
}
data.put("parameter", parameter);
return data;
}*/
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
// Response re = RequestDataUtils.Post_cooike(data, Url,"PHPSESSID",PHPSESSID);
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
Url
);
//接口URL
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getLiveInfo1.java
0 → 100644
View file @
964319ae
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.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MyDateUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
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
;
import
net.sf.json.JSONObject
;
/**
*
* @Description: 81.教务包编辑直播组件-获取信息
* @author:
* @date: 2019年10月15日 下午16:23
* @version V1.0
*/
public
class
getLiveInfo1
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
level_id
;
//母版id
public
String
package_id
;
//当前讲义id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
//从excel取出参数
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
level_id
=
MapUtil
.
getParameter_get
(
parameter
,
"level_id"
).
trim
();
package_id
=
MapUtil
.
getParameter_get
(
parameter
,
"package_id"
).
trim
();
if
((!
level_id
.
equals
(
""
))
&&
level_id
.
equals
(
"code"
))
{
level_id
=
liveId
;
parameter
=
parameter
.
replace
(
"level_id=code"
,
"level_id="
+
level_id
);
}
if
((!
package_id
.
equals
(
""
))
&&
package_id
.
equals
(
"code"
))
{
package_id
=
"4029219"
;
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
)
{
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
"/admin/package/getLiveInfo"
);
//接口URL
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
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
,
","
);
// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
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
(
"0"
.
equals
(
jp
.
getString
(
"retcode"
))){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getStoreInfoFromId.java
0 → 100644
View file @
964319ae
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.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MyDateUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
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
;
import
net.sf.json.JSONObject
;
/**
*
* @Description: 86.店铺—登录用户店铺列表
* @author:
* @date: 2019年10月15日 上午9:26:59
* @version V1.0
*/
public
class
getStoreInfoFromId
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
//从excel取出参数
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
"/admin/package/getStoreInfoFromId"
);
//接口URL
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
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
,
","
);
// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
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
(
"0"
.
equals
(
jp
.
getString
(
"retcode"
))){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getStoreList.java
0 → 100644
View file @
964319ae
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.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MyDateUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
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
;
import
net.sf.json.JSONObject
;
/**
*
* @Description: 86.店铺—登录用户店铺列表
* @author:
* @date: 2019年10月15日 上午9:26:59
* @version V1.0
*/
public
class
getStoreList
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
login_user_card_no
;
//登录用户的工号
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
//从excel取出参数
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
login_user_card_no
=
MapUtil
.
getParameter_get
(
parameter
,
"login_user_card_no"
).
trim
();
if
((!
login_user_card_no
.
equals
(
""
))
&&
login_user_card_no
.
equals
(
"code"
))
{
//login_user_card_no = "ls60541";
parameter
=
parameter
.
replace
(
"login_user_card_no=code"
,
"login_user_card_no="
+
login_user_card_no
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
Url
);
//接口URL
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
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
,
","
);
// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
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
(
"0"
.
equals
(
jp
.
getString
(
"retcode"
))){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/getUserLoginStoreRole.java
0 → 100644
View file @
964319ae
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.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MyDateUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
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
;
import
net.sf.json.JSONObject
;
/**
*
* @Description: 86.店铺—登录用户店铺列表
* @author:
* @date: 2019年10月15日 上午9:26:59
* @version V1.0
*/
public
class
getUserLoginStoreRole
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
//从excel取出参数
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
"/admin/package/getUserLoginStoreRole"
);
//接口URL
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
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
,
","
);
// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
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
(
"0"
.
equals
(
jp
.
getString
(
"retcode"
))){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/saveLiveInfo.java
0 → 100644
View file @
964319ae
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.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MyDateUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
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
;
import
net.sf.json.JSONObject
;
/**
*
* @Description: 82.教务包编辑直播组件-保存信息
* @author:
* @date: 2019年10月15日 上午9:26:59
* @version V1.0
*/
public
class
saveLiveInfo
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
/*public String template_id_1;//母版id
public String menu_id ;//当前讲义id
public String handouts_name ;//直播名
public String handouts_path ;//日期
*/
public
String
package_id
;
public
String
level_id
;
public
String
live_name
;
public
String
date_time
;
public
String
start_time
;
public
String
end_time
;
public
String
room_id
;
public
String
room_type
;
public
String
subject_id
;
public
String
is_choice_type
;
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
package_id
=
MapUtil
.
getParameter
(
parameter
,
"package_id"
).
trim
();
level_id
=
MapUtil
.
getParameter
(
parameter
,
"level_id"
).
trim
();
live_name
=
MapUtil
.
getParameter
(
parameter
,
"live_name"
).
trim
();
date_time
=
MapUtil
.
getParameter
(
parameter
,
"date_time"
).
trim
();
start_time
=
MapUtil
.
getParameter
(
parameter
,
"start_time"
).
trim
();
end_time
=
MapUtil
.
getParameter
(
parameter
,
"end_time"
).
trim
();
room_id
=
MapUtil
.
getParameter
(
parameter
,
"room_id"
).
trim
();
room_type
=
MapUtil
.
getParameter
(
parameter
,
"room_type"
).
trim
();
subject_id
=
MapUtil
.
getParameter
(
parameter
,
"subject_id"
).
trim
();
if
((!
package_id
.
equals
(
""
))
&&
package_id
.
equals
(
"code"
))
{
package_id
=
"4029219"
;
parameter
=
parameter
.
replace
(
"\"package_id\":code"
,
"\"package_id\":\""
+
package_id
+
"\""
);
}
if
((!
level_id
.
equals
(
""
))
&&
level_id
.
equals
(
"code"
))
{
level_id
=
liveId
;
parameter
=
parameter
.
replace
(
"\"level_id\":code"
,
"\"level_id\":\""
+
level_id
+
"\""
);
}
if
((!
live_name
.
equals
(
""
))
&&
live_name
.
equals
(
"code"
))
{
live_name
=
"直播111"
;
parameter
=
parameter
.
replace
(
"\"live_name\":code"
,
"\"live_name\":\""
+
live_name
+
"\""
);
}
if
((!
date_time
.
equals
(
""
))
&&
date_time
.
equals
(
"code"
))
{
date_time
=
"2019-11-09"
;
parameter
=
parameter
.
replace
(
"\"date_time\":code"
,
"\"date_time\":\""
+
date_time
+
"\""
);
}
if
((!
start_time
.
equals
(
""
))
&&
start_time
.
equals
(
"code"
))
{
start_time
=
"15:00"
;
parameter
=
parameter
.
replace
(
"\"start_time\":code"
,
"\"start_time\":\""
+
start_time
+
"\""
);
}
if
((!
end_time
.
equals
(
""
))
&&
end_time
.
equals
(
"code"
))
{
end_time
=
"17:00"
;
parameter
=
parameter
.
replace
(
"\"end_time\":code"
,
"\"end_time\":\""
+
end_time
+
"\""
);
}
if
((!
room_id
.
equals
(
""
))
&&
room_id
.
equals
(
"code"
))
{
room_id
=
""
;
parameter
=
parameter
.
replace
(
"\"room_id\":code"
,
"\"room_id\":\""
+
room_id
+
"\""
);
}
if
((!
subject_id
.
equals
(
""
))
&&
subject_id
.
equals
(
"code"
))
{
subject_id
=
"1"
;
parameter
=
parameter
.
replace
(
"\"subject_id\":code"
,
"\"subject_id\":\""
+
subject_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
Url
);
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
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
,
","
);
// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
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
(
"0"
.
equals
(
jp
.
getString
(
"retcode"
))){
//讲义对应的menuid
menuId
=
jp
.
getString
(
"data.level_id"
);
//是否验证数据库
if
(!
isProduct
)
{
try
{
String
sql
=
"SELECT MAX(id) id,menu_id,name FROM n_handouts"
;
ResultSet
rs_bankcard
=
this
.
sqlFromDB
(
sql
);
rs_bankcard
.
last
();
//添加讲义的主键id
handoutsId
=
rs_bankcard
.
getString
(
"id"
);
//// System.out.println(rs_bankcard.getString("name"));
//// if(!(rs_bankcard.getString("name")).equals(handouts_name)){
//// result = result && false;
//// failReason = failReason + "template_id info in DB is wrong;";
//// }
// System.out.println(menuId);
// System.out.println(liveId);
//
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify template_id info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
nwn_Api_auto_test/src/com/offcn/api/nwn/ht/storeLogin.java
0 → 100644
View file @
964319ae
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.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MyDateUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
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
;
import
net.sf.json.JSONObject
;
/**
*
* @Description: 86.店铺—店铺登录
* @author:
* @date: 2019年10月15日 上午9:26:59
* @version V1.0
*/
public
class
storeLogin
extends
NWN
implements
API
{
public
String
parameter
;
//参数集合
public
String
store_id
;
//店铺id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
//从excel取出参数
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
store_id
=
MapUtil
.
getParameter_get
(
parameter
,
"store_id"
).
trim
();
System
.
out
.
println
(
"******店铺id*******"
+
store_id
);
if
((!
store_id
.
equals
(
""
))
&&
store_id
.
equals
(
"code"
))
{
store_id
=
"2"
;
parameter
=
parameter
.
replace
(
"store_id=code"
,
"store_id="
+
store_id
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
cookie
=
new
HashMap
<
String
,
String
>();
cookie
.
put
(
"PHPSESSID"
,
PHPSESSID
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
Url
);
//接口URL
myRequest
.
setParameter
(
parameter
);
myRequest
.
setCookies
(
cookie
);
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
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
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
,
","
);
// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
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
(
"0"
.
equals
(
jp
.
getString
(
"retcode"
))){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
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