增加远程启动调度任务接口

修复HTTP put delete方法没有消息体异常的BUG
This commit is contained in:
seagull 2017-12-18 18:29:53 +08:00
parent b260a2c4d7
commit e837209357
3 changed files with 70 additions and 13 deletions

View File

@ -25,6 +25,11 @@ import net.sf.json.JsonConfig;
*/
public class GetServerAPI {
/**
* 通过计划ID获取测试用例对象集
* @param planid
* @return
*/
@SuppressWarnings("unchecked")
public static List<ProjectCase> getCasesbyplanid(int planid) {
String result = HttpRequest.loadJSON("/projectPlanCase/cgetcasebyplanid.do?planid=" + planid);
@ -34,6 +39,11 @@ public class GetServerAPI {
return list;
}
/**
* 通过计划名称获取测试用例对象集
* @param name
* @return
*/
@SuppressWarnings("unchecked")
public static List<ProjectCase> getCasesbyplanname(String name) {
String result = HttpRequest.loadJSON("/projectPlanCase/cgetcasebyplanname.do?name=" + name);
@ -43,6 +53,11 @@ public class GetServerAPI {
return list;
}
/**
* 通过用例ID获取下面的步骤对象
* @param caseid
* @return
*/
@SuppressWarnings("unchecked")
public static List<ProjectCasesteps> getStepsbycaseid(int caseid) {
String result = HttpRequest.loadJSON("/projectCasesteps/cgetStepsByCase.do?caseid=" + caseid);
@ -52,6 +67,11 @@ public class GetServerAPI {
return list;
}
/**
* 通过taskid获取对象
* @param taskid
* @return
*/
public static TestTaskexcute cgetTaskbyid(int taskid) {
String result = HttpRequest.loadJSON("/tastExecute/cgettaskbyid.do?taskid=" + taskid);
JSONObject jsonObject = JSONObject.fromObject(result.toString());
@ -59,6 +79,11 @@ public class GetServerAPI {
return task;
}
/**
* 通过用例编号获取对象
* @param sign
* @return
*/
public static ProjectCase cgetCaseBysign(String sign) {
String result = HttpRequest.loadJSON("/projectCase/cgetcasebysign.do?sign=" + sign);
JSONObject jsonObject = JSONObject.fromObject(result.toString());
@ -66,6 +91,11 @@ public class GetServerAPI {
return pc;
}
/**
* 获取项目下的所有公共参数
* @param projectid
* @return
*/
public static List<PublicCaseParams> cgetParamsByProjectid(String projectid) {
String result = HttpRequest.loadJSON("/publicCaseParams/cgetParamsByProjectid.do?projectid="+projectid);
JSONObject jsonObject = JSONObject.fromObject(result.toString());
@ -75,6 +105,13 @@ public class GetServerAPI {
return list;
}
/**
* put web界面的数据到服务端
* @param sign
* @param executor
* @param loglevel
* @param detail
*/
public static void cPostDebugLog(String sign, String executor, String loglevel, String detail){
sign = sign.replace("%","BBFFHH");
sign = sign.replace("=","DHDHDH");
@ -93,8 +130,19 @@ public class GetServerAPI {
System.out.println("已经成功写入临时日志库ID" + logid);
}
/**
* 供其他系统远程调用调度任务启动执行
* @param jobid
* @return
* @throws UnsupportedEncodingException
*/
public static String cRunJobForId(String jobid) throws UnsupportedEncodingException {
String result = HttpRequest.loadJSON("/testJobs/runJobForInterface.do?jobid=" + jobid);
return new String(result.getBytes("GBK"), "UTF-8");
}
public static void main(String[] args) throws UnsupportedEncodingException {
getCasesbyplanid(79);
}
}

View File

@ -64,7 +64,7 @@ public class InvokeMethod {
String templateidstr = action.substring(1, action.indexOf("¡¿"));
String templatenamestr = action.substring(action.indexOf("¡¿") + 1);
luckyclient.publicclass.LogUtil.APP
.info("即将使用模板" + templatenamestr + " ID:" + templateidstr + " 发送HTTP请求");
.info("即将使用模板" + templatenamestr + " ID:" + templateidstr + " 发送HTTP请求");
String httpppt = HttpRequest
.loadJSON("/projectprotocolTemplate/cgetPTemplateById.do?templateid=" + templateidstr);
@ -194,7 +194,7 @@ public class InvokeMethod {
String templateidstr = action.substring(1, action.indexOf("¡¿"));
String templatenamestr = action.substring(action.indexOf("¡¿") + 1);
luckyclient.publicclass.LogUtil.APP
.info("即将使用模板" + templatenamestr + " ID:" + templateidstr + " 发送SOCKET请求");
.info("即将使用模板" + templatenamestr + " ID:" + templateidstr + " 发送SOCKET请求");
String httpppt = HttpRequest
.loadJSON("/projectprotocolTemplate/cgetPTemplateById.do?templateid=" + templateidstr);

View File

@ -13,6 +13,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -1051,11 +1052,13 @@ public class HttpClientHelper {
org.apache.http.StatusLine statusLine = response.getStatusLine();
//从状态行中获取状态码
responsecode = String.valueOf(statusLine.getStatusCode());
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), charset));
String temp;
while ((temp = br.readLine()) != null) {
resultBuffer.append(temp);
}
if(null!=response.getEntity()){
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), charset));
String temp;
while ((temp = br.readLine()) != null) {
resultBuffer.append(temp);
}
}
} catch (Exception e) {
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
throw new RuntimeException(e);
@ -1116,11 +1119,13 @@ public class HttpClientHelper {
org.apache.http.StatusLine statusLine = response.getStatusLine();
//从状态行中获取状态码
responsecode = String.valueOf(statusLine.getStatusCode());
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), charset));
String temp;
while ((temp = br.readLine()) != null) {
resultBuffer.append(temp);
}
if(null!=response.getEntity()){
br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), charset));
String temp;
while ((temp = br.readLine()) != null) {
resultBuffer.append(temp);
}
}
} catch (Exception e) {
luckyclient.publicclass.LogUtil.APP.error(e.getMessage(), e);
throw new RuntimeException(e);
@ -1140,5 +1145,9 @@ public class HttpClientHelper {
public static void main(String[] args) {
// TODO Auto-generated method stub
Map<String, Object> params = new HashMap<String, Object>(0);
Map<String, String> headmsg = new HashMap<String, String>(0);
String a=httpClientPut("http://tmsclub.gugud.com/aggregation/courses/48/start", params, "UTF-8",headmsg);
System.out.println(a);
}
}