Commit 6e2dcb51 by Li Yongyu

update requestdatautiles

parent be44ce1c
......@@ -9,6 +9,7 @@ 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;
......@@ -20,6 +21,7 @@ import com.offcn.TestUnti.StringUtils;
import com.offcn.interfaces.API;
import com.offcn.process.NWN;
import com.offcn.process.TK;
import com.offcn.system.MyRequest;
import com.offcn.TestUnti.ListUtil;
import net.sf.json.JSONObject;
......@@ -60,6 +62,10 @@ public class uploadImg extends NWN implements API {
public Response SendRequest(HashMap<String, Object> data, String Url,
String Request) {
Response re = RequestDataUtils.Post_file(data, Url,"PHPSESSID",PHPSESSID,"img","1.png");
// Response re = RequestDataUtils.POST_houtai(data,myRequest);
return re;
}
......
......@@ -269,6 +269,7 @@ public class BasicsGM {
try {
String errmsg=JSONObject.fromObject(re.body().asString()).getString("errmsg");
if(StringIsNull(errmsg)){
return errmsg;
}
......
......@@ -46,6 +46,10 @@ public class NWN extends BasicsGM{
public static String level_id_List = "";//层级的id
public static List<String> user_id_List = new ArrayList<String>();//user_id
public NWN(){
Connectionsa();
}
public void Connectionsa(){
//================设置数据库连接池=====================
ConnectionsMap=getConnections(new String[]{"nwn"});
......@@ -57,9 +61,7 @@ public class NWN extends BasicsGM{
// DynamicParameter.put("sign","code");//动态公共参数
}
public NWN(){
Connectionsa();
}
//动态公共参数
public HashMap<String, Object> setDynamicParameter(HashMap<String, Object> data) {
......@@ -78,15 +80,15 @@ public class NWN extends BasicsGM{
if(!parameter.contains("\""+key+"\"") && !parameter.contains(key+"=")){
if("get".equals(Request)){
if(parameter==null || parameter.length()==0){
parameter=key+"="+"ppp";
parameter=key+"="+"value";//value 需要自己写
}else{
parameter=parameter+"&"+key+"="+"ppp";
parameter=parameter+"&"+key+"="+"value";//value 需要自己写
}
}else{
if(parameter==null || parameter.length()==0){
parameter=key+"\":\""+"ppp"+"\"";
parameter=key+"\":\""+"value"+"\"";//value 需要自己写
}else{
parameter=parameter+",\""+key+"\":\""+"ppp"+"\"";
parameter=parameter+",\""+key+"\":\""+"value"+"\"";//value 需要自己写
}
}
}
......@@ -114,15 +116,15 @@ public class NWN extends BasicsGM{
if(!parameter.contains("\""+key+"\"") && !parameter.contains(key+"=")){
if("get".equals(Request)){
if(parameter==null || parameter.length()==0){
parameter=key+"="+value;
parameter=key+"="+value;//value 需要自己写
}else{
parameter=parameter+"&"+key+"="+value;
parameter=parameter+"&"+key+"="+value;//value 需要自己写
}
}else{
if(parameter==null || parameter.length()==0){
parameter=key+"\":\""+value+"\"";
parameter=key+"\":\""+value+"\"";//value 需要自己写
}else{
parameter=parameter+",\""+key+"\":\""+value+"\"";
parameter=parameter+",\""+key+"\":\""+value+"\"";//value 需要自己写
}
}
}
......
......@@ -52,8 +52,6 @@ public class TK extends BasicsGM{
public static String is_hf_L="";//47
public static String type_L="";//47
public static String recordId_L="";//110申论,使用记录id 提交做题记录时需要用到
public static String admin_login_ssid="";//后台登录cookie
public static String admin_28_encode="";//后台登录cookie
public static String PHPSESSID="";//Cookie,后台第77个接口使用
......
......@@ -7,10 +7,11 @@ public class MyRequest {
private String Request;
private String Url;
private Map<String, String> Cookies;
private Map<String,String> headers;
private Map<String, String> Headers;
private String Parameter; //json请求方式的参数
private Map<String, String> formParameter;//form_data请求方式的参数、或file请求方式的参数
private String file;
private String fileType;
public String getRequest() {
return Request;
}
......@@ -30,10 +31,10 @@ public class MyRequest {
Cookies = cookies;
}
public Map<String, String> getHeaders() {
return headers;
return Headers;
}
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
Headers = headers;
}
public String getParameter() {
return Parameter;
......@@ -53,19 +54,27 @@ public class MyRequest {
public void setFile(String file) {
this.file = file;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public MyRequest(String request, String url, Map<String, String> cookies,
Map<String, String> headers, String parameter,
Map<String, String> formParameter, String file) {
Map<String, String> formParameter, String file, String fileType) {
super();
Request = request;
Url = url;
Cookies = cookies;
this.headers = headers;
Headers = headers;
Parameter = parameter;
this.formParameter = formParameter;
this.file = file;
this.fileType = fileType;
}
public MyRequest() {
}
}
......@@ -8,12 +8,9 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
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.MapUtil;
......@@ -91,21 +88,21 @@ public class APITest_tk extends BasicsGM{
//数据回写
// HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
// SheetUtils sheet = new SheetUtils("DataAll.xls", "Output");
// sheet.writeExcel(
// data.get("NO").toString(),
// data.get("TCNO").toString() + "_Step" + data.get("Step").toString(),
// data.get("Description").toString(),
// parameter.length()>1000?"内容超长。":parameter,
// JSONObject.fromObject(ExpectResult).toString(),
// StringUtils.decodeUnicode(re.asString().length()>10000?"内容超长。状态码:"+re.getStatusCode():re.asString()),
// codeORerrcode,
// msgORerrmsy,
// result,
// time
// );
//
HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
SheetUtils sheet = new SheetUtils("DataAll.xls", "Output");
sheet.writeExcel(
data.get("NO").toString(),
data.get("TCNO").toString() + "_Step" + data.get("Step").toString(),
data.get("Description").toString(),
parameter.length()>1000?"内容超长。":parameter,
JSONObject.fromObject(ExpectResult).toString(),
StringUtils.decodeUnicode(re.asString().length()>10000?"内容超长。状态码:"+re.getStatusCode():re.asString()),
codeORerrcode,
msgORerrmsy,
result,
time
);
if(result.indexOf("Fail")!=-1){
String Expect1=data.get("code")==null?"":data.get("code").toString();
......
package test;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class ReadProperties {
public static void main(String[] args) {
String s=ReadProperties.GetTestPropertyByKey("xls");
System.out.println(s);
// ClearProperty();
// SetProperty("123","111");
}
public static String GetPropertyByKey(String key) {
Properties pps = new Properties();
try {
File directory = new File(".");
String sourceFile = directory.getCanonicalPath() +File.separator+"src"+File.separator+"resources"+File.separator+"class.properties";
InputStream in = new BufferedInputStream (new FileInputStream(sourceFile));
pps.load(in);
String value = pps.getProperty(key);
return value;
}catch (IOException e) {
return null;
}
}
public static String GetTestPropertyByKey(String key) {
Properties pps = new Properties();
try {
File directory = new File(".");
System.out.println(directory);
String sourceFile = directory.getCanonicalPath() +File.separator+"src"+File.separator+"resources"+File.separator+"test.properties";
InputStream in = new BufferedInputStream (new FileInputStream(sourceFile));
pps.load(in);
String value = pps.getProperty(key);
System.out.println("value====" +value);
return value;
}catch (IOException e) {
return null;
}
}
}
\ No newline at end of file
package test;
import static io.restassured.http.ContentType.JSON;
import java.util.List;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.http.Header;
import io.restassured.http.Headers;
import io.restassured.response.Response;
public class maxiao implements Runnable{
public String JSESSIONID;
public String StatusCode;
public String time;
public maxiao(String jSESSIONID) {
JSESSIONID = jSESSIONID;
}
@Override
public void run() {
// RestAssured ra_VerifyCode = new RestAssured();
// ra_VerifyCode.baseURI = "http://10.10.197.245";
// ra_VerifyCode.port = 8888;
// ra_VerifyCode.basePath = "/puhui-lend-pre/page/lendRepay/repayList.jsp";
//
// Long start=System.currentTimeMillis();
// Response re2 = ra_VerifyCode.given().given().
// headers("Cookie", JSESSIONID,
// "Referer","http://10.10.197.245:8888/puhui-lend-pre/main",
// "Upgrade-Insecure-Requests","1"
// ).get();
// Long end=System.currentTimeMillis();
//
// time=(end-start)+"";
// System.out.println();
// StatusCode=re2.getStatusCode()+"";
// System.out.println(re2.getBody().asString());
// System.out.print("名称:"+Thread.currentThread().getName()+"状态:"+re2.getStatusCode()+"耗时:"+time+"毫秒");
RestAssured ra_VerifyCode = new RestAssured();
ra_VerifyCode.baseURI = "http://10.10.197.245";
ra_VerifyCode.port = 8888;
ra_VerifyCode.basePath = "/puhui-lend-pre/lendRepay/list ";
String Parameter="{\"billDate\":\"2016-12-25\",\"page\":1,\"rows\":20}";
System.out.println(Parameter);
Long start=System.currentTimeMillis();
Response re2 = ra_VerifyCode.given().given().contentType(JSON).
headers("Cookie", "JSESSIONID=17E32712D50602F82C30A29E827343E6",
"Referer"," http://10.10.197.245:8888/puhui-lend-pre/page/lendRepay/repayList.jsp",
"Origin","http://10.10.197.245:8888"
).body(Parameter).when().post();
Long end=System.currentTimeMillis();
time=(end-start)+"";
System.out.println(re2.getBody().asString());
System.out.print("名称:"+Thread.currentThread().getName()+"状态:"+re2.getStatusCode()+"耗时:"+time+"毫秒");
}
public static void main(String[] args) {
RestAssured ra_VerifyCode = new RestAssured();
ra_VerifyCode.baseURI = "http://10.10.197.245";
ra_VerifyCode.port = 8888;
ra_VerifyCode.basePath = "/puhui-lend-pre/lendRepay/list";
String Parameter="{\"billDate\":\"2016-12-25\",\"page\":1,\"rows\":20}";
System.out.println(Parameter);
Long start=System.currentTimeMillis();
Response re2 = ra_VerifyCode.given().given().contentType(ContentType.URLENC).
headers("Cookie", "JSESSIONID=17E32712D50602F82C30A29E827343E6",
"Referer"," http://10.10.197.245:8888/puhui-lend-pre/page/lendRepay/repayList.jsp",
"Origin","http://10.10.197.245:8888"
).body("billDate=2016-12-25&page=1&rows=20").when().post();
Long end=System.currentTimeMillis();
System.out.println(re2.getBody().asString());
System.out.print("名称:"+Thread.currentThread().getName()+"状态:"+re2.getStatusCode()+"耗时:毫秒");
}
}
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