diff --git a/src/main/java/org/bench4q/web/TestPlan/RunTestPlan.java b/src/main/java/org/bench4q/web/TestPlan/RunTestPlan.java index 3b5ca4bb..7213bc08 100644 --- a/src/main/java/org/bench4q/web/TestPlan/RunTestPlan.java +++ b/src/main/java/org/bench4q/web/TestPlan/RunTestPlan.java @@ -12,7 +12,6 @@ import org.bench4q.share.models.master.TestPlanResultModel; import org.bench4q.share.models.master.TestScriptConfig; import org.bench4q.web.exception.CustomGenericException; import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange; -import org.bench4q.web.model.BaseResponseModel; import org.bench4q.web.model.ScriptModel; import org.bench4q.web.model.TestPlanRequestModel; import org.bench4q.web.model.TestPlanTaskModel; @@ -23,7 +22,7 @@ import org.springframework.ui.ModelMap; @Component //will to change static method======================== public class RunTestPlan extends BaseService { - public BaseResponseModel runTestPlan(String accessToken,TestPlanRequestModel testPlanRequestModel,ModelMap model) throws CustomGenericException{ + public void runTestPlan(String accessToken,TestPlanRequestModel testPlanRequestModel,ModelMap model) throws CustomGenericException{ String url = BaseService .getMasterIP() + "testPlan" + "/runTestPlanWithTestPlanModel"; String caller ="runTestPlan"; try { @@ -38,9 +37,6 @@ public class RunTestPlan extends BaseService { .extractTestPlanTaskModel(testPlanRequestModel, testPlanResultModel); addToTestPlanTaskList(testPlanTaskModel, model); - //should not exist the jsp name - return new BaseResponseModel(true, (Object) new String( - "testPlanTask.jsp")); } catch (JAXBException e) { throw new CustomGenericException("0", e.getMessage(), caller); } diff --git a/src/main/java/org/bench4q/web/api/ScriptActionController.java b/src/main/java/org/bench4q/web/api/ScriptActionController.java index 340d2be3..dde11ee7 100644 --- a/src/main/java/org/bench4q/web/api/ScriptActionController.java +++ b/src/main/java/org/bench4q/web/api/ScriptActionController.java @@ -7,9 +7,11 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; +import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.xml.bind.JAXBException; import javax.xml.transform.Source; @@ -17,6 +19,7 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; + import org.bench4q.share.models.agent.RunScenarioModel; import org.bench4q.share.models.master.OperateScriptServerResponseModel; import org.bench4q.share.models.master.ScriptModel; @@ -73,11 +76,9 @@ public class ScriptActionController extends BaseControllerService { if (operateScriptServerResponseModel.isSuccess()) { List scripts = operateScriptServerResponseModel .getScriptModels(); - if (scripts == null) - return new BaseResponseModel(false, "data empty"); - - else - return new BaseResponseModel(true, scripts); + if(scripts==null) + scripts=new ArrayList(); + return new BaseResponseModel(true, scripts); } else { return new BaseResponseModel(false, diff --git a/src/main/java/org/bench4q/web/api/TestPlanActionController.java b/src/main/java/org/bench4q/web/api/TestPlanActionController.java index fa8006c8..b5b12ec4 100644 --- a/src/main/java/org/bench4q/web/api/TestPlanActionController.java +++ b/src/main/java/org/bench4q/web/api/TestPlanActionController.java @@ -107,33 +107,34 @@ public class TestPlanActionController extends BaseControllerService { throw new CustomGenericException("0", "run testplan request model is invalidate", caller); } - return this.getRunTestPlan().runTestPlan(accessToken, + this.getRunTestPlan().runTestPlan(accessToken, testPlanRequestModel, model); + return new BaseResponseModel(true); } - - @RequestMapping(value = "testPlanTaskList", method = RequestMethod.POST) + + + @RequestMapping(value ="testPlanTaskList", method = RequestMethod.POST) @ResponseBody - public BaseResponseModel getTestPlanTaskList( + public BaseResponseModel getTestPlanTaskList( @ModelAttribute("accessToken") String accessToken, @ModelAttribute("testPlanTaskList") List testPlanTaskModels, - ModelMap model) throws CustomGenericException { + ModelMap model) throws CustomGenericException, JAXBException { String caller = this.BASECALLER + "testPlanTaskList"; Iterator iterator = testPlanTaskModels.iterator(); while (iterator.hasNext()) { TestPlanTaskModel testPlanTaskModel = iterator.next(); TestPlanResultModel testPlanResultModel = this.getTestPlanInfo() - .getRunningTestPlanModel(accessToken, + .getTestPlanInfoFromDB(accessToken, testPlanTaskModel.getId().toString(), caller); if (testPlanResultModel.getCurrentStatus() == null) testPlanTaskModel.setStatus("-1"); - testPlanTaskModel.setStatus(testPlanResultModel.getCurrentStatus() + else testPlanTaskModel.setStatus(testPlanResultModel.getCurrentStatus() .toString()); - testPlanTaskModels.add(testPlanTaskModel); + /*testPlanTaskModels.add(testPlanTaskModel);*/ } return new BaseResponseModel(true, testPlanTaskModels); } - // get the test plan running info @RequestMapping("/{testPlanId}/runningInfo") @ResponseBody public BaseResponseModel getRunningInfo( diff --git a/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java b/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java index b82173e4..1e29f065 100644 --- a/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java +++ b/src/main/java/org/bench4q/web/api/TestPlanHistoryResult.java @@ -66,7 +66,6 @@ public class TestPlanHistoryResult extends BaseControllerService { loadTestPlans( @ModelAttribute("accessToken") String accessToken) throws CustomGenericException { - System.out.println("enter loadTestPlans"); String caller = "TestPlanHistoryResult:loadTestPlans"; String url = this.getBaseUrl() + "/loadTestPlans"; TestPlanResponseModel testPlanResponseModel = (TestPlanResponseModel) this @@ -99,10 +98,14 @@ public class TestPlanHistoryResult extends BaseControllerService { this.getBaseUrl() + "/getTestPlanReport", makeParamsMap("testPlanRunID", testPlanId), this.makeAccessTockenMap(accessToken)); - if (httpResponse == null || httpResponse.getContent().isEmpty()) { + if (httpResponse == null ) { throw new CustomGenericException("1", "invalidate http response", caller); } + if(httpResponse.getContent().isEmpty()) + throw new CustomGenericException("5", "report data empty",""); + /*if(httpResponse.getContent().isEmpty()) + throw new CustomGenericException(errCode, errMsg, source)*/ if (httpResponse.getCode() == HttpStatus.BAD_REQUEST_400) { ErrorResponseModel errorResponseModel = (ErrorResponseModel) ObjectXmlExchange .fromXml(ErrorResponseModel.class, diff --git a/src/main/resources/ipConfig.properties b/src/main/resources/ipConfig.properties index 63e5d3c0..93407696 100644 --- a/src/main/resources/ipConfig.properties +++ b/src/main/resources/ipConfig.properties @@ -1 +1 @@ -masterAddress=127.0.0.1:7979/ \ No newline at end of file +masterAddress=133.133.12.1:7979/ \ No newline at end of file diff --git a/src/main/webapp/script/resultInfo.js b/src/main/webapp/script/resultInfo.js index 13914849..8b068042 100644 --- a/src/main/webapp/script/resultInfo.js +++ b/src/main/webapp/script/resultInfo.js @@ -21,8 +21,10 @@ function createScriptResultInfoTree(testPlanId,tree){ dataType:"json", async: false, success: function(data){ - if(data==null) + if(!data.success){ return; + } + else data=data.data; createScriptTree(data,scriptResultTree); tree.root.insertSingleNode(scriptResultTree.root); } @@ -58,11 +60,12 @@ var SutResult=function(testPlanId){ dataType:"json", async: false, success: function(data){ - if(data==null) + if(!data.success) { sutResultInfo.root=null; return; } + else data=data.data; scriptResultTree.createRoot("SUT","SUT"); sutResultInfo.root=scriptResultTree.root; sutResultInfo.data=data; diff --git a/src/main/webapp/script/script.js b/src/main/webapp/script/script.js index 7b1d69b0..299971e7 100644 --- a/src/main/webapp/script/script.js +++ b/src/main/webapp/script/script.js @@ -67,7 +67,6 @@ function stopServer() { if (!data.success) $('#scriptInfo').text("stop record server error:"+data.failedMessage); else { - server=null; $('#fileName').show(); $('#scriptInfo').text( "The script recording has been stopped," @@ -92,11 +91,11 @@ function saveScript() { if (data.success) { $("#scriptInfo").text("Saving success!"); $('#fileName').hide(); + server=null; } else { $("#scriptInfo").text("Saving failure:"+data.failedMessage); $('#fileName').hide(); } - loadScript(table,2); }); } diff --git a/src/main/webapp/script/scriptTable.js b/src/main/webapp/script/scriptTable.js index 30dd3980..6c308c5f 100644 --- a/src/main/webapp/script/scriptTable.js +++ b/src/main/webapp/script/scriptTable.js @@ -15,6 +15,7 @@ function loadScript(table, actionId) { addScriptAction(); } else { // show load banner or error + alert(data.failedMessage); } }, "json"); diff --git a/src/main/webapp/script/test.js b/src/main/webapp/script/test.js index 7b43da21..45b8ca20 100644 --- a/src/main/webapp/script/test.js +++ b/src/main/webapp/script/test.js @@ -467,7 +467,7 @@ function start() { data : JSON.stringify(testPlan), success : function(data) { if (data.success) - window.location.replace(data.data); + window.location.replace("testPlanTask.jsp"); else alert(data.failedMessage); }, diff --git a/src/main/webapp/script/testTask.js b/src/main/webapp/script/testTask.js index 22e9a0d6..0c88223b 100644 --- a/src/main/webapp/script/testTask.js +++ b/src/main/webapp/script/testTask.js @@ -2,32 +2,38 @@ $(document).ready(function() { testPlanTaskList(); }); $('.datatable').dataTable({ - "sDom": "<'row-fluid'<'span6'l>>t<'row-fluid'<'span3 center'p>>", - "sPaginationType": "bootstrap", - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" + "sDom" : "<'row-fluid'<'span6'l>>t<'row-fluid'<'span3 center'p>>", + "sPaginationType" : "bootstrap", + "oLanguage" : { + "sLengthMenu" : "_MENU_ records per page" } -} ); -var tesPlanTaskList; +}); function testPlanTaskList() { - $('#testTaskList').dataTable().fnClearTable(); - var statusHtml; $.post("testPlanTaskList", {}, function(data) { - testPlanTaskList = data; + if (!data.success) { + alert(data.failedMessage); + return; + } + if(data.data.length==0) + return ; + data = data.data; + + for ( var i = 0; i < data.length; i++) { var $button = $("
"); - var $a=$($button.find("a")[0]); - var $i=$($a.find("i")); - switch (data[i].status) { + var $a = $($button.find("a")[0]); + var $i = $($a.find("i")); + switch (data[i].status) { + case "NotStart": $i.text("NotStart"); break; case "InRunning": $i.text("InRunning"); - $a.attr("onclick","viewRealTimeResult(this)"); + $a.attr("onclick", "viewRealTimeResult(this)"); break; case "PendingNoEnoughMaxLoad": $i.text("PendingNoEnoughMaxLoad"); @@ -50,10 +56,9 @@ function testPlanTaskList() { } $('#testTaskList').dataTable().fnAddData( [ i, data[i].name, $button.html() ]); - } - }, "json"); - + },"json"); + } function getTestPlanIdInTable(obj) {