当前位置:   article > 正文

beanshell脚本

beanshell fastjson脚本求和
  1. List list = vars.getObject("phones");
  2. ArrayList cities = new ArrayList();
  3. Map map = new HashMap();
  4. for (int i = 0; i < list.size(); i++) {
  5. String s = list.get(i).get("phone");
  6. vars.put("phone_"+(i+1), s);
  7. String city = list.get(i).get("city");
  8. // cities.add(city);
  9. map.put(s, city);
  10. }
  11. vars.putObject("cities", map);
  1. import com.alibaba.fastjson.JSONObject;
  2. String response = prev.getResponseDataAsString();
  3. log.info(response);
  4. JSONObject object = JSONObject.parseObject(response);
  5. JSONObject object1 = object.getJSONObject("response");
  6. JSONObject object2 = object1.getJSONObject(vars.get("phoneNum"));
  7. String location = object2.getString("location");
  8. Map cities = vars.getObject("cities");
  9. String city = cities.get(vars.get("phoneNum"));
  10. log.info("city: " + city);
  11. if (location.contains(city)) {
  12. Failure= true ;
  13. FailureMessage = "expect city is: " + city + " ,real location is: " + location;
  14. }

转载于:https://my.oschina.net/mexiaobai1315/blog/3069027

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/1014210
推荐阅读
相关标签
  

闽ICP备14008679号