From fbf4d6fb15ab0ca6c0a364c8107fa20ebb37c9f2 Mon Sep 17 00:00:00 2001 From: fanfuxiaoran <495538672@qq.com> Date: Fri, 22 Aug 2014 11:09:32 +0800 Subject: [PATCH 1/5] add stop to testplan --- .../src/main/resources/ipConfig.properties | 2 +- .../webapp/WEB-INF/classes/i18n_en.properties | 5 +-- .../webapp/WEB-INF/classes/i18n_zh.properties | 2 ++ .../src/main/webapp/i18n/i18n.properties | 3 +- .../main/webapp/i18n/i18n_zh-CN.properties | 3 +- Bench4Q-Web/src/main/webapp/result.jsp | 11 +++++-- .../main/webapp/script/testResult/result.js | 33 +++++++++++++++---- .../src/test/resources/ipConfig.properties | 2 +- 8 files changed, 45 insertions(+), 16 deletions(-) diff --git a/Bench4Q-Web/src/main/resources/ipConfig.properties b/Bench4Q-Web/src/main/resources/ipConfig.properties index 06535e4f..8184dc34 100644 --- a/Bench4Q-Web/src/main/resources/ipConfig.properties +++ b/Bench4Q-Web/src/main/resources/ipConfig.properties @@ -1 +1 @@ -masterAddress=133.133.2.100:8901 \ No newline at end of file +masterAddress=127.0.0.1:8901 \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_en.properties b/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_en.properties index e3ee66df..5e14671b 100644 --- a/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_en.properties +++ b/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_en.properties @@ -204,5 +204,6 @@ staticTip=The static resources contains:js,css,jpeg,gif,png files. timeTipe=The Think time refers the time between tow behaviors. startServer=start server to generate a script or upload a script to server testExecuteTime=Execute Time - -startServerFail=Fail to start record server: \ No newline at end of file +startServerFail=Fail to start record server: +stopTestPlan=Stop Test +stop=Stop \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_zh.properties b/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_zh.properties index b30aaa2f..360262ac 100644 --- a/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_zh.properties +++ b/Bench4Q-Web/src/main/webapp/WEB-INF/classes/i18n_zh.properties @@ -206,3 +206,5 @@ staticTip=\u9759\u6001\u8D44\u6E90\u4E3B\u8981\u662F\u6307:js,css,jpeg,gif,png\u timeTip=\u601D\u8003\u65F6\u95F4\u6307\u7684\u662F\u7528\u6237\u4E24\u4E2A\u8FDE\u7EED\u884C\u4E3A\u4E4B\u95F4\u7684\u95F4\u9694\u65F6\u95F4 startServer=\u70B9\u51FB\u542F\u52A8\u670D\u52A1\u5F55\u5236\u811A\u672C\u6216\u8005\u4E0A\u4F20\u811A\u672C\u6587\u4EF6 testExecuteTime=\u6267\u884C\u65F6\u95F4 +stopTestPlan=\u505C\u6B62\u6D4B\u8BD5 +stop=\u505C\u6B62 diff --git a/Bench4Q-Web/src/main/webapp/i18n/i18n.properties b/Bench4Q-Web/src/main/webapp/i18n/i18n.properties index e233f632..eb379906 100644 --- a/Bench4Q-Web/src/main/webapp/i18n/i18n.properties +++ b/Bench4Q-Web/src/main/webapp/i18n/i18n.properties @@ -44,4 +44,5 @@ recordScript=Record Script stopRecord=The script recording has been stopped, please input the script name and save it. saveScriptSuccess=Save successfully. saveScriptFail=Fail to save script. -plugin_jsp_addPage=Add Page \ No newline at end of file +plugin_jsp_addPage=Add Page +stopTestPlan_fail=Stop running test plan fail \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties b/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties index 91d45e55..4ad94669 100644 --- a/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties +++ b/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties @@ -40,4 +40,5 @@ recordScript=\u5F55\u5236\u811A\u672C stopRecord=\u505C\u6B62\u811A\u672C\u5F55\u5236\uFF0C\u8BF7\u8F93\u5165\u811A\u672C\u540D\u79F0\uFF0C\u4FDD\u5B58\u811A\u672C saveScriptSuccess=\u4FDD\u5B58\u6210\u529F\u3002 saveScriptFail=\u4FDD\u5B58\u811A\u672C\u5931\u8D25 -plugin_jsp_addPage=\u52A0\u9875 \ No newline at end of file +plugin_jsp_addPage=\u52A0\u9875 +stopTestPlan_fail=\u505C\u6B62\u8FD0\u884C\u6D4B\u8BD5\u8BA1\u5212\u5931\u8D25 \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/result.jsp b/Bench4Q-Web/src/main/webapp/result.jsp index 1cf3a318..87d327f3 100644 --- a/Bench4Q-Web/src/main/webapp/result.jsp +++ b/Bench4Q-Web/src/main/webapp/result.jsp @@ -67,23 +67,28 @@ body { --%>
-
+


-
+


-
+


+
+ +

+ +

diff --git a/Bench4Q-Web/src/main/webapp/script/testResult/result.js b/Bench4Q-Web/src/main/webapp/script/testResult/result.js index 5fbf517a..00847824 100644 --- a/Bench4Q-Web/src/main/webapp/script/testResult/result.js +++ b/Bench4Q-Web/src/main/webapp/script/testResult/result.js @@ -1,22 +1,22 @@ var loadItems = new loadItems(); $(function() { - var testPlanId = getvars()['testPlanId']; - var testPlan = getTestInfo(testPlanId); + var testPlanRunId = getvars()['testPlanId']; + var testPlan = getTestInfo(testPlanRunId); $("#testplanName").html(testPlan.testPlanName); $("#createTime").html(new Date(testPlan.createDateTime)); $("#testTime").html(testPlan.executeTime) if (!(testPlan.currentStatus == "InRunning" || testPlan.currentStatus == "Complete")) { return; } - getTestBrief(testPlanId); + getTestBrief(testPlanRunId); // doProgress(); var pageResult = new PageResult(); - pageResult.loadPageResult(testPlanId, testPlan.scripts); + pageResult.loadPageResult(testPlanRunId, testPlan.scripts); var behavior = new Behavior(); - behavior.loadBehaviorResults(testPlanId, testPlan.scripts); - var tree = getResultTree(testPlanId); + behavior.loadBehaviorResults(testPlanRunId, testPlan.scripts); + var tree = getResultTree(testPlanRunId); if (tree == null) { alert($.i18n.prop('test-error')); } @@ -27,6 +27,25 @@ $(function() { getShowTreePathValues(tree)); chartSelector.initChart(); graphButtonListener(chartSelector); + + $("#stop-testplan").click(function() { + if ($("#status").attr("status") == "InRunning") { + $.post("stop/" + testPlanRunId, {}, function(data) { + if (data.success) { + $('#status').attr("status", "Complete"); + var testStatus = testStatusMap("Complete"); + $('#status').html("

" + testStatus + '

'); + } else { + alert($.i18n("stopTestPlan_fail")); + } + + }) + + } else { + return; + } + + }); }); function getTestInfo(testPlanId) { var testPlan; @@ -124,4 +143,4 @@ function getvars() { vars[hash[0]] = hash[1]; } return vars; -} \ No newline at end of file +} diff --git a/Bench4Q-Web/src/test/resources/ipConfig.properties b/Bench4Q-Web/src/test/resources/ipConfig.properties index d9539586..8184dc34 100644 --- a/Bench4Q-Web/src/test/resources/ipConfig.properties +++ b/Bench4Q-Web/src/test/resources/ipConfig.properties @@ -1 +1 @@ -masterAddress=127.0.0.1:6000 \ No newline at end of file +masterAddress=127.0.0.1:8901 \ No newline at end of file From 1b0fa87719223981e62e94001fedb927814b5196 Mon Sep 17 00:00:00 2001 From: hmm Date: Fri, 22 Aug 2014 14:09:49 +0800 Subject: [PATCH 2/5] success to create new script --- .../org/bench4q/web/api/ScriptController.java | 14 ++++---- .../main/webapp/script/editor/createScript.js | 5 +-- .../main/webapp/script/editor/submitScript.js | 35 +++++++++---------- .../main/webapp/script/editor/usePlugin.js | 11 +++--- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptController.java b/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptController.java index c1a3b837..975af565 100644 --- a/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptController.java +++ b/Bench4Q-Web/src/main/java/org/bench4q/web/api/ScriptController.java @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +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.SessionAttributes; @@ -209,17 +210,18 @@ public class ScriptController extends BaseController { operateScriptServerResponseModel.getFailCauseString()); } } - - @RequestMapping("submitScriptCreated/{scriptName}") + @RequestMapping(value="submitScriptCreated/{scriptName}") @ResponseBody public Map submitScriptCreated( @ModelAttribute("accessToken") String accessToken, -// @RequestBody ScenarioModel scenarioModel, - @RequestBody RunScenarioModel runScenarioModel, + @RequestParam String runScenarioModelStr, @PathVariable String scriptName, - @RequestParam(required = false) MultipartFile[] paramFiles) { - + @RequestParam(required = false) MultipartFile[] paramFiles + ) { Map map = new HashMap(); + Gson gson = new Gson(); + RunScenarioModel runScenarioModel = gson.fromJson(runScenarioModelStr, RunScenarioModel.class); + // RunScenarioModel runScenarioModel = this.getScriptService() // .createRunScenarioModel(scenarioModel.getUsePlugins(), // scenarioModel.getBehaviors()); diff --git a/Bench4Q-Web/src/main/webapp/script/editor/createScript.js b/Bench4Q-Web/src/main/webapp/script/editor/createScript.js index e401e386..8a383250 100644 --- a/Bench4Q-Web/src/main/webapp/script/editor/createScript.js +++ b/Bench4Q-Web/src/main/webapp/script/editor/createScript.js @@ -4,7 +4,8 @@ $(function() { // usePlugin.getPluginList(); $("#submitScript").click(function() { - var pages = behavior.getPages(); - submitScript(pages); + var plugins = usePlugin.getPlugins(); + var pages = usePlugin.getPages(); + submitScript(pages,plugins); }); }); diff --git a/Bench4Q-Web/src/main/webapp/script/editor/submitScript.js b/Bench4Q-Web/src/main/webapp/script/editor/submitScript.js index bba92970..3cb329e4 100644 --- a/Bench4Q-Web/src/main/webapp/script/editor/submitScript.js +++ b/Bench4Q-Web/src/main/webapp/script/editor/submitScript.js @@ -28,32 +28,29 @@ function CollectScriptData(behavior) { // this.behaviors = behaviors; //} -function submitScript(pages) { -// var usePlugins = scriptDataModel.usePlugin; -// var behaviors = collectScriptData.collectBehavior(); -// var scenarioModel = new ScenarioModel(usePlugins, behaviors); -// if (usePlugins.length == 0 || behaviors.length == 0) { -// return; -// } +function submitScript(pages,usePlugins) { + var scriptName = $("#scriptName").val(); if (scriptName == undefined || scriptName == "") { alert("need a script name!") return; } -// $.ajax({ -// type : "POST", -// url : "submitScriptCreated" + "/" + scriptName, -// data : JSON.stringify(scenarioModel), + var runScenarioModel = new RunScenarioModel(0,usePlugins,new Array(),pages); + + $.ajax({ + type : "POST", + url : "submitScriptCreated" + "/" + scriptName, + data :{runScenarioModelStr: JSON.stringify(runScenarioModel)},//JSON.stringify(runScenarioModel), // dataType : "json", // contentType : "application/json", -// success : function(data) { -// if (!data.success) { -// return; -// } else { -// alert("success"); -// } -// } -// }); + success : function(data) { + if (!data.success) { + return; + } else { + alert("success"); + } + } + }); } diff --git a/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js b/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js index 9a169527..6342a09a 100644 --- a/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js +++ b/Bench4Q-Web/src/main/webapp/script/editor/usePlugin.js @@ -8,9 +8,8 @@ function UsePluginViewModel(id, name) { function UsePlugin(behaviorListContainerId) { var containerId = "usePluginList"; // var usePlugin = this; - var behavior = new Behavior(this,"useBehaviorList"); - + var paramDataCollector = new DataCollector(); var index = 1; var usePluginEditorMap = new HashMap(); @@ -180,12 +179,10 @@ function UsePlugin(behaviorListContainerId) { for ( var i = 0; i < keys.length; i++) { var id = keys[i]; var usePluginViewModel = map.get(id); - - var usePluginContainer = usePluginEditorMap - .get(id); - var params = this.paramDataCollector.getUnitParams($( + var usePluginContainer = usePluginEditorMap.get(id); + var params = paramDataCollector.getUnitParams($( usePluginContainer).find(".editor")); - usePlugins.push(new UsePluginModel(usePluginViewModel.id, pluginName, params)); + usePlugins.push(new UsePluginModel(usePluginViewModel.id, usePluginViewModel.name,usePluginViewModel.nickName, params)); } return usePlugins; } From f47d025b38def6dbf42ec4738e5d85560bfa2b46 Mon Sep 17 00:00:00 2001 From: hmm Date: Fri, 22 Aug 2014 14:10:10 +0800 Subject: [PATCH 3/5] change BathcModel Id to id --- .../bench4q/share/models/agent/scriptrecord/BatchModel.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BatchModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BatchModel.java index 092f345d..5b747251 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BatchModel.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/scriptrecord/BatchModel.java @@ -9,18 +9,18 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "batch") public class BatchModel { - private int Id; + private int id; private int parentId; private int childId; private List behaviors = new ArrayList(); @XmlElement public int getId() { - return Id; + return id; } public void setId(int id) { - Id = id; + this.id = id; } @XmlElement From 4a0db1a002c3d501413f4354e9960a3b6462b00c Mon Sep 17 00:00:00 2001 From: luqiong <605601787@qq.com> Date: Fri, 22 Aug 2014 14:19:25 +0800 Subject: [PATCH 4/5] add init jstree of editEcript --- Bench4Q-Web/src/main/webapp/editScript.jsp | 4 +- .../script/ScriptEditor/scriptEditor.js | 44 +++++++++++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Bench4Q-Web/src/main/webapp/editScript.jsp b/Bench4Q-Web/src/main/webapp/editScript.jsp index 0098e003..e756fc92 100644 --- a/Bench4Q-Web/src/main/webapp/editScript.jsp +++ b/Bench4Q-Web/src/main/webapp/editScript.jsp @@ -20,6 +20,7 @@ + @@ -217,6 +218,7 @@ + @@ -228,7 +230,7 @@ - + diff --git a/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js b/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js index 080bec49..c501c10d 100644 --- a/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js +++ b/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js @@ -13,10 +13,10 @@ function getScriptObject(scriptId) { $.post("getScript", { scriptId : scriptId }, function(data) { - if (!data.success) { + /*if (!data.success) { alert("failed to get script:" + data.failedMessage); return; - } else { + } else {*/ // alert(data.script); var scriptObj = eval("(" + data.script + ")"); // createRadioGroupByAttribute(scriptObj.usePlugins, "nickName", "name","id","plugins", @@ -25,18 +25,44 @@ function getScriptObject(scriptId) { // // collectScriptData = new CollectScriptData(usePlugin, behavior); - + var index = 0; + var index2 = 0; + var pos; + var indexId = 1; var usePlugin = new UsePlugin(); - usePlugin.getPluginList(); + //init plugin - scriptObj.usePlugins; + while(index < scriptObj.usePlugins.length){ + jstreeCreateNode("usePluginList",scriptObj.usePlugins[index].name,scriptObj.usePlugins[index].name,scriptObj.usePlugins[index].id,"after"); + index++; + } + jstreeSelectNode("usePluginList", scriptObj.usePlugins[0].id); //init page, batch, behavior - scriptObj.pages; + index = 0; + jstreeCreateNode("useBehaviorList","page","page",indexId,"after"); + jstreeSelectNode("useBehaviorList", indexId); + indexId++; + while(index < scriptObj.pages.length){ //create_node("batch") + pos = "last"; + jstreeCreateNode("useBehaviorList","batch","batch",indexId,pos); + jstreeSelectNode("useBehaviorList", indexId); + indexId++; + var batches = scriptObj.pages[index].batches; + var index2 = 0; + while(index2 < batches.length){ //create_node("behavior") + jstreeCreateNode("useBehaviorList",batches[index2].behaviors[0].name,batches[index2].behaviors[0].name,indexId,pos); + jstreeSelectNode("useBehaviorList", indexId); + pos = "after"; + indexId++; + index2++; + if(index2 == batches.length) + jstreeSelectNode("useBehaviorList", 1); + } + index++; + } + jstreeSelectNode("useBehaviorList", 1); var behavior = new Behavior(); - - } - }, "json"); } From 8c88fd9076408b093fb96672706efe2d19b24dd1 Mon Sep 17 00:00:00 2001 From: luqiong <605601787@qq.com> Date: Fri, 22 Aug 2014 14:22:31 +0800 Subject: [PATCH 5/5] fix editScript --- .../src/main/webapp/script/ScriptEditor/scriptEditor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js b/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js index c501c10d..442f95a3 100644 --- a/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js +++ b/Bench4Q-Web/src/main/webapp/script/ScriptEditor/scriptEditor.js @@ -13,10 +13,10 @@ function getScriptObject(scriptId) { $.post("getScript", { scriptId : scriptId }, function(data) { - /*if (!data.success) { + if (!data.success) { alert("failed to get script:" + data.failedMessage); return; - } else {*/ + } else { // alert(data.script); var scriptObj = eval("(" + data.script + ")"); // createRadioGroupByAttribute(scriptObj.usePlugins, "nickName", "name","id","plugins", @@ -63,6 +63,7 @@ function getScriptObject(scriptId) { } jstreeSelectNode("useBehaviorList", 1); var behavior = new Behavior(); + } }, "json"); }