Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tiku_APP_APITest
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
tiku_APP_APITest
Commits
be44ce1c
Commit
be44ce1c
authored
Apr 18, 2019
by
shuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20190418-2
parent
c9182c99
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
60 deletions
+153
-60
DataAll.xls
tiku_App/TestData/DataAll.xls
+0
-0
RequestDataUtils.java
tiku_App/src/com/offcn/TestUnti/RequestDataUtils.java
+1
-1
getPaperFilter.java
tiku_App/src/com/offcn/api/tk/ht/getPaperFilter.java
+114
-0
mockList.java
tiku_App/src/com/offcn/api/tk/ht/mockList.java
+38
-58
APITest_tk.java
tiku_App/src/com/offcn/test/APITest_tk.java
+0
-1
No files found.
tiku_App/TestData/DataAll.xls
View file @
be44ce1c
No preview for this file type
tiku_App/src/com/offcn/TestUnti/RequestDataUtils.java
View file @
be44ce1c
...
@@ -49,7 +49,7 @@ public class RequestDataUtils {
...
@@ -49,7 +49,7 @@ public class RequestDataUtils {
// RestAssured.config = ra.config().connectionConfig(RestAssured.config().getConnectionConfig().closeIdleConnectionsAfterEachResponse());
// RestAssured.config = ra.config().connectionConfig(RestAssured.config().getConnectionConfig().closeIdleConnectionsAfterEachResponse());
}
}
// ra.config = RestAssured.config().redirect(RedirectConfig.redirectConfig().followRedirects(false));
// ra.config = RestAssured.config().redirect(RedirectConfig.redirectConfig().followRedirects(false));
//
RestAssured.config = RestAssured.config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs("x-www-form-urlencoded", ContentType.ANY).defaultContentCharset("utf-8"));
RestAssured
.
config
=
RestAssured
.
config
().
encoderConfig
(
EncoderConfig
.
encoderConfig
().
encodeContentTypeAs
(
"x-www-form-urlencoded"
,
ContentType
.
ANY
).
defaultContentCharset
(
"utf-8"
));
return
ra
;
return
ra
;
}
}
...
...
tiku_App/src/com/offcn/api/tk/ht/getPaperFilter.java
0 → 100644
View file @
be44ce1c
package
com
.
offcn
.
api
.
tk
.
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.HT
;
import
com.offcn.system.MyRequest
;
/**
*
*
* @author puhui
*
*/
public
class
getPaperFilter
extends
HT
implements
API
{
public
String
parameter
;
//参数集合
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setRequest
(
Request
);
myRequest
.
setUrl
(
Url
);
if
(!
""
.
equals
(
PHPSESSID
)){
Map
<
String
,
String
>
Cookies
=
new
HashMap
<
String
,
String
>();
Cookies
.
put
(
"PHPSESSID"
,
PHPSESSID
);
myRequest
.
setCookies
(
Cookies
);
}
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
// Response re = RequestDataUtils.POST_houtai(data,myRequest);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
String
json
=
re
.
asString
().
substring
(
1
);
JsonPath
jp
=
new
JsonPath
(
json
);
boolean
result
=
true
;
String
failReason
=
""
;
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
)
{
System
.
out
.
println
(
jp
.
toString
());
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
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/ht/mockList.java
View file @
be44ce1c
...
@@ -3,27 +3,12 @@ package com.offcn.api.tk.ht;
...
@@ -3,27 +3,12 @@ package com.offcn.api.tk.ht;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.util.EntityUtils
;
import
org.json.simple.JSONArray
;
import
test.HttpUtils
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.ReadProperties
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.HT
;
import
com.offcn.process.HT
;
import
com.offcn.system.MyRequest
;
import
com.offcn.system.MyRequest
;
...
@@ -71,11 +56,13 @@ public class mockList extends HT implements API {
...
@@ -71,11 +56,13 @@ public class mockList extends HT implements API {
@Override
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
// JsonPath jp = re.body().jsonPath();
boolean
result
=
true
;
boolean
result
=
true
;
String
failReason
=
""
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
String
json
=
re
.
asString
().
substring
(
1
);
JsonPath
jp
=
new
JsonPath
(
json
);
if
((
data
.
get
(
"statusCode"
)
!=
null
)
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
&&
(!
data
.
get
(
"statusCode"
).
toString
()
...
@@ -86,46 +73,39 @@ public class mockList extends HT implements API {
...
@@ -86,46 +73,39 @@ public class mockList extends HT implements API {
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
}
// if (json.length() != 0) {
if
(
json
.
length
()
!=
0
)
{
//
// System.out.println(jp.toString());
String
msg
=
jp
.
getString
(
"message"
);
// String msg=jp.getString("message");
String
code
=
jp
.
getString
(
"retcode"
);
// String code=jp.getString("retcode");
//
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
// if ((data.get("code") != null ) && (code != null) && (!code.equals(data.get("code").toString()))) {
result
=
result
&&
false
;
// result = result && false;
failReason
=
failReason
+
"code is expected "
// failReason = failReason + "code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
// + data.get("code").toString() + " but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
// + jp.getString("code") + ".";
}
// }
//
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
// if ((data.get("msg") != null) && (msg != null) && (!msg.equals(data.get("msg").toString()))) {
result
=
result
&&
false
;
// result = result && false;
failReason
=
failReason
+
"msg is expected "
// failReason = failReason + "msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
// + data.get("msg").toString() + " but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
// + jp.getString("msg") + ".";
}
// }
//
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
// if(data.get("custom") != null && jp.getString("data")!=null){
String
custom
=
data
.
get
(
"custom"
).
toString
();
// String custom=data.get("custom").toString();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
// String[] ArrayString=StringUtils.getArrayString(custom,",");
// System.out.println(jp.getString("custom"));
//// System.out.println(jp.getString("custom"));
// System.out.println(Arrays.toString(ArrayString));
//// System.out.println(Arrays.toString(ArrayString));
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
// if(!StringUtils.VerificationString(jp.getString("data"),ArrayString)){
result
=
result
&&
false
;
// result = result && false;
failReason
=
failReason
+
"custom is expected "
// failReason = failReason + "custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
// + data.get("custom").toString() + " but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
// + jp.getString("data") + ".";
}
// }
}
// }
}
// if("0".equals(jp.getString("retcode"))){
// System.out.println(json);
// }
// }
if
(
result
)
if
(
result
)
return
"Pass"
;
return
"Pass"
;
...
...
tiku_App/src/com/offcn/test/APITest_tk.java
View file @
be44ce1c
...
@@ -64,7 +64,6 @@ public class APITest_tk extends BasicsGM{
...
@@ -64,7 +64,6 @@ public class APITest_tk extends BasicsGM{
String
codeORerrcode
=
""
;
String
codeORerrcode
=
""
;
String
msgORerrmsy
=
""
;
String
msgORerrmsy
=
""
;
String
result
=
""
;
String
result
=
""
;
if
(
re
!=
null
){
if
(
re
!=
null
){
body
=
re
.
asString
();
body
=
re
.
asString
();
if
(
body
.
contains
(
"<html"
)){
if
(
body
.
contains
(
"<html"
)){
...
...
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