refactor the testplanControler's api to pure restful
refactor the testplanControler's api to pure restful
This commit is contained in:
parent
dcf91a19b1
commit
7d7d8c7837
|
@ -21,14 +21,17 @@ import org.bench4q.master.exception.Bench4QException;
|
||||||
import org.bench4q.master.exception.ExceptionLog;
|
import org.bench4q.master.exception.ExceptionLog;
|
||||||
import org.bench4q.recorder.ScriptCapturer;
|
import org.bench4q.recorder.ScriptCapturer;
|
||||||
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
||||||
|
import org.bench4q.share.models.master.ScriptFilterModel;
|
||||||
import org.bench4q.share.models.master.ScriptModel;
|
import org.bench4q.share.models.master.ScriptModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@ -67,33 +70,33 @@ public class ScriptController extends BaseController {
|
||||||
this.portPoolService = portPoolService;
|
this.portPoolService = portPoolService;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequestMapping(value = "/startScriptRecordServer", method = {
|
// @RequestMapping(value = "/startScriptRecordServer", method = {
|
||||||
// RequestMethod.GET, RequestMethod.POST })
|
// RequestMethod.GET, RequestMethod.POST })
|
||||||
// @ResponseBody
|
// @ResponseBody
|
||||||
// public OperateScriptServerResponseModel startScriptRecordServer()
|
// public OperateScriptServerResponseModel startScriptRecordServer()
|
||||||
// throws UnknownHostException {
|
// throws UnknownHostException {
|
||||||
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
// return buildReponseModel(false,
|
// return buildReponseModel(false,
|
||||||
// "has no power for recording script!!!", "", -1, null, null,
|
// "has no power for recording script!!!", "", -1, null, null,
|
||||||
// null);
|
// null);
|
||||||
// }
|
// }
|
||||||
// Port port = new Port();
|
// Port port = new Port();
|
||||||
// synchronized (PORT_LOCK) {
|
// synchronized (PORT_LOCK) {
|
||||||
// port = this.getPortPoolService().getAPortNotInUse();
|
// port = this.getPortPoolService().getAPortNotInUse();
|
||||||
// if (port == null) {
|
// if (port == null) {
|
||||||
// return buildReponseModel(false, "port is in use!", "", -1,
|
// return buildReponseModel(false, "port is in use!", "", -1,
|
||||||
// null, null, null);
|
// null, null, null);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// UUID uuid = UUID.randomUUID();
|
// UUID uuid = UUID.randomUUID();
|
||||||
// this.getScriptCapturer().startRecord(port.getPort(),
|
// this.getScriptCapturer().startRecord(port.getPort(),
|
||||||
// buildScriptSavePath(), uuid.toString());
|
// buildScriptSavePath(), uuid.toString());
|
||||||
//
|
//
|
||||||
// return buildReponseModel(true, "", this.getScriptCapturer()
|
// return buildReponseModel(true, "", this.getScriptCapturer()
|
||||||
// .getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
// .getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
||||||
// uuid.toString());
|
// uuid.toString());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@RequestMapping(value = "/startScriptRecordServer", method = {
|
@RequestMapping(value = "/startScriptRecordServer", method = {
|
||||||
RequestMethod.GET, RequestMethod.POST })
|
RequestMethod.GET, RequestMethod.POST })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -112,14 +115,13 @@ public class ScriptController extends BaseController {
|
||||||
null, null, null);
|
null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getScriptCapturer().startRecordServer(port.getPort());
|
this.getScriptCapturer().startRecordServer(port.getPort());
|
||||||
|
|
||||||
return buildReponseModel(true, "", this.getScriptCapturer()
|
return buildReponseModel(true, "", this.getScriptCapturer()
|
||||||
.getIpHttpCaptureServerAdress(), port.getPort(), null, null,
|
.getIpHttpCaptureServerAdress(), port.getPort(), null, null, "");
|
||||||
"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/startScriptRecording", method = {
|
@RequestMapping(value = "/startScriptRecording", method = {
|
||||||
RequestMethod.POST, RequestMethod.GET })
|
RequestMethod.POST, RequestMethod.GET })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -131,13 +133,13 @@ public class ScriptController extends BaseController {
|
||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
this.getScriptCapturer().startRecording(port,
|
this.getScriptCapturer().startRecording(port, buildScriptSavePath(),
|
||||||
buildScriptSavePath(), uuid.toString());
|
uuid.toString());
|
||||||
|
|
||||||
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
||||||
null, uuid.toString());
|
null, uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildScriptSavePath() {
|
private String buildScriptSavePath() {
|
||||||
String dirString = "Scripts" + System.getProperty("file.separator")
|
String dirString = "Scripts" + System.getProperty("file.separator")
|
||||||
+ this.getPrincipal().getUserName()
|
+ this.getPrincipal().getUserName()
|
||||||
|
@ -182,11 +184,11 @@ public class ScriptController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getScriptCapturer().stopRecording(port);
|
this.getScriptCapturer().stopRecording(port);
|
||||||
|
|
||||||
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
return buildReponseModel(true, "RecordServer stop", "", port, null,
|
||||||
null, fileNameUUID);
|
null, fileNameUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/saveScriptToDB", method = { RequestMethod.GET,
|
@RequestMapping(value = "/saveScriptToDB", method = { RequestMethod.GET,
|
||||||
RequestMethod.POST })
|
RequestMethod.POST })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -257,7 +259,7 @@ public class ScriptController extends BaseController {
|
||||||
return this.buildReponseModel(true, null, null, 0,
|
return this.buildReponseModel(true, null, null, 0,
|
||||||
dealWithCollection(scripts), null, null);
|
dealWithCollection(scripts), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/queryScriptsByDate", method = RequestMethod.POST)
|
@RequestMapping(value = "/queryScriptsByDate", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public OperateScriptServerResponseModel queryScriptsByDate(
|
public OperateScriptServerResponseModel queryScriptsByDate(
|
||||||
|
@ -325,42 +327,45 @@ public class ScriptController extends BaseController {
|
||||||
RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT })
|
RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public OperateScriptServerResponseModel updateScript(
|
public OperateScriptServerResponseModel updateScript(
|
||||||
@PathVariable int scriptId, @RequestParam String content, @RequestParam String scriptName) {
|
@PathVariable int scriptId, @RequestParam String content,
|
||||||
|
@RequestParam String scriptName) {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
Logger.getLogger(ScriptController.class).info("no power");
|
Logger.getLogger(ScriptController.class).info("no power");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.buildReponseModel(
|
return this.buildReponseModel(
|
||||||
this.getScriptService().alterScriptContent(scriptId,
|
this.getScriptService().alterScriptContent(scriptId,
|
||||||
this.getPrincipal().getId(),content,scriptName), "", "", 0, null,
|
this.getPrincipal().getId(), content, scriptName), "",
|
||||||
null, null);
|
"", 0, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequestMapping(value = "updateScript/{scriptId}", method = {
|
// @RequestMapping(value = "updateScript/{scriptId}", method = {
|
||||||
// RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT })
|
// RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT })
|
||||||
// @ResponseBody
|
// @ResponseBody
|
||||||
// public OperateScriptServerResponseModel updateScript(
|
// public OperateScriptServerResponseModel updateScript(
|
||||||
// @PathVariable int scriptId,
|
// @PathVariable int scriptId,
|
||||||
// @RequestParam(value = "paramContents[]", required = true) List<String> paramContents,
|
// @RequestParam(value = "paramContents[]", required = true) List<String>
|
||||||
// @RequestParam(value = "paramFiles[]", required = false) List<MultipartFile> paramFiles)
|
// paramContents,
|
||||||
// throws Bench4QException {
|
// @RequestParam(value = "paramFiles[]", required = false)
|
||||||
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
// List<MultipartFile> paramFiles)
|
||||||
// throw new Bench4QException(HAVE_NO_POWER, HAVE_NO_POWER
|
// throws Bench4QException {
|
||||||
// + "for update a script", "/updateScript");
|
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
// }
|
// throw new Bench4QException(HAVE_NO_POWER, HAVE_NO_POWER
|
||||||
// try {
|
// + "for update a script", "/updateScript");
|
||||||
// boolean success = this.getScriptService().alterScriptContent(scriptId,
|
// }
|
||||||
// this.getPrincipal().getId(), paramContents.get(0), paramContents.get(1));
|
// try {
|
||||||
// logger.info("update script:" + paramContents.get(0));
|
// boolean success = this.getScriptService().alterScriptContent(scriptId,
|
||||||
// return buildReponseModel(success, null, null, -1, null, null, null);
|
// this.getPrincipal().getId(), paramContents.get(0), paramContents.get(1));
|
||||||
// } catch (Exception e) {
|
// logger.info("update script:" + paramContents.get(0));
|
||||||
// this.logger.error(ExceptionLog.getStackTrace(e));
|
// return buildReponseModel(success, null, null, -1, null, null, null);
|
||||||
// return buildReponseModel(false,
|
// } catch (Exception e) {
|
||||||
// "The script is not in the right format", null, -1, null,
|
// this.logger.error(ExceptionLog.getStackTrace(e));
|
||||||
// null, null);
|
// return buildReponseModel(false,
|
||||||
// }
|
// "The script is not in the right format", null, -1, null,
|
||||||
// }
|
// null, null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
private OperateScriptServerResponseModel buildReponseModel(
|
private OperateScriptServerResponseModel buildReponseModel(
|
||||||
boolean isSuccess, String failCauseString, String hostName,
|
boolean isSuccess, String failCauseString, String hostName,
|
||||||
int port, List<ScriptModel> scriptModels, ScriptModel scriptModel,
|
int port, List<ScriptModel> scriptModels, ScriptModel scriptModel,
|
||||||
|
@ -379,4 +384,16 @@ public class ScriptController extends BaseController {
|
||||||
return responseModel;
|
return responseModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/loadFilterTypeList", method = RequestMethod.GET)
|
||||||
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
|
@ResponseBody
|
||||||
|
public ScriptFilterModel loadFilterTypeList() throws Bench4QException {
|
||||||
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
|
throw new Bench4QException(HAVE_NO_POWER,
|
||||||
|
"You don't have enough power to get filter type list!",
|
||||||
|
"/loadFilterTypeList");
|
||||||
|
}
|
||||||
|
String[] filterTypeList = this.getScriptService().loadFilterTypeList();
|
||||||
|
return new ScriptFilterModel(filterTypeList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
@ -98,8 +97,7 @@ public class TestPlanController extends BaseController {
|
||||||
this.testPlanScriptResultService = testPlanScriptResultService;
|
this.testPlanScriptResultService = testPlanScriptResultService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/run", method = { RequestMethod.POST,
|
@RequestMapping(value = "/run", method = RequestMethod.PUT)
|
||||||
RequestMethod.GET })
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanResultModel runTestPlanWithTestPlanModel(
|
public TestPlanResultModel runTestPlanWithTestPlanModel(
|
||||||
|
@ -132,12 +130,11 @@ public class TestPlanController extends BaseController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRunningInfo", method = { RequestMethod.GET,
|
@RequestMapping(value = "/{testPlanId}/runningInfo", method = { RequestMethod.GET })
|
||||||
RequestMethod.POST })
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanResultModel getTestPlanRunningInfo(
|
public TestPlanResultModel getTestPlanRunningInfo(
|
||||||
@RequestParam UUID testPlanId) throws Bench4QException {
|
@PathVariable UUID testPlanId) throws Bench4QException {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
throw new Bench4QException(HAVE_NO_POWER,
|
throw new Bench4QException(HAVE_NO_POWER,
|
||||||
"You have not power to get test plan running info",
|
"You have not power to get test plan running info",
|
||||||
|
@ -147,7 +144,7 @@ public class TestPlanController extends BaseController {
|
||||||
return this.getTestPlanService().buildResultModel(testPlanId);
|
return this.getTestPlanService().buildResultModel(testPlanId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/{duationBegin}", method = RequestMethod.GET)
|
@RequestMapping(value = "/{testPlanId}/scriptBrief/{scriptId}/{duationBegin}", method = RequestMethod.GET)
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanScriptBriefResultModel getScriptBrief(
|
public TestPlanScriptBriefResultModel getScriptBrief(
|
||||||
|
@ -169,7 +166,7 @@ public class TestPlanController extends BaseController {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}")
|
@RequestMapping(value = "/{testPlanRunID}/behaviorsBrief/{scriptId}", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ScriptBehaviorsBriefModel getBehaviorsBrief(
|
public ScriptBehaviorsBriefModel getBehaviorsBrief(
|
||||||
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
|
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
|
||||||
|
@ -184,7 +181,7 @@ public class TestPlanController extends BaseController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/pagesBrief/{testPlanRunId}/{scriptId}")
|
@RequestMapping(value = "/{testPlanRunId}/pagesBrief/{scriptId}", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ScriptPagesBriefModel getPagesBrief(
|
public ScriptPagesBriefModel getPagesBrief(
|
||||||
@PathVariable UUID testPlanRunId, @PathVariable int scriptId)
|
@PathVariable UUID testPlanRunId, @PathVariable int scriptId)
|
||||||
|
@ -199,49 +196,45 @@ public class TestPlanController extends BaseController {
|
||||||
return pagesBriefModel;
|
return pagesBriefModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/loadTestPlans", method = { RequestMethod.GET,
|
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||||
RequestMethod.POST })
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanResponseModel loadTestPlans() {
|
public TestPlanResponseModel loadTestPlans() {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
return buildTestPlanResponseModel(false, "no scope", null, null);
|
return buildTestPlanResponseModel(false, "no scope", null);
|
||||||
}
|
}
|
||||||
List<TestPlan> testPlanDBs = this.testPlanService.loadTestPlans(this
|
List<TestPlan> testPlanDBs = this.testPlanService.loadTestPlans(this
|
||||||
.getPrincipal());
|
.getPrincipal());
|
||||||
return testPlanDBs == null ? buildTestPlanResponseModel(false,
|
return testPlanDBs == null ? buildTestPlanResponseModel(false,
|
||||||
"exception", null, null) : buildTestPlanResponseModel(true,
|
"exception", null) : buildTestPlanResponseModel(true, null,
|
||||||
null, testPlanDBs, null);
|
testPlanDBs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/queryTestPlan/{runId}", method = RequestMethod.GET)
|
@RequestMapping(value = "/{runId}", method = RequestMethod.GET)
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanDBModel queryTestPlan(@PathVariable UUID runId)
|
public TestPlanDBModel queryTestPlan(@PathVariable UUID runId)
|
||||||
throws Bench4QException {
|
throws Bench4QException {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
throw new Bench4QException(HAVE_NO_POWER, HAVE_NO_POWER,
|
throw new Bench4QException(HAVE_NO_POWER, HAVE_NO_POWER, "/{runId}");
|
||||||
"/queryTestPlan/{runId}");
|
|
||||||
}
|
}
|
||||||
return this.getTestPlanService().getTestPlanDBModel(runId);
|
return this.getTestPlanService().getTestPlanDBModel(runId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/removeTestPlanFromPool", method = {
|
@RequestMapping(value = "/{testPlanId}", method = { RequestMethod.DELETE })
|
||||||
RequestMethod.GET, RequestMethod.POST })
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanResponseModel removeTestPlanFromPool(int testPlanId) {
|
public TestPlanResponseModel removeTestPlanFromPool(
|
||||||
|
@PathVariable int testPlanId) {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
return buildTestPlanResponseModel(false, "no scope", null, null);
|
return buildTestPlanResponseModel(false, "no scope", null);
|
||||||
}
|
}
|
||||||
return buildTestPlanResponseModel(
|
return buildTestPlanResponseModel(
|
||||||
this.testPlanService.removeTestPlanInDB(testPlanId), null,
|
this.testPlanService.removeTestPlanInDB(testPlanId), null, null);
|
||||||
null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestPlanResponseModel buildTestPlanResponseModel(boolean success,
|
private TestPlanResponseModel buildTestPlanResponseModel(boolean success,
|
||||||
String failCause, List<TestPlan> testPlanDBs,
|
String failCause, List<TestPlan> testPlanDBs) {
|
||||||
String[] filterTypeList) {
|
|
||||||
TestPlanResponseModel result = new TestPlanResponseModel();
|
TestPlanResponseModel result = new TestPlanResponseModel();
|
||||||
result.setSuccess(success);
|
result.setSuccess(success);
|
||||||
result.setFailCause(failCause);
|
result.setFailCause(failCause);
|
||||||
|
@ -252,16 +245,14 @@ public class TestPlanController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.setTestPlanDBModels(modelList);
|
result.setTestPlanDBModels(modelList);
|
||||||
result.setFilterTypeList(filterTypeList);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getTestPlanReport", method = { RequestMethod.GET,
|
@RequestMapping(value = "/{testPlanRunID}/report", method = { RequestMethod.GET })
|
||||||
RequestMethod.POST })
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void getTestPlanReport(HttpServletResponse response,
|
public void getTestPlanReport(HttpServletResponse response,
|
||||||
@RequestParam UUID testPlanRunID) throws Bench4QException {
|
@PathVariable UUID testPlanRunID) throws Bench4QException {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
throw new Bench4QException(HAVE_NO_POWER,
|
throw new Bench4QException(HAVE_NO_POWER,
|
||||||
"You have no power to get test plan report",
|
"You have no power to get test plan report",
|
||||||
|
@ -290,7 +281,7 @@ public class TestPlanController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/latestResult")
|
@RequestMapping(value = "/{testPlanId}/scriptBrief/{scriptId}/latestResult", method = RequestMethod.GET)
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ScriptBriefResultModel getLatestScriptResult(
|
public ScriptBriefResultModel getLatestScriptResult(
|
||||||
|
@ -304,7 +295,7 @@ public class TestPlanController extends BaseController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/stop/{testPlanId}")
|
@RequestMapping(value = "/{testPlanId}/stop", method = RequestMethod.POST)
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TestPlanResponseModel stop(@PathVariable UUID testPlanId)
|
public TestPlanResponseModel stop(@PathVariable UUID testPlanId)
|
||||||
|
@ -314,7 +305,7 @@ public class TestPlanController extends BaseController {
|
||||||
guardIsTheOwner(testPlanId);
|
guardIsTheOwner(testPlanId);
|
||||||
return buildTestPlanResponseModel(
|
return buildTestPlanResponseModel(
|
||||||
this.getTestPlanRunner().stop(testPlanId), "",
|
this.getTestPlanRunner().stop(testPlanId), "",
|
||||||
Collections.<TestPlan> emptyList(), null);
|
Collections.<TestPlan> emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void guardIsTheOwner(UUID testPlanId) {
|
private void guardIsTheOwner(UUID testPlanId) {
|
||||||
|
@ -325,19 +316,4 @@ public class TestPlanController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/loadFilterTypeList", method = {
|
|
||||||
RequestMethod.POST, RequestMethod.GET })
|
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
|
||||||
@ResponseBody
|
|
||||||
public TestPlanResponseModel loadFilterTypeList() throws Bench4QException {
|
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
|
||||||
throw new Bench4QException(HAVE_NO_POWER,
|
|
||||||
"You don't have enough power to get filter type list!",
|
|
||||||
"/loadFilterTypeList");
|
|
||||||
}
|
|
||||||
String[] filterTypeList = this.getTestPlanService()
|
|
||||||
.loadFilterTypeList();
|
|
||||||
return this
|
|
||||||
.buildTestPlanResponseModel(true, null, null, filterTypeList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package org.bench4q.master.domain.service;
|
package org.bench4q.master.domain.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -22,6 +26,7 @@ public class ScriptService {
|
||||||
private ScriptRepositoty scriptRepositoty;
|
private ScriptRepositoty scriptRepositoty;
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
private Logger logger = Logger.getLogger(ScriptService.class);
|
private Logger logger = Logger.getLogger(ScriptService.class);
|
||||||
|
private Properties properties = null;
|
||||||
|
|
||||||
private ScriptRepositoty getScriptRepositoty() {
|
private ScriptRepositoty getScriptRepositoty() {
|
||||||
return scriptRepositoty;
|
return scriptRepositoty;
|
||||||
|
@ -120,4 +125,29 @@ public class ScriptService {
|
||||||
return this.getScriptRepositoty().update(script);
|
return this.getScriptRepositoty().update(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: refactor this, it's not good here in this format
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String[] loadFilterTypeList() {
|
||||||
|
return getFilterTypeList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getFilterTypeList() {
|
||||||
|
if (properties == null) {
|
||||||
|
try {
|
||||||
|
properties = new Properties();
|
||||||
|
InputStream inputStream = ScriptService.class
|
||||||
|
.getClassLoader()
|
||||||
|
.getResourceAsStream(
|
||||||
|
"org/bench4q/master/config/FilterType.properties");
|
||||||
|
properties.load(inputStream);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return properties.getProperty("filter.type.list", "").split(",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package org.bench4q.master.domain.service;
|
package org.bench4q.master.domain.service;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -28,8 +25,6 @@ import org.springframework.stereotype.Component;
|
||||||
public class TestPlanService {
|
public class TestPlanService {
|
||||||
private BusinessModelMapFactory businessMapFactory;
|
private BusinessModelMapFactory businessMapFactory;
|
||||||
private TestPlanRepository testPlanRepository;
|
private TestPlanRepository testPlanRepository;
|
||||||
|
|
||||||
private Properties properties = null;
|
|
||||||
|
|
||||||
private TestPlanRepository getTestPlanRepository() {
|
private TestPlanRepository getTestPlanRepository() {
|
||||||
return testPlanRepository;
|
return testPlanRepository;
|
||||||
|
@ -101,23 +96,5 @@ public class TestPlanService {
|
||||||
public Collection<TestPlan> loadAllRunningTestPlans() {
|
public Collection<TestPlan> loadAllRunningTestPlans() {
|
||||||
return this.getTestPlanRepository().loadRunningTestPlans();
|
return this.getTestPlanRepository().loadRunningTestPlans();
|
||||||
}
|
}
|
||||||
public String[] loadFilterTypeList() {
|
|
||||||
return getFilterTypeList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getFilterTypeList(){
|
|
||||||
if(properties == null){
|
|
||||||
try {
|
|
||||||
properties = new Properties();
|
|
||||||
InputStream inputStream = ScriptService.class.getClassLoader()
|
|
||||||
.getResourceAsStream(
|
|
||||||
"org/bench4q/master/config/FilterType.properties");
|
|
||||||
properties.load(inputStream);
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return properties.getProperty("filter.type.list","").split(",");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ public class HttpRequester {
|
||||||
|
|
||||||
public HttpResponse sendGet(String url, Map<String, String> params,
|
public HttpResponse sendGet(String url, Map<String, String> params,
|
||||||
Map<String, String> properties) throws IOException {
|
Map<String, String> properties) throws IOException {
|
||||||
|
|
||||||
return this.send(url, "GET", params, "", properties);
|
return this.send(url, "GET", params, "", properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.bench4q.share.models.master;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
public class ScriptFilterModel {
|
||||||
|
private String[] filterTypeList;
|
||||||
|
|
||||||
|
public String[] getFilterTypeList() {
|
||||||
|
return filterTypeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterTypeList(String[] filterTypeList) {
|
||||||
|
this.filterTypeList = filterTypeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScriptFilterModel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScriptFilterModel(String[] filterTypeList) {
|
||||||
|
this.filterTypeList = filterTypeList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,6 @@ public class TestPlanResponseModel {
|
||||||
private boolean success;
|
private boolean success;
|
||||||
private String failCause;
|
private String failCause;
|
||||||
private List<TestPlanDBModel> testPlanDBModels;
|
private List<TestPlanDBModel> testPlanDBModels;
|
||||||
private String[] filterTypeList;
|
|
||||||
|
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
|
@ -41,12 +40,4 @@ public class TestPlanResponseModel {
|
||||||
this.testPlanDBModels = testPlanDBModels;
|
this.testPlanDBModels = testPlanDBModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getFilterTypeList() {
|
|
||||||
return filterTypeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFilterTypeList(String[] filterTypeList) {
|
|
||||||
this.filterTypeList = filterTypeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -16,6 +17,7 @@ import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||||
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
||||||
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
||||||
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
||||||
|
import org.bench4q.share.models.master.ScriptFilterModel;
|
||||||
import org.bench4q.share.models.master.ScriptModel;
|
import org.bench4q.share.models.master.ScriptModel;
|
||||||
import org.bench4q.web.masterMessager.ScriptMessager;
|
import org.bench4q.web.masterMessager.ScriptMessager;
|
||||||
import org.bench4q.web.model.ScenarioModel;
|
import org.bench4q.web.model.ScenarioModel;
|
||||||
|
@ -283,9 +285,8 @@ public class ScriptController extends BaseController {
|
||||||
@ModelAttribute("accessToken") String accessToken,
|
@ModelAttribute("accessToken") String accessToken,
|
||||||
@RequestParam String port) {
|
@RequestParam String port) {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
OperateScriptServerResponseModel operateScriptServerResponseModel =
|
OperateScriptServerResponseModel operateScriptServerResponseModel = this
|
||||||
this.getScriptMessager().startRecording(accessToken,
|
.getScriptMessager().startRecording(accessToken, port);
|
||||||
port);
|
|
||||||
if (operateScriptServerResponseModel.isSuccess()) {
|
if (operateScriptServerResponseModel.isSuccess()) {
|
||||||
map = success(map);
|
map = success(map);
|
||||||
map.put("server", operateScriptServerResponseModel);
|
map.put("server", operateScriptServerResponseModel);
|
||||||
|
@ -322,11 +323,11 @@ public class ScriptController extends BaseController {
|
||||||
@RequestMapping("testRecordProxy")
|
@RequestMapping("testRecordProxy")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, Object> testRecordProxy(
|
public Map<String, Object> testRecordProxy(
|
||||||
@RequestHeader HttpHeaders headers,@RequestParam String port) {
|
@RequestHeader HttpHeaders headers, @RequestParam String port) {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
// is from proxy
|
// is from proxy
|
||||||
String proxyPort = headers.getFirst("FromProxyPort");
|
String proxyPort = headers.getFirst("FromProxyPort");
|
||||||
if (proxyPort!=null && proxyPort.equals(port)) {
|
if (proxyPort != null && proxyPort.equals(port)) {
|
||||||
success(map);
|
success(map);
|
||||||
} else {
|
} else {
|
||||||
fail(map, "proxy setting error!");
|
fail(map, "proxy setting error!");
|
||||||
|
@ -412,4 +413,14 @@ public class ScriptController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("loadFilterTypeList")
|
||||||
|
public @ResponseBody Map<String, Object> loadFilterTypeList(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@ModelAttribute("accessToken") String accessToken) {
|
||||||
|
ScriptFilterModel responseModel = this.getScriptMessager()
|
||||||
|
.loadFilterTypeList(accessToken);
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("filterTypeList", responseModel.getFilterTypeList());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -421,19 +420,4 @@ public class TestPlanController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("loadFilterTypeList")
|
|
||||||
public @ResponseBody Map<String, Object> loadFilterTypeList(
|
|
||||||
HttpServletRequest request,
|
|
||||||
@ModelAttribute("accessToken") String accessToken) {
|
|
||||||
TestPlanResponseModel responseModel = this.getTestPlanMessager()
|
|
||||||
.loadFilterTypeList(accessToken);
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
|
||||||
if (responseModel.isSuccess()) {
|
|
||||||
map.put("filterTypeList", responseModel.getFilterTypeList());
|
|
||||||
success(map);
|
|
||||||
} else {
|
|
||||||
fail(map, responseModel.getFailCause());
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import javax.xml.bind.JAXBException;
|
||||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||||
import org.bench4q.share.helper.MarshalHelper;
|
import org.bench4q.share.helper.MarshalHelper;
|
||||||
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
||||||
|
import org.bench4q.share.models.master.ScriptFilterModel;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@ -26,16 +27,16 @@ public class ScriptMessager extends MasterMessager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperateScriptServerResponseModel startRecording(
|
public OperateScriptServerResponseModel startRecording(String accessToken,
|
||||||
String accessToken, String port) {
|
String port) {
|
||||||
String url = this.getBaseUrl() + "/startScriptRecording";
|
String url = this.getBaseUrl() + "/startScriptRecording";
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("port", port);
|
params.put("port", port);
|
||||||
// params.put("fileNameUUID", fileNameUUID);
|
// params.put("fileNameUUID", fileNameUUID);
|
||||||
return this.getOperateScriptServerResponseModelByPost(url, params,
|
return this.getOperateScriptServerResponseModelByPost(url, params,
|
||||||
accessToken);
|
accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperateScriptServerResponseModel stopScriptRecordServer(
|
public OperateScriptServerResponseModel stopScriptRecordServer(
|
||||||
String accessToken, String port, String fileNameUUID) {
|
String accessToken, String port, String fileNameUUID) {
|
||||||
String url = this.getBaseUrl() + "/stopScriptRecordServer";
|
String url = this.getBaseUrl() + "/stopScriptRecordServer";
|
||||||
|
@ -55,7 +56,7 @@ public class ScriptMessager extends MasterMessager {
|
||||||
return this.getOperateScriptServerResponseModelByPost(url, params,
|
return this.getOperateScriptServerResponseModelByPost(url, params,
|
||||||
accessToken);
|
accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperateScriptServerResponseModel saveScriptRecorded(
|
public OperateScriptServerResponseModel saveScriptRecorded(
|
||||||
String accessToken, String scriptName, String port,
|
String accessToken, String scriptName, String port,
|
||||||
String fileNameUUID) {
|
String fileNameUUID) {
|
||||||
|
@ -128,7 +129,7 @@ public class ScriptMessager extends MasterMessager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperateScriptServerResponseModel updateScript(String accessToken,
|
public OperateScriptServerResponseModel updateScript(String accessToken,
|
||||||
String scriptId,String scriptContent, String scriptName) {
|
String scriptId, String scriptContent, String scriptName) {
|
||||||
String url = this.getBaseUrl() + "/updateScript" + "/" + scriptId;
|
String url = this.getBaseUrl() + "/updateScript" + "/" + scriptId;
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("content", scriptContent);
|
params.put("content", scriptContent);
|
||||||
|
@ -138,31 +139,32 @@ public class ScriptMessager extends MasterMessager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public OperateScriptServerResponseModel updateScript(String accessToken,
|
// public OperateScriptServerResponseModel updateScript(String accessToken,
|
||||||
// String scriptId, String scenarioModel,String scriptName, MultipartFile[] paramFiles) {
|
// String scriptId, String scenarioModel,String scriptName, MultipartFile[]
|
||||||
// String url = this.getBaseUrl() + "/updateScript" + "/" + scriptId;
|
// paramFiles) {
|
||||||
// List<String> stringPart = new LinkedList<String>();
|
// String url = this.getBaseUrl() + "/updateScript" + "/" + scriptId;
|
||||||
// stringPart.add(scenarioModel);
|
// List<String> stringPart = new LinkedList<String>();
|
||||||
// stringPart.add(scriptName);
|
// stringPart.add(scenarioModel);
|
||||||
// HttpResponse httpResponse = null;
|
// stringPart.add(scriptName);
|
||||||
//
|
// HttpResponse httpResponse = null;
|
||||||
// try {
|
//
|
||||||
// httpResponse = this.getHttpRequester().postFilesMulti(
|
// try {
|
||||||
// makeAccessTockenMap(accessToken), url, "paramFiles[]",
|
// httpResponse = this.getHttpRequester().postFilesMulti(
|
||||||
// paramFiles, "paramContents[]", stringPart);
|
// makeAccessTockenMap(accessToken), url, "paramFiles[]",
|
||||||
// if (!validateHttpResponse(httpResponse))
|
// paramFiles, "paramContents[]", stringPart);
|
||||||
// return null;
|
// if (!validateHttpResponse(httpResponse))
|
||||||
// return (OperateScriptServerResponseModel) MarshalHelper.unmarshal(
|
// return null;
|
||||||
// OperateScriptServerResponseModel.class,
|
// return (OperateScriptServerResponseModel) MarshalHelper.unmarshal(
|
||||||
// httpResponse.getContent());
|
// OperateScriptServerResponseModel.class,
|
||||||
//
|
// httpResponse.getContent());
|
||||||
// } catch (Exception e) {
|
//
|
||||||
// this.handleException(httpResponse, e);
|
// } catch (Exception e) {
|
||||||
// return createFailOperateScriptServerResponseModel();
|
// this.handleException(httpResponse, e);
|
||||||
// }
|
// return createFailOperateScriptServerResponseModel();
|
||||||
//
|
// }
|
||||||
// }
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
public OperateScriptServerResponseModel loadScripts(String accessToken) {
|
public OperateScriptServerResponseModel loadScripts(String accessToken) {
|
||||||
String url = this.getBaseUrl() + "/loadScriptList";
|
String url = this.getBaseUrl() + "/loadScriptList";
|
||||||
return this.getOperateScriptServerResponseModelByPost(url, null,
|
return this.getOperateScriptServerResponseModelByPost(url, null,
|
||||||
|
@ -196,8 +198,6 @@ public class ScriptMessager extends MasterMessager {
|
||||||
accessToken);
|
accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private OperateScriptServerResponseModel getOperateScriptServerResponseModelByPost(
|
private OperateScriptServerResponseModel getOperateScriptServerResponseModelByPost(
|
||||||
String url, Map<String, String> params, String accessToken) {
|
String url, Map<String, String> params, String accessToken) {
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
|
@ -228,4 +228,22 @@ public class ScriptMessager extends MasterMessager {
|
||||||
OperateScriptServerResponseModel.class,
|
OperateScriptServerResponseModel.class,
|
||||||
httpResponse.getContent());
|
httpResponse.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScriptFilterModel loadFilterTypeList(String accessToken) {
|
||||||
|
String url = this.getBaseUrl() + "/loadFilterTypeList";
|
||||||
|
HttpResponse httpResponse = null;
|
||||||
|
try {
|
||||||
|
httpResponse = this.getHttpRequester().sendGet(url, null,
|
||||||
|
makeAccessTockenMap(accessToken));
|
||||||
|
if (!validateHttpResponse(httpResponse)) {
|
||||||
|
handleInvalidatedResponse(url);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (ScriptFilterModel) MarshalHelper.tryUnmarshal(
|
||||||
|
ScriptFilterModel.class, httpResponse.getContent());
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.handleException(httpResponse, e);
|
||||||
|
return new ScriptFilterModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
String url = this.getBaseUrl() + "/run";
|
String url = this.getBaseUrl() + "/run";
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
httpResponse = this.getHttpRequester().sendPostXml(url,
|
httpResponse = this.getHttpRequester().sendPutXml(url,
|
||||||
testPlanXmlContent, makeAccessTockenMap(accessToken));
|
testPlanXmlContent, makeAccessTockenMap(accessToken));
|
||||||
if (!validateHttpResponse(httpResponse))
|
if (!validateHttpResponse(httpResponse))
|
||||||
return null;
|
return null;
|
||||||
|
@ -62,17 +62,26 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public TestPlanResultModel getRunningTestInfo(String accessToken,
|
public TestPlanResultModel getRunningTestInfo(String accessToken,
|
||||||
String testPlanId) {
|
String testPlanId) {
|
||||||
String url = this.getBaseUrl() + "/getRunningInfo";
|
String url = this.getBaseUrl() + "/" + testPlanId.toString()
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
+ "/runningInfo";
|
||||||
params.put("testPlanId", testPlanId);
|
HttpResponse httpResponse = null;
|
||||||
return this.getTestPlanResultModelByPost(url, params, accessToken);
|
try {
|
||||||
|
|
||||||
|
httpResponse = this.getHttpRequester().sendGet(url, null,
|
||||||
|
makeAccessTockenMap(accessToken));
|
||||||
|
if (!validateHttpResponse(httpResponse))
|
||||||
|
return null;
|
||||||
|
return extractTestPlanResultModel(httpResponse);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.handleException(httpResponse, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanScriptBriefResultModel getScriptBriefResult(
|
public TestPlanScriptBriefResultModel getScriptBriefResult(
|
||||||
String accessToken, String testPlanId, String scriptId,
|
String accessToken, String testPlanId, String scriptId,
|
||||||
String duationBegin) {
|
String duationBegin) {
|
||||||
String url = this.getBaseUrl() + "/scriptBrief" + "/" + testPlanId
|
String url = this.getBaseUrl() + "/" + testPlanId + "/scriptBrief"
|
||||||
+ "/" + scriptId + "/" + duationBegin;
|
+ "/" + scriptId + "/" + duationBegin;
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
|
@ -94,8 +103,8 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public ScriptBehaviorsBriefModel getScriptBehaviorsBriefResult(
|
public ScriptBehaviorsBriefModel getScriptBehaviorsBriefResult(
|
||||||
String accessToken, String testPlanId, String scriptId) {
|
String accessToken, String testPlanId, String scriptId) {
|
||||||
String url = this.getBaseUrl() + "/getBehaviorsBrief" + "/"
|
String url = this.getBaseUrl() + "/" + testPlanId + "/behaviorsBrief"
|
||||||
+ testPlanId + "/" + scriptId;
|
+ "/" + scriptId;
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
httpResponse = this.getHttpRequester().sendGet(url, null,
|
httpResponse = this.getHttpRequester().sendGet(url, null,
|
||||||
|
@ -113,7 +122,7 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public TestPlanDBModel queryTestPlanById(String accessToken,
|
public TestPlanDBModel queryTestPlanById(String accessToken,
|
||||||
String testPlanRunId) {
|
String testPlanRunId) {
|
||||||
String url = this.getBaseUrl() + "/queryTestPlan" + "/" + testPlanRunId;
|
String url = this.getBaseUrl() + "/" + testPlanRunId;
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
httpResponse = this.getHttpRequester().sendGet(url, null,
|
httpResponse = this.getHttpRequester().sendGet(url, null,
|
||||||
|
@ -133,26 +142,48 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public TestPlanResponseModel deleteTestPlan(String accessToken,
|
public TestPlanResponseModel deleteTestPlan(String accessToken,
|
||||||
String testPlanId) {
|
String testPlanId) {
|
||||||
String url = this.getBaseUrl() + "/removeTestPlanFromPool";
|
String url = this.getBaseUrl() + "/" + testPlanId;
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
HttpResponse httpResponse = null;
|
||||||
params.put("testPlanId", testPlanId);
|
try {
|
||||||
return getTestPlanResponseModel(url, params, accessToken);
|
httpResponse = this.getHttpRequester().sendDelete(url, null,
|
||||||
|
makeAccessTockenMap(accessToken));
|
||||||
|
if (!validateHttpResponse(httpResponse)) {
|
||||||
|
handleInvalidatedResponse(url);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return extractTestPlanResponseModel(httpResponse);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.handleException(httpResponse, e);
|
||||||
|
return createFailTestPlanResponseModel();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanResponseModel loadTestPlans(String accessToken) {
|
public TestPlanResponseModel loadTestPlans(String accessToken) {
|
||||||
String url = this.getBaseUrl() + "/loadTestPlans";
|
String url = this.getBaseUrl() + "/";
|
||||||
return getTestPlanResponseModel(url, null, accessToken);
|
HttpResponse httpResponse = null;
|
||||||
|
try {
|
||||||
|
httpResponse = this.getHttpRequester().sendGet(url, null,
|
||||||
|
makeAccessTockenMap(accessToken));
|
||||||
|
if (!validateHttpResponse(httpResponse)) {
|
||||||
|
handleInvalidatedResponse(url);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return extractTestPlanResponseModel(httpResponse);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.handleException(httpResponse, e);
|
||||||
|
return createFailTestPlanResponseModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpResponse getTestPlanReport(String accessToken,
|
public HttpResponse getTestPlanReport(String accessToken,
|
||||||
String testPlanRunId) {
|
String testPlanRunId) {
|
||||||
String url = this.getBaseUrl() + "/getTestPlanReport";
|
String url = this.getBaseUrl() + "/" + testPlanRunId + "/report";
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("testPlanRunID", testPlanRunId);
|
params.put("testPlanRunID", testPlanRunId);
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
httpResponse = this.getHttpRequester().sendPost(url, params,
|
httpResponse = this.getHttpRequester().sendGet(url, params,
|
||||||
makeAccessTockenMap(accessToken));
|
makeAccessTockenMap(accessToken));
|
||||||
if (!validateHttpResponse(httpResponse))
|
if (!validateHttpResponse(httpResponse))
|
||||||
return null;
|
return null;
|
||||||
|
@ -164,25 +195,6 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestPlanResponseModel getTestPlanResponseModel(String url,
|
|
||||||
Map<String, String> params, String accessToken) {
|
|
||||||
HttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
httpResponse = this.getHttpRequester().sendPost(url, params,
|
|
||||||
makeAccessTockenMap(accessToken));
|
|
||||||
if (!validateHttpResponse(httpResponse)) {
|
|
||||||
handleInvalidatedResponse(url);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return extractTestPlanResponseModel(httpResponse);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.handleException(httpResponse, e);
|
|
||||||
return createFailTestPlanResponseModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestPlanResponseModel createFailTestPlanResponseModel() {
|
private TestPlanResponseModel createFailTestPlanResponseModel() {
|
||||||
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
|
TestPlanResponseModel testPlanResponseModel = new TestPlanResponseModel();
|
||||||
testPlanResponseModel.setSuccess(false);
|
testPlanResponseModel.setSuccess(false);
|
||||||
|
@ -190,22 +202,6 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
return testPlanResponseModel;
|
return testPlanResponseModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestPlanResultModel getTestPlanResultModelByPost(String url,
|
|
||||||
Map<String, String> params, String accessToken) {
|
|
||||||
HttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
httpResponse = this.getHttpRequester().sendPost(url, params,
|
|
||||||
makeAccessTockenMap(accessToken));
|
|
||||||
if (!validateHttpResponse(httpResponse))
|
|
||||||
return null;
|
|
||||||
return extractTestPlanResultModel(httpResponse);
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.handleException(httpResponse, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestPlanResponseModel extractTestPlanResponseModel(
|
private TestPlanResponseModel extractTestPlanResponseModel(
|
||||||
HttpResponse httpResponse) throws JAXBException,
|
HttpResponse httpResponse) throws JAXBException,
|
||||||
UnsupportedEncodingException {
|
UnsupportedEncodingException {
|
||||||
|
@ -223,7 +219,7 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public ScriptBriefResultModel getLatestScriptBriefResult(
|
public ScriptBriefResultModel getLatestScriptBriefResult(
|
||||||
String accessToken, String testPlanId, String scriptId) {
|
String accessToken, String testPlanId, String scriptId) {
|
||||||
String url = this.baseUrl + "/scriptBrief" + "/" + testPlanId + "/"
|
String url = this.baseUrl + "/" + testPlanId + "/scriptBrief" + "/"
|
||||||
+ scriptId + "/latestResult";
|
+ scriptId + "/latestResult";
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
|
@ -233,7 +229,8 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
handleInvalidatedResponse(url);
|
handleInvalidatedResponse(url);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
System.out.println("getLatestScriptBriefResult:\r\n"+httpResponse.getContent());
|
System.out.println("getLatestScriptBriefResult:\r\n"
|
||||||
|
+ httpResponse.getContent());
|
||||||
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
|
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
|
||||||
ScriptBriefResultModel.class, httpResponse.getContent());
|
ScriptBriefResultModel.class, httpResponse.getContent());
|
||||||
|
|
||||||
|
@ -245,7 +242,7 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public ScriptPagesBriefModel getScriptPageBriefModel(String accessToken,
|
public ScriptPagesBriefModel getScriptPageBriefModel(String accessToken,
|
||||||
String testPlanId, String scriptId) {
|
String testPlanId, String scriptId) {
|
||||||
String url = this.baseUrl + "/pagesBrief" + "/" + testPlanId + "/"
|
String url = this.baseUrl + "/" + testPlanId + "/pagesBrief" + "/"
|
||||||
+ scriptId;
|
+ scriptId;
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
|
@ -266,12 +263,20 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
|
|
||||||
public TestPlanResponseModel stopTestPlan(String accessToken,
|
public TestPlanResponseModel stopTestPlan(String accessToken,
|
||||||
String testPlanRunId) {
|
String testPlanRunId) {
|
||||||
String url = this.baseUrl + "/stop" + "/" + testPlanRunId;
|
String url = this.baseUrl + "/" + testPlanRunId + "/stop";
|
||||||
return getTestPlanResponseModel(url, null, accessToken);
|
HttpResponse httpResponse = null;
|
||||||
|
try {
|
||||||
|
httpResponse = this.getHttpRequester().sendPost(url, null,
|
||||||
|
makeAccessTockenMap(accessToken));
|
||||||
|
if (!validateHttpResponse(httpResponse)) {
|
||||||
|
handleInvalidatedResponse(url);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return extractTestPlanResponseModel(httpResponse);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.handleException(httpResponse, e);
|
||||||
|
return createFailTestPlanResponseModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanResponseModel loadFilterTypeList(String accessToken) {
|
|
||||||
String url = this.getBaseUrl() + "/loadFilterTypeList";
|
|
||||||
return getTestPlanResponseModel(url, null, accessToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue