@RequestMapping(value = "/generateHistoryFile", method = RequestMethod.POST)
  @ResponseBody
  public void generateHistoryFile(HttpServletRequest request, HttpServletResponse response) {
    String foldername = request.getParameter("foldername");
    String reqstate = request.getParameter("reqstate");
    if (reqstate.equalsIgnoreCase("success")) {
      JSONArray ja = JSONArray.fromObject(request.getParameter("testresultitemcollectionjson"));
      for (int i = 0; i < ja.length(); i++) {
        TestResultItem tri = new TestResultItem();
        try {
          JSONObject itemobj = ja.getJSONObject(i);
          String result = itemobj.getString("result");
          tri.setResult(result);
          if (!result.equals(TestStatus.exception)) {
            Set<CheckPointItem> cps = new HashSet<CheckPointItem>();

            tri.setTime(itemobj.getString("time"));
            tri.setRequestInfo(itemobj.getString("requestInfo"));
            tri.setResponseInfo(itemobj.getString("responseInfo"));
            tri.setDuration(itemobj.getString("duration"));

            Object[] callbackarr = JSONArray.fromObject(itemobj.get("callback")).toArray();
            tri.setCallback(new HashSet(Arrays.asList(callbackarr)));
            JSONArray jsonarr = JSONArray.fromObject(itemobj.get("checkPoint"));
            for (int j = 0; j < jsonarr.length(); j++) {
              CheckPointItem item =
                  (CheckPointItem)
                      JSONObject.toBean(jsonarr.getJSONObject(j), CheckPointItem.class);
              cps.add(item);
            }
            tri.setCheckPoint(cps);
          } else tri.setComment(itemobj.getString("comment"));
        } catch (Exception e) {
          tri.setDuration("");
          tri.setResult(TestStatus.exception);
          tri.setComment(e.getClass().toString() + ": " + e.getMessage());
        } finally {
          testExecuteService.generateHistoryFile(foldername, tri);
        }
      }
    } else {
      TestResultItem tri = new TestResultItem();
      tri.setDuration("");
      tri.setResult(TestStatus.exception);
      String comment = "";
      String json = request.getParameter("obj");
      if (json.startsWith("{") && json.endsWith("}"))
        comment = JSONObject.fromObject(json).get("comment").toString();
      else if (json.startsWith("[") && json.endsWith("]"))
        comment = JSONArray.fromObject(json).getJSONObject(0).get("comment").toString();
      tri.setComment(comment);
      testExecuteService.generateHistoryFile(foldername, tri);
    }
  }
 @RequestMapping(value = "/executeTest", method = RequestMethod.POST)
 @ResponseBody
 public Json executeTest(HttpServletRequest request, HttpServletResponse response) {
   Json j = new Json();
   return testExecuteService.executeTestInFront(request);
 }
 @RequestMapping(value = "/getTestResponse", method = RequestMethod.POST)
 @ResponseBody
 public Json getTestResponse(@RequestParam String path) {
   Json j = new Json();
   return testExecuteService.getTestResponseBody(path);
 }