fix the testPlanTaskList 404:java

exception:java.util.ConcurrentModificationException
This commit is contained in:
fanfuxiaoran 2014-02-20 17:33:51 +08:00
parent f63a329dd1
commit e2aa6234a3
10 changed files with 52 additions and 43 deletions

View File

@ -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);
}

View File

@ -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<ScriptModel> scripts = operateScriptServerResponseModel
.getScriptModels();
if (scripts == null)
return new BaseResponseModel(false, "data empty");
else
return new BaseResponseModel(true, scripts);
if(scripts==null)
scripts=new ArrayList<ScriptModel>();
return new BaseResponseModel(true, scripts);
} else {
return new BaseResponseModel(false,

View File

@ -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<TestPlanTaskModel> testPlanTaskModels,
ModelMap model) throws CustomGenericException {
ModelMap model) throws CustomGenericException, JAXBException {
String caller = this.BASECALLER + "testPlanTaskList";
Iterator<TestPlanTaskModel> 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(

View File

@ -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,

View File

@ -1 +1 @@
masterAddress=127.0.0.1:7979/
masterAddress=133.133.12.1:7979/

View File

@ -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;

View File

@ -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);
});
}

View File

@ -15,6 +15,7 @@ function loadScript(table, actionId) {
addScriptAction();
} else {
// show load banner or error
alert(data.failedMessage);
}
}, "json");

View File

@ -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);
},

View File

@ -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 = $("<div><a class='btn btn-info' ><i ></i></a></div>");
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) {