Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webappauto
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
Li Yongyu
webappauto
Commits
fc1ee83e
Commit
fc1ee83e
authored
Nov 29, 2018
by
shuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2018-11-29
parent
0b14555c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
44 additions
and
48 deletions
+44
-48
CaseMake.xls
Api_auto_test/TestData/CaseMake.xls
+0
-0
DataAll.xls
Api_auto_test/TestData/DataAll.xls
+0
-0
RequestDataUtils.java
Api_auto_test/src/com/offcn/TestUnti/RequestDataUtils.java
+19
-20
aliOCR.java
Api_auto_test/src/com/offcn/TestUnti/aliOCR.java
+3
-1
banned_status.java
Api_auto_test/src/com/offcn/api/xyzb/banned_status.java
+0
-1
edit.java
Api_auto_test/src/com/offcn/api/xyzb/edit.java
+1
-1
getUser.java
Api_auto_test/src/com/offcn/api/xyzb/getUser.java
+1
-0
member.java
Api_auto_test/src/com/offcn/api/xyzb/process/member.java
+3
-1
questions.java
Api_auto_test/src/com/offcn/api/xyzb/questions.java
+3
-1
update.java
Api_auto_test/src/com/offcn/api/xyzb/update.java
+0
-3
users.java
Api_auto_test/src/com/offcn/api/xyzb/users.java
+2
-2
BasicsGM.java
Api_auto_test/src/com/offcn/process/BasicsGM.java
+0
-0
APITest.java
Api_auto_test/src/com/offcn/test/APITest.java
+9
-16
test.properties
Api_auto_test/src/resources/test.properties
+2
-1
testng.xml
Api_auto_test/testng.xml
+1
-1
No files found.
Api_auto_test/TestData/CaseMake.xls
View file @
fc1ee83e
No preview for this file type
Api_auto_test/TestData/DataAll.xls
View file @
fc1ee83e
No preview for this file type
Api_auto_test/src/com/offcn/TestUnti/RequestDataUtils.java
View file @
fc1ee83e
...
...
@@ -49,7 +49,7 @@ public class RequestDataUtils {
}
//不带token的post请求
public
static
Response
Post_headers
(
HashMap
<
String
,
Object
>
data
,
String
serviceURL
,
String
zgl_clienttype
)
{
public
static
Response
Post_headers
_token
(
HashMap
<
String
,
Object
>
data
,
String
serviceURL
,
String
zgl_clienttype
,
String
Salesman_token
)
{
// 设置参数格式
String
Parameter
=
(
String
)
data
.
get
(
"parameter"
);
...
...
@@ -64,7 +64,7 @@ public class RequestDataUtils {
while
(
state
<
5
)
{
try
{
state
++;
re
=
rdu
.
getRMEnv
(
tem
).
given
()
re
=
rdu
.
getRMEnv
(
tem
).
given
()
.
header
(
"Authorization"
,
"Bearer "
+
Salesman_token
)
.
header
(
"zgl-systemtype"
,
"Windows"
)
.
header
(
"zgl-clienttype"
,
zgl_clienttype
)
.
contentType
(
JSON
).
body
(
"{"
+
Parameter
+
"}"
).
when
()
...
...
@@ -99,36 +99,32 @@ public class RequestDataUtils {
int
state
=
0
;
Response
re
=
null
;
RequestDataUtils
rdu
=
new
RequestDataUtils
();
// System.out.println("laravel_session:"+XYZB.laravel_session);
// System.out.println("XSRF_token:"+XYZB.XSRF_token);
// System.out.println("请求参数:"+Parameter);
boolean
b
=
false
;
if
(
"创建房间流程测试_3"
.
equals
(
data
.
get
(
"TCNO"
).
toString
())
||
"创建房间流程测试_7"
.
equals
(
data
.
get
(
"TCNO"
).
toString
())){
b
=
true
;
}
while
(
state
<
5
)
{
try
{
state
++;
if
(
"/web/member"
.
equals
(
serviceURL
)){
// Cookie cookie1 = Cookie.Builder("username", "John").setComment("comment 1").build();
// Cookie cookie2 = Cookie.Builder("token", 1234).setComment("comment 2").build();
// Cookies cookies = new Cookies(cookie1, cookie2);
re
=
rdu
.
getRMEnv
(
tem
).
given
()
// .header("laravel_session", XYZB.laravel_session)
// .header("XSRF-TOKEN", XYZB.XSRF_token)
.
cookie
(
"laravel_session"
,
XYZB
.
laravel_session
)
.
cookie
(
"XSRF-TOKEN"
,
XYZB
.
XSRF_token
)
// .cookie("domain", ".live.offcncloud.com")
.
contentType
(
JSON
).
body
(
"{"
+
Parameter
+
"}"
).
when
()
.
post
(
serviceURL
).
thenReturn
();
// System.out.println(re.getStatusCode()+"............................");
// System.out.println(re.asString());
// Headers headers=re.getHeaders();
// System.out.println(headers.toString());
// System.out.println(re.getSessionId());
// JsonPath jp = re.body().jsonPath();
// System.out.println(re.asString());
// System.out.println(re.getStatusCode());
if
(!
"200"
.
equals
(
re
.
getStatusCode
()+
""
))
{
Log
.
logError
(
"请求返回:"
+
re
.
getStatusCode
()+
",第"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
if
(
b
){
if
(!
re
.
asString
().
contains
(
"<html"
)){
return
re
;
}
}
else
{
return
re
;
}
...
...
@@ -287,7 +283,7 @@ public class RequestDataUtils {
state
++;
if
(
parameter
!=
null
&&
!
""
.
equals
(
parameter
))
{
re
=
rdu
.
getRMEnv
(
tem
).
given
().
header
(
"Authorization"
,
"Bearer "
+
token
).
get
(
serviceURL
+
"?"
+
parameter
).
andReturn
();
re
=
rdu
.
getRMEnv
(
tem
).
given
().
header
(
"
system_type"
,
"Windows"
).
header
(
"
Authorization"
,
"Bearer "
+
token
).
get
(
serviceURL
+
"?"
+
parameter
).
andReturn
();
}
else
{
re
=
rdu
.
getRMEnv
(
tem
).
given
().
header
(
"Authorization"
,
"Bearer "
+
token
).
get
(
serviceURL
).
andReturn
();
}
...
...
@@ -523,10 +519,13 @@ public class RequestDataUtils {
// .formParam("area", "东城区").
when
().
put
(
serviceURL
).
thenReturn
();
JsonPath
jp
=
re
.
body
().
jsonPath
();
// System.out.println(StringUtils.decodeUnicode(re.asString()));
// System.out.println(re.getStatusCode());
if
(
"500"
.
equals
(
jp
.
getString
(
"status"
)))
{
Log
.
logError
(
"请求返回500,"
+
state
+
"次。"
);
Thread
.
sleep
(
1000
);
}
else
{
}
else
{
return
re
;
}
}
catch
(
Exception
e
)
{
...
...
Api_auto_test/src/com/offcn/TestUnti/aliOCR.java
View file @
fc1ee83e
...
...
@@ -26,7 +26,9 @@ import sun.misc.BASE64Decoder;
public
class
aliOCR
{
public
static
void
main
(
String
[]
args
)
{
// getYZM(6,"d:\\a1.jpg");
getYZM
(
4
,
"d:\\t1.jpg"
);
// getYZM(4,"d:\\t1.jpg");
// getYZM(4,"温爽看到了吗 11");
System
.
out
.
println
(
new
String
(
Base64
.
encodeBase64
(
"温爽看到了吗 11"
.
getBytes
())));
}
public
static
String
getYZM
(
int
count
,
String
imagePath
){
String
host
=
"http://ali-checkcode.showapi.com"
;
...
...
Api_auto_test/src/com/offcn/api/xyzb/banned_status.java
View file @
fc1ee83e
...
...
@@ -50,7 +50,6 @@ public class banned_status extends XYZB implements API {
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
is_banned
=
MapUtil
.
getParameter
(
parameter
,
"is_banned"
).
trim
();
is_banned
=
MapUtil
.
killQuotes
(
is_banned
,
"\""
);
return
data
;
}
...
...
Api_auto_test/src/com/offcn/api/xyzb/edit.java
View file @
fc1ee83e
...
...
@@ -256,7 +256,7 @@ public class edit extends XYZB implements API {
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
).
length
()>
4
){
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)
!=
null
&&
jp
.
getString
(
"data"
)
.
length
()>
4
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
...
...
Api_auto_test/src/com/offcn/api/xyzb/getUser.java
View file @
fc1ee83e
...
...
@@ -57,6 +57,7 @@ public class getUser extends XYZB implements API {
parameter
=
Current_uuid
;
parameter
=
MapUtil
.
killQuotes
(
parameter
,
"\""
);
//去掉双引号的parameter
parameter
=
parameter
;
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
...
...
Api_auto_test/src/com/offcn/api/xyzb/process/member.java
View file @
fc1ee83e
...
...
@@ -99,6 +99,7 @@ public class member extends XYZB implements API {
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
...
...
@@ -183,7 +184,7 @@ public class member extends XYZB implements API {
" xyu_users x "
,
" x.name = '"
+
name
+
"' "
);
rs_bankcard
.
last
();
System
.
out
.
println
(
rs_bankcard
.
getRow
());
if
(
rs_bankcard
.
getRow
()
<
1
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"xyu_users info is not in DB;"
;
...
...
@@ -204,6 +205,7 @@ public class member extends XYZB implements API {
}
else
{
Log
.
logInfo
(
"xyu_users info in DB is correct;"
);
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
...
...
Api_auto_test/src/com/offcn/api/xyzb/questions.java
View file @
fc1ee83e
...
...
@@ -48,7 +48,9 @@ public class questions extends XYZB implements API {
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
user_id
=
Current_user_id
;
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
name
=
MapUtil
.
getParameter
(
parameter
,
"name"
).
trim
();
if
(
parameter
.
length
()>
7
){
name
=
parameter
.
substring
(
7
);
}
if
(
Current_password
.
contains
(
"Not_started"
)){
room_id
=
ReadProperties
.
GetinformationByKey
(
"Not_started_xyzbid"
);
}
else
if
(
Current_password
.
contains
(
"Running_xyzb"
)){
...
...
Api_auto_test/src/com/offcn/api/xyzb/update.java
View file @
fc1ee83e
...
...
@@ -36,15 +36,12 @@ import net.sf.json.JSONObject;
*/
public
class
update
extends
XYZB
implements
API
{
public
String
parameter
;
//参数集合
public
String
name
;
//房间名称
public
String
phone
;
//房间名称
public
String
room_num
;
//房间名称
public
String
identity
;
public
String
id
;
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
...
...
Api_auto_test/src/com/offcn/api/xyzb/users.java
View file @
fc1ee83e
...
...
@@ -110,7 +110,7 @@ public class users extends XYZB implements API {
parameter
=
parameter
.
replace
(
"\"uuid\":random"
,
"\"uuid\":\""
+
Current_uuid
+
"\""
);
}
parameter
=
parameter
+
",\"system_type\":\"Windows\""
;
// 替换原来的parameter
data
.
put
(
"parameter"
,
parameter
);
return
data
;
...
...
@@ -120,7 +120,7 @@ public class users extends XYZB implements API {
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
// Response re = RequestDataUtils.Post_NOToken(data, Url);
Response
re
=
RequestDataUtils
.
Post_headers
(
data
,
Url
,
zgl_clienttype
);
Response
re
=
RequestDataUtils
.
Post_headers
_token
(
data
,
Url
,
zgl_clienttype
,
Salesman_token
);
return
re
;
}
...
...
Api_auto_test/src/com/offcn/process/BasicsGM.java
View file @
fc1ee83e
This diff is collapsed.
Click to expand it.
Api_auto_test/src/com/offcn/test/APITest.java
View file @
fc1ee83e
package
com
.
offcn
.
test
;
import
io.restassured.response.Response
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
net.sf.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
com.offcn.TestData.offcn_api_testData
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.Mail
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.OAuthTokenUnti
;
import
com.offcn.TestUnti.ReadProperties
;
import
com.offcn.TestUnti.Reflect_api
;
import
com.offcn.TestUnti.SheetUtils
;
...
...
@@ -25,7 +19,6 @@ import com.offcn.listener.ProcessTestng;
import
com.offcn.listener.ResultTestng
;
import
com.offcn.process.BasicsGM
;
import
com.offcn.process.XYZB
;
import
org.testng.annotations.Listeners
;
import
org.testng.annotations.Test
;
...
...
@@ -37,6 +30,10 @@ public class APITest extends XYZB{
Log
.
logInfo
(
data
.
get
(
"TCNO"
).
toString
()
+
" Step "
+
data
.
get
(
"Description"
).
toString
()
+
" is running......"
);
if
(
"冒烟测试_70"
.
equals
(
data
.
get
(
"TCNO"
).
toString
())){
System
.
out
.
println
(
123
);
}
API
obj
=
new
Reflect_api
().
Reflections
(
data
);
BasicsGM
.
map
=
new
XMLread
().
getSystem
();
...
...
@@ -96,12 +93,15 @@ public class APITest extends XYZB{
String
Expect1
=
data
.
get
(
"code"
)==
null
?
""
:
data
.
get
(
"code"
).
toString
();
String
Expect2
=
data
.
get
(
"msg"
)==
null
?
""
:
data
.
get
(
"msg"
).
toString
();
String
Expect3
=
data
.
get
(
"custom"
)==
null
?
""
:
data
.
get
(
"custom"
).
toString
();
// System.out.println("Expect1:"+Expect1);
// System.out.println("Expect2:"+Expect2);
// System.out.println("Expect3:"+Expect3);
// System.out.println("Expect4:"+StringUtils.decodeUnicode(body));
Assert
.
assertEquals
(
StringUtils
.
decodeUnicode
(
body
),
Expect1
+
","
+
Expect2
+
","
+
Expect3
);
}
else
{
Assert
.
assertTrue
(
true
);
}
// OAuthTokenUnti.token=null;
}
@AfterClass
...
...
@@ -121,13 +121,6 @@ public class APITest extends XYZB{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
// //发送邮件
// try {
// Mail.POP3();
// } catch (Exception e) {
// Log.logError("邮件发送失败");
// e.printStackTrace();
// }
}
Log
.
logInfo
(
"========测试结束========"
);
...
...
Api_auto_test/src/resources/test.properties
View file @
fc1ee83e
xls
=
DataAll.xls
sheet
=
TestCase
2
sheet
=
TestCase
1
mysql_local_Online
=
Online
\ No newline at end of file
Api_auto_test/testng.xml
View file @
fc1ee83e
...
...
@@ -4,7 +4,7 @@
<listeners>
<listener
class-name=
"org.uncommons.reportng.HTMLReporter"
/>
<listener
class-name=
"org.uncommons.reportng.JUnitXMLReporter"
/>
</listeners>
<!-- -->
</listeners>
<!--
org.uncommons.reportng.HTMLReporter
-->
<test
name=
"Test"
>
<classes>
...
...
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