Commit 3fe2f2e2 by Li Yongyu

Merge branch 'master' of

git@gitlab.eoffcn.com:ys65701/nwn_Api_auto_test.git

Conflicts:
	nwn_Api_auto_test/src/DefectTest.xml
parents d070efd9 c2745fc8
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<classes> <classes>
<class name="com.puhui.test.RenMai_APITest"> <class name="com.puhui.test.RenMai_APITest">
<methods> <methods>
<include name="f" invocation-numbers="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 "/> <include name="f" invocation-numbers="0 1 2 3 4 5 6 "/>
</methods> </methods>
</class> </class>
</classes> </classes>
......
package com.offcn.TestUnti;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
public class HttpRequest {
/**
* 向指定URL发送GET方法的请求
*
* @param url
* 发送请求的URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
*/
public static void main(String[] args) {
String s=HttpRequest.sendGet("http://beta.alitest.eoffcn.com/template/addStuden/sign/5d114486999208096dace001ae4bc45a",
"user_info=[{\"package_id\":391634,\"username\":\"aaa\",\"phone\":15656333337,\"sso_id\":1}]&timestamp=1548828632&appid=jiaowu");
try {
String s1=new String(s.getBytes(),"utf-8");
System.out.println(s1);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
public static String sendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
// String urlNameString = url ;
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("Authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NSwicGhvbmUiOiIxODUxMTg1MjA0OSIsImlhdCI6MTQ4NzEzMjU0OX0.2aZ8FcfE52CYpXc4VUYjdfzzLzXwVOE-J8CnMlhUPic");
connection.setRequestProperty("Content-Type", "application/json");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
// o.write(line+"\r\n");
result += line;
result += "\r\n";
}
// o.close();
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url
* 发送请求的 URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("Authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NSwicGhvbmUiOiIxODUxMTg1MjA0OSIsImlhdCI6MTQ4NzEzMjU0OX0.2aZ8FcfE52CYpXc4VUYjdfzzLzXwVOE-J8CnMlhUPic");
conn.setRequestProperty("Content-Type", "application/json");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
result += "\r\n";
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
}
\ No newline at end of file
package com.offcn.TestUnti; package com.offcn.TestUnti;
import io.restassured.RestAssured; import io.restassured.RestAssured;
import io.restassured.config.RestAssuredConfig; import io.restassured.config.RestAssuredConfig;
import io.restassured.config.SSLConfig; import io.restassured.config.SSLConfig;
import io.restassured.path.json.JsonPath; import io.restassured.path.json.JsonPath;
import io.restassured.response.Response; import io.restassured.response.Response;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static io.restassured.http.ContentType.JSON; import static io.restassured.http.ContentType.JSON;
/** /**
* Created by puhui on 16/9/14. * Created by puhui on 16/9/14.
*/ */
public class MockServerTestUtil { public class MockServerTestUtil {
static RestAssured ra; static RestAssured ra;
public static RestAssured getLocalRAEnv(){ public static RestAssured getLocalRAEnv(){
if (ra == null){ if (ra == null){
ra = new RestAssured(); ra = new RestAssured();
ra.config = RestAssuredConfig.newConfig().sslConfig(SSLConfig.sslConfig().allowAllHostnames()); ra.config = RestAssuredConfig.newConfig().sslConfig(SSLConfig.sslConfig().allowAllHostnames());
ra.baseURI = "http://127.0.0.1"; ra.baseURI = "http://127.0.0.1";
ra.port = 30800; ra.port = 30800;
} }
return ra; return ra;
} }
public static void sendSingleMessageResponse(String mobile, String messageContent){ public static void sendSingleMessageResponse(String mobile, String messageContent){
Response re = getLocalRAEnv().given(). Response re = getLocalRAEnv().given().
param("token", "faketoken"). param("token", "faketoken").
param("senderId", 1). param("senderId", 1).
param("senderName", "iqianjin"). param("senderName", "iqianjin").
param("mobile", mobile). param("mobile", mobile).
param("messageContent", messageContent). param("messageContent", messageContent).
param("bsCode", "sbcode"). param("bsCode", "sbcode").
when().get("/api/v1/message/getSend").thenReturn(); when().get("/api/v1/message/getSend").thenReturn();
re.getBody().print(); re.getBody().print();
re.then().statusCode( 200 ); re.then().statusCode( 200 );
} }
//batchNo批次号非必要参数, //batchNo批次号非必要参数,
// messageContent messageContents 单条内容和多条容不能共存,优先单一内容发送,多条内容发送是与发送号码一一对应的。 // messageContent messageContents 单条内容和多条容不能共存,优先单一内容发送,多条内容发送是与发送号码一一对应的。
public static JsonPath sendmutiMessageResponse(List<String> mobiles, List<String> messageContents){ public static JsonPath sendmutiMessageResponse(List<String> mobiles, List<String> messageContents){
Map<String, Object> jsonAsMap = new HashMap(); Map<String, Object> jsonAsMap = new HashMap();
jsonAsMap.put("senderName","testmuti"); jsonAsMap.put("senderName","testmuti");
jsonAsMap.put("messageContents",messageContents); jsonAsMap.put("messageContents",messageContents);
jsonAsMap.put("mobiles",mobiles); jsonAsMap.put("mobiles",mobiles);
jsonAsMap.put("bscode","fakebscode"); jsonAsMap.put("bscode","fakebscode");
Response re = getLocalRAEnv().given().contentType(JSON).body(jsonAsMap). Response re = getLocalRAEnv().given().contentType(JSON).body(jsonAsMap).
when(). post("/api/v1/message/send").thenReturn(); when(). post("/api/v1/message/send").thenReturn();
re.getBody().print(); re.getBody().print();
re.then().statusCode( 200 ); re.then().statusCode( 200 );
return re.getBody().jsonPath(); return re.getBody().jsonPath();
} }
public static JsonPath getSingleMessageResponse(String mobile){ public static JsonPath getSingleMessageResponse(String mobile){
Response re = getLocalRAEnv().given(). Response re = getLocalRAEnv().given().
param("mobile", mobile). param("mobile", mobile).
when(). get("/api/v1/message/query").thenReturn(); when(). get("/api/v1/message/query").thenReturn();
re.getBody().print(); re.getBody().print();
re.then().statusCode( 200 ); re.then().statusCode( 200 );
return re.getBody().jsonPath(); return re.getBody().jsonPath();
} }
} }
package com.offcn.TestUnti; package com.offcn.TestUnti;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.token.DefaultAccessTokenRequest; import org.springframework.security.oauth2.client.token.DefaultAccessTokenRequest;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.OAuth2AccessToken; import org.springframework.security.oauth2.common.OAuth2AccessToken;
import com.offcn.process.BasicsGM; import com.offcn.process.BasicsGM;
import com.offcn.system.system; import com.offcn.system.system;
import com.offcn.test.APITest_tk; import com.offcn.test.APITest_tk;
import java.util.Arrays; import java.util.Arrays;
public class OAuthTokenUnti { public class OAuthTokenUnti {
public APITest_tk RAPI; public APITest_tk RAPI;
// private static OAuth2AccessToken token; // private static OAuth2AccessToken token;
public static OAuth2AccessToken token; public static OAuth2AccessToken token;
public static void main(String[] args) { public static void main(String[] args) {
String strToken=OAuthTokenUnti.getOathToken("gmysx").getValue(); String strToken=OAuthTokenUnti.getOathToken("gmysx").getValue();
System.out.println("strToken="+strToken); System.out.println("strToken="+strToken);
} }
public static OAuth2AccessToken getOathToken(String system){ public static OAuth2AccessToken getOathToken(String system){
if(token == null){ if(token == null){
OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(getResource(system),new DefaultOAuth2ClientContext(new DefaultAccessTokenRequest())); OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(getResource(system),new DefaultOAuth2ClientContext(new DefaultAccessTokenRequest()));
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
restTemplate.setMessageConverters(Arrays.<HttpMessageConverter<?>> asList(converter)); restTemplate.setMessageConverters(Arrays.<HttpMessageConverter<?>> asList(converter));
token = restTemplate.getAccessToken(); token = restTemplate.getAccessToken();
} }
return token; return token;
} }
private static ClientCredentialsResourceDetails getResource(String system){ private static ClientCredentialsResourceDetails getResource(String system){
ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails(); ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
system tem=(system)(BasicsGM.map.get(system)); system tem=(system)(BasicsGM.map.get(system));
resource.setAccessTokenUri(tem.getAccess_token_uri()); resource.setAccessTokenUri(tem.getAccess_token_uri());
resource.setClientId(tem.getClient_id()); resource.setClientId(tem.getClient_id());
resource.setClientSecret(tem.getClient_secret()); resource.setClientSecret(tem.getClient_secret());
resource.setGrantType(tem.getGrant_type()); resource.setGrantType(tem.getGrant_type());
return resource; return resource;
} }
} }
...@@ -665,8 +665,7 @@ public class RequestDataUtils { ...@@ -665,8 +665,7 @@ public class RequestDataUtils {
} }
} }
return re; return re;
} }
@SuppressWarnings("static-access") @SuppressWarnings("static-access")
public static Response Get_one_cookie_pre(HashMap<String, Object> data, public static Response Get_one_cookie_pre(HashMap<String, Object> data,
...@@ -837,4 +836,5 @@ public class RequestDataUtils { ...@@ -837,4 +836,5 @@ public class RequestDataUtils {
} }
return re; return re;
} }
} }
...@@ -33,7 +33,7 @@ public class nwngetsign { ...@@ -33,7 +33,7 @@ public class nwngetsign {
str = str + "bf2h3%^j?ljkj3706kji88697"; //教务的加密,规则固定需要加 str = str + "bf2h3%^j?ljkj3706kji88697"; //教务的加密,规则固定需要加
System.out.println("str===" + str); System.out.println("str===" + str);
NWN.suprise_str = str;
//String str1 = "appid=tiku&avatar=http://thirdqq.qlogo.cn/qqapp/1106773681/5B50BBF83A00DC46B16B708F720A5D46/100&device_id=861837034477409&login_type=qq&nickname=hobo&open_id=1&platform=Android&version=1"+"&123456"; //String str1 = "appid=tiku&avatar=http://thirdqq.qlogo.cn/qqapp/1106773681/5B50BBF83A00DC46B16B708F720A5D46/100&device_id=861837034477409&login_type=qq&nickname=hobo&open_id=1&platform=Android&version=1"+"&123456";
String res = new LMFMD5().MD5(str); String res = new LMFMD5().MD5(str);
System.out.println("res===" +res); System.out.println("res===" +res);
......
...@@ -4,6 +4,7 @@ package com.offcn.api.nwn.service; ...@@ -4,6 +4,7 @@ package com.offcn.api.nwn.service;
import io.restassured.path.json.JsonPath; import io.restassured.path.json.JsonPath;
import io.restassured.response.Response; import io.restassured.response.Response;
import java.io.UnsupportedEncodingException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
...@@ -15,16 +16,17 @@ import java.util.Random; ...@@ -15,16 +16,17 @@ import java.util.Random;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import com.offcn.TestUnti.HttpRequest;
import com.offcn.TestUnti.Log; import com.offcn.TestUnti.Log;
import com.offcn.TestUnti.MapUtil; import com.offcn.TestUnti.MapUtil;
import com.offcn.TestUnti.RequestDataUtils; import com.offcn.TestUnti.RequestDataUtils;
import com.offcn.TestUnti.StringUtils; import com.offcn.TestUnti.StringUtils;
import com.offcn.api.nwn.md5.nwngetsign;
import com.offcn.interfaces.API; import com.offcn.interfaces.API;
import com.offcn.process.NWN; import com.offcn.process.NWN;
import com.offcn.process.TK; import com.offcn.process.TK;
import com.offcn.TestUnti.ListUtil; import com.offcn.TestUnti.ListUtil;
import net.sf.json.JSONObject;
...@@ -40,6 +42,7 @@ public class addStuden extends NWN implements API { ...@@ -40,6 +42,7 @@ public class addStuden extends NWN implements API {
public String template_id_1;//母板ID public String template_id_1;//母板ID
public String response;//返回结果
// public String phone;//层级包id // public String phone;//层级包id
@Override @Override
public void initialize(HashMap<String, Object> data) { public void initialize(HashMap<String, Object> data) {
...@@ -76,20 +79,30 @@ public class addStuden extends NWN implements API { ...@@ -76,20 +79,30 @@ public class addStuden extends NWN implements API {
// Map<String,String> m=new HashMap<String,String>(); // Map<String,String> m=new HashMap<String,String>();
// m.put("user_info", parameter); // m.put("user_info", parameter);
//Response re = RequestDataUtils.Post_cooike_form_data(data, Url,"PHPSESSID",PHPSESSID,m); //Response re = RequestDataUtils.Post_cooike_form_data(data, Url,"PHPSESSID",PHPSESSID,m);
Response re = RequestDataUtils.Get_one_cookie_pre(data, Url, "PHPSESSID",PHPSESSID); // Response re = RequestDataUtils.Get_one_cookie_pre(data, Url, "PHPSESSID",PHPSESSID);
//Response re = RequestDataUtils.Get_one_cookie(data, serviceURL, cookie1Name, cookie1value) //只能无参
// Response re = RequestDataUtils.Get_token(data, Url, ""); //response=HttpRequest.sendGet("http://beta.alitest.eoffcn.com/template/addStuden/sign/5d114486999208096dace001ae4bc45a",
return re; // "user_info=[{\"package_id\":391634,\"username\":\"aaa\",\"phone\":15656333337,\"sso_id\":1}]&timestamp=1548828632&appid=jiaowu");
System.out.println("parameter====" + parameter);
System.out.println("url===" + Url);
response=HttpRequest.sendGet("http://beta.alitest.eoffcn.com"+Url,parameter);
try {
String s1=new String(response.getBytes(),"utf-8");
System.out.println(s1);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
} }
@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 = new JsonPath(response);
System.out.println( "jp===="+ jp); System.out.println( "jp===="+ jp);
boolean result = true; boolean result = true;
String failReason = ""; String failReason = "";
String json = re.asString(); String json = response;
System.out.println("response=========="+StringUtils.decodeUnicode(json)); System.out.println("response=========="+StringUtils.decodeUnicode(json));
if ((data.get("statusCode") != null) if ((data.get("statusCode") != null)
......
...@@ -47,6 +47,7 @@ public class NWN extends BasicsGM{ ...@@ -47,6 +47,7 @@ public class NWN extends BasicsGM{
public static List<String> user_id_List = new ArrayList<String>();//user_id public static List<String> user_id_List = new ArrayList<String>();//user_id
public static String template_id = ""; public static String template_id = "";
public static String timestamp;//时间戳 public static String timestamp;//时间戳
public static String suprise_str;//特殊字符
// public static String phone_code = "";//手机号验证码 // public static String phone_code = "";//手机号验证码
// //
// //
......
...@@ -99,13 +99,18 @@ public class APITest_nwn extends NWN{ ...@@ -99,13 +99,18 @@ public class APITest_nwn extends NWN{
if(data.get("Description").toString().contains("流程")){ if(data.get("Description").toString().contains("流程")){
result = obj.handleOutput(re, data); result = obj.handleOutput(re, data);
} }
}else{
result = obj.handleOutput(re, data);
} }
codeORerrcode=getCode(re); // else{
msgORerrmsy=getMsg(re); // result = obj.handleOutput(re, data);
// }
// codeORerrcode=getCode(re);
// msgORerrmsy=getMsg(re);
} }
result = obj.handleOutput(re, data);
codeORerrcode=getCode(re);
msgORerrmsy=getMsg(re);
Log.logInfo("返回结果="+StringUtils.decodeUnicode(body)); Log.logInfo("返回结果="+StringUtils.decodeUnicode(body));
System.out.println(); System.out.println();
......
package com.offcn.test; package com.offcn.test;
import io.restassured.response.Response; import io.restassured.response.Response;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import com.offcn.TestData.offcn_api_testData; import com.offcn.TestData.offcn_api_testData;
import com.offcn.TestUnti.Log; import com.offcn.TestUnti.Log;
import com.offcn.TestUnti.Mail; import com.offcn.TestUnti.Mail;
import com.offcn.TestUnti.MapUtil; import com.offcn.TestUnti.MapUtil;
import com.offcn.TestUnti.OAuthTokenUnti; import com.offcn.TestUnti.OAuthTokenUnti;
import com.offcn.TestUnti.ReadProperties; import com.offcn.TestUnti.ReadProperties;
import com.offcn.TestUnti.Reflect_api; import com.offcn.TestUnti.Reflect_api;
import com.offcn.TestUnti.SheetUtils; import com.offcn.TestUnti.SheetUtils;
import com.offcn.TestUnti.StringUtils; import com.offcn.TestUnti.StringUtils;
import com.offcn.TestUnti.XMLread; import com.offcn.TestUnti.XMLread;
import com.offcn.interfaces.API; import com.offcn.interfaces.API;
import com.offcn.listener.ProcessTestng; import com.offcn.listener.ProcessTestng;
import com.offcn.listener.ResultTestng; import com.offcn.listener.ResultTestng;
import com.offcn.process.BasicsGM; import com.offcn.process.BasicsGM;
import com.offcn.process.TK; import com.offcn.process.TK;
import com.offcn.process.XYZB; import com.offcn.process.XYZB;
import org.testng.annotations.Listeners; import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Listeners({ ProcessTestng.class ,ResultTestng.class }) @Listeners({ ProcessTestng.class ,ResultTestng.class })
public class APITest_tk extends TK{ public class APITest_tk extends TK{
@Test(dataProvider = "renmai", dataProviderClass = offcn_api_testData.class) @Test(dataProvider = "renmai", dataProviderClass = offcn_api_testData.class)
public void f(HashMap<String, Object> data) { public void f(HashMap<String, Object> data) {
Log.logInfo(data.get("TCNO").toString() + " Step " + data.get("Description").toString() + " is running......"); Log.logInfo(data.get("TCNO").toString() + " Step " + data.get("Description").toString() + " is running......");
API obj = new Reflect_api().Reflections(data); API obj = new Reflect_api().Reflections(data);
BasicsGM.map=new XMLread().getSystem(); BasicsGM.map=new XMLread().getSystem();
obj.initialize(data); obj.initialize(data);
data = obj.handleInput(data); data = obj.handleInput(data);
String parameter = MapUtil.getValue("parameter", data); String parameter = MapUtil.getValue("parameter", data);
Long startTime=System.currentTimeMillis(); Long startTime=System.currentTimeMillis();
Response re = obj.SendRequest(data, data.get("serviceUrl").toString(), data.get("Request").toString()); Response re = obj.SendRequest(data, data.get("serviceUrl").toString(), data.get("Request").toString());
Long endTime=System.currentTimeMillis(); Long endTime=System.currentTimeMillis();
String time=(endTime-startTime)+"毫秒"; String time=(endTime-startTime)+"毫秒";
String body=re.asString(); String body=re.asString();
String codeORerrcode=""; String codeORerrcode="";
String msgORerrmsy=""; String msgORerrmsy="";
String result = ""; String result = "";
if(body.contains("<title>")){ if(body.contains("<title>")){
int Alength="<title>".length(); int Alength="<title>".length();
int start=body.indexOf("<title>"); int start=body.indexOf("<title>");
int end=body.indexOf("</title>")+1; int end=body.indexOf("</title>")+1;
body="页面标题:"+body.substring(start+Alength, end-1); body="页面标题:"+body.substring(start+Alength, end-1);
result=body; result=body;
if(data.get("Description").toString().contains("流程")){ if(data.get("Description").toString().contains("流程")){
result = obj.handleOutput(re, data); result = obj.handleOutput(re, data);
} }
}else{ }else{
result = obj.handleOutput(re, data); result = obj.handleOutput(re, data);
} }
codeORerrcode=getCode(re); codeORerrcode=getCode(re);
msgORerrmsy=getMsg(re); msgORerrmsy=getMsg(re);
Log.logInfo("返回结果="+StringUtils.decodeUnicode(body)); Log.logInfo("返回结果="+StringUtils.decodeUnicode(body));
System.out.println(); System.out.println();
//数据回写 //数据回写
// 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("DataAll.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(),
// data.get("Description").toString(), // data.get("Description").toString(),
// parameter, // parameter,
// JSONObject.fromObject(ExpectResult).toString(), // JSONObject.fromObject(ExpectResult).toString(),
// StringUtils.decodeUnicode(re.asString()), // StringUtils.decodeUnicode(re.asString()),
// codeORerrcode, // codeORerrcode,
// 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();
String Expect2=data.get("msg")==null?"":data.get("msg").toString(); String Expect2=data.get("msg")==null?"":data.get("msg").toString();
String Expect3=data.get("custom")==null?"":data.get("custom").toString(); String Expect3=data.get("custom")==null?"":data.get("custom").toString();
if(body.contains("HTML")){ if(body.contains("HTML")){
body="异常页面信息"; body="异常页面信息";
} }
Assert.assertEquals(StringUtils.decodeUnicode(body),Expect1+","+Expect2+","+Expect3); Assert.assertEquals(StringUtils.decodeUnicode(body),Expect1+","+Expect2+","+Expect3);
}else{ }else{
Assert.assertTrue(true); Assert.assertTrue(true);
} }
} }
@AfterClass @AfterClass
public void afterClass() { public void afterClass() {
//测试结束删除测试所用的数据 //测试结束删除测试所用的数据
if (!isClearMysql) { if (!isClearMysql) {
cleanUser_FromDB();//清除注册user_id, cleanUser_FromDB();//清除注册user_id,
cleanexam_FromDB();//清除用户地区操作表t_exam_area cleanexam_FromDB();//清除用户地区操作表t_exam_area
try { try {
if(stmt!=null){ if(stmt!=null){
stmt.close(); stmt.close();
} }
if (conn != null){ if (conn != null){
conn.close(); conn.close();
} }
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
Log.logInfo("========测试结束========"); Log.logInfo("========测试结束========");
} }
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<customers> <customers>
<customer active="false"> <customer active="false">
<xml_name>王炎炎</xml_name> <xml_name>王炎炎</xml_name>
<xml_idNo>130426199201270329</xml_idNo> <xml_idNo>130426199201270329</xml_idNo>
<xml_bankNo>6227000210250635768</xml_bankNo> <xml_bankNo>6227000210250635768</xml_bankNo>
<xml_phone>18230065651</xml_phone> <xml_phone>18230065651</xml_phone>
</customer> </customer>
<customer active="true"> <customer active="true">
<xml_name>王炎炎</xml_name> <xml_name>王炎炎</xml_name>
<xml_idNo>130426199201270329</xml_idNo> <xml_idNo>130426199201270329</xml_idNo>
<xml_bankNo>6227000210250635768</xml_bankNo> <xml_bankNo>6227000210250635768</xml_bankNo>
<xml_phone>18230065651</xml_phone> <xml_phone>18230065651</xml_phone>
</customer> </customer>
</customers> </customers>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<package_name name="com.puhui.api.zy"> <package_name name="com.puhui.api.zy">
<class_name name="support"></class_name> <class_name name="support"></class_name>
<father_class_name name="ZY"></father_class_name> <father_class_name name="ZY"></father_class_name>
<implements_name name="获取所支持银行列表"></implements_name> <implements_name name="获取所支持银行列表"></implements_name>
<!-- 参数:name是参数名,标签内容是备注--> <!-- 参数:name是参数名,标签内容是备注-->
<parameters> <parameters>
<!-- <!--
<parameter name="openId">openId</parameter> <parameter name="openId">openId</parameter>
<parameter name="openId111">openId111</parameter> <parameter name="openId111">openId111</parameter>
<parameter name="productName">商品名称</parameter> <parameter name="productName">商品名称</parameter>
<parameter name="busiId">商户Id(更美)</parameter> <parameter name="busiId">商户Id(更美)</parameter>
<parameter name="busiName">商户名称 </parameter> <parameter name="busiName">商户名称 </parameter>
<parameter name="productPrice">商户价格</parameter> <parameter name="productPrice">商户价格</parameter>
<parameter name="sqlRs">查询结果</parameter> <parameter name="sqlRs">查询结果</parameter>
--> -->
</parameters> </parameters>
<initialize_Disable>false</initialize_Disable> <initialize_Disable>false</initialize_Disable>
<initializes> <initializes>
<initialize name="insert">"insert into huimai.bestbuy_sub_busi (busi_id,sub_busi_name,busi_id_third,create_time) "+ "values('999','" + thirdBusi.get("busiName") + "','" + thirdBusi.get("busiId") + "', NOW())"</initialize> <initialize name="insert">"insert into huimai.bestbuy_sub_busi (busi_id,sub_busi_name,busi_id_third,create_time) "+ "values('999','" + thirdBusi.get("busiName") + "','" + thirdBusi.get("busiId") + "', NOW())"</initialize>
<initialize name="delelt"></initialize> <initialize name="delelt"></initialize>
<initialize name="update"></initialize> <initialize name="update"></initialize>
<initialize name="select" value="sqlRs">"selecrt * from word"</initialize> <initialize name="select" value="sqlRs">"selecrt * from word"</initialize>
</initializes> </initializes>
<handleInput_Disable>false</handleInput_Disable> <handleInput_Disable>false</handleInput_Disable>
<handleInput_replaces> <handleInput_replaces>
<handleInput_replace name="openId" type="code" >data_ext.get("openId").toString()</handleInput_replace> <handleInput_replace name="openId" type="code" >data_ext.get("openId").toString()</handleInput_replace>
<handleInput_replace name="busiId" type="code" >thirdBusi.get("busiId")</handleInput_replace> <handleInput_replace name="busiId" type="code" >thirdBusi.get("busiId")</handleInput_replace>
<handleInput_replace name="busiName" type="code" >thirdBusi.get("busiName")</handleInput_replace> <handleInput_replace name="busiName" type="code" >thirdBusi.get("busiName")</handleInput_replace>
</handleInput_replaces> </handleInput_replaces>
<handleInputs_Verifications> <handleInputs_Verifications>
<handleInputs_Verification name="productName"></handleInputs_Verification> <handleInputs_Verification name="productName"></handleInputs_Verification>
<handleInputs_Verification name="productPrice"></handleInputs_Verification> <handleInputs_Verification name="productPrice"></handleInputs_Verification>
</handleInputs_Verifications> </handleInputs_Verifications>
<SendRequest_Disable>true</SendRequest_Disable> <SendRequest_Disable>true</SendRequest_Disable>
<SendRequest name="Get"></SendRequest> <SendRequest name="Get"></SendRequest>
<handleOutput_Disable>false</handleOutput_Disable> <handleOutput_Disable>false</handleOutput_Disable>
<handleOutput_saves> <handleOutput_saves>
<handleOutput_save name="productId"> <handleOutput_save name="productId">
<handleOutput>prod_ids.add(productId);</handleOutput> <handleOutput>prod_ids.add(productId);</handleOutput>
<handleOutput>data_ext.put("productId", productId);</handleOutput> <handleOutput>data_ext.put("productId", productId);</handleOutput>
</handleOutput_save> </handleOutput_save>
</handleOutput_saves> </handleOutput_saves>
<handleOutput_Table name="huimai.bestbuy_goods">"id=" + productId</handleOutput_Table> <handleOutput_Table name="huimai.bestbuy_goods">"id=" + productId</handleOutput_Table>
</package_name> </package_name>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<package_name name="com.puhui.api.rgxs"> <package_name name="com.puhui.api.rgxs">
<class_name name="commitOrderApprove"></class_name> <class_name name="commitOrderApprove"></class_name>
<father_class_name name="GM"></father_class_name> <father_class_name name="GM"></father_class_name>
<implements_name name="订单模式,人工信审-结论"></implements_name> <implements_name name="订单模式,人工信审-结论"></implements_name>
<!-- 参数:name是参数名,标签内容是备注--> <!-- 参数:name是参数名,标签内容是备注-->
<parameters> <parameters>
<parameter name="Description">用例名称</parameter> <parameter name="Description">用例名称</parameter>
<parameter name="auditRecordId">人工信审工单处理记录表ID</parameter> <parameter name="auditRecordId">人工信审工单处理记录表ID</parameter>
<parameter name="audit_result">人工信审结论</parameter> <parameter name="audit_result">人工信审结论</parameter>
<parameter name="engine_result">决策引擎结论</parameter> <parameter name="engine_result">决策引擎结论</parameter>
</parameters> </parameters>
<initialize_Disable>false</initialize_Disable> <initialize_Disable>false</initialize_Disable>
<initializes> <initializes>
<initialize name="insert">"insert into huimai.bestbuy_sub_busi (busi_id,sub_busi_name,busi_id_third,create_time) "+ "values('999','" + thirdBusi.get("busiName") + "','" + thirdBusi.get("busiId") + "', NOW())"</initialize> <initialize name="insert">"insert into huimai.bestbuy_sub_busi (busi_id,sub_busi_name,busi_id_third,create_time) "+ "values('999','" + thirdBusi.get("busiName") + "','" + thirdBusi.get("busiId") + "', NOW())"</initialize>
<initialize name="delelt"></initialize> <initialize name="delelt"></initialize>
<initialize name="update"></initialize> <initialize name="update"></initialize>
<initialize name="select" value="sqlRs">"selecrt * from word"</initialize> <initialize name="select" value="sqlRs">"selecrt * from word"</initialize>
</initializes> </initializes>
<handleInput_Disable>true</handleInput_Disable> <handleInput_Disable>true</handleInput_Disable>
<handleInput_replaces> <handleInput_replaces>
<handleInput_replace name="auditRecordId" type="code" >thirdBusi.get("busiId")</handleInput_replace> <handleInput_replace name="auditRecordId" type="code" >thirdBusi.get("busiId")</handleInput_replace>
</handleInput_replaces> </handleInput_replaces>
<handleInputs_Verifications> <handleInputs_Verifications>
<handleInputs_Verification name="audit_result"></handleInputs_Verification> <handleInputs_Verification name="audit_result"></handleInputs_Verification>
<handleInputs_Verification name="engine_result"></handleInputs_Verification> <handleInputs_Verification name="engine_result"></handleInputs_Verification>
</handleInputs_Verifications> </handleInputs_Verifications>
<SendRequest_Disable>true</SendRequest_Disable> <SendRequest_Disable>true</SendRequest_Disable>
<SendRequest name="Post"></SendRequest> <SendRequest name="Post"></SendRequest>
<handleOutput_Disable>true</handleOutput_Disable> <handleOutput_Disable>true</handleOutput_Disable>
<handleOutput_saves> <handleOutput_saves>
<handleOutput_save name="productId"> <handleOutput_save name="productId">
<handleOutput>prod_ids.add(productId);</handleOutput> <handleOutput>prod_ids.add(productId);</handleOutput>
<handleOutput>data_ext.put("productId", productId);</handleOutput> <handleOutput>data_ext.put("productId", productId);</handleOutput>
</handleOutput_save> </handleOutput_save>
</handleOutput_saves> </handleOutput_saves>
<handleOutput_Table name="huimai.bestbuy_goods">"id=" + productId</handleOutput_Table> <handleOutput_Table name="huimai.bestbuy_goods">"id=" + productId</handleOutput_Table>
</package_name> </package_name>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment