码迷,mamicode.com
首页 > 其他好文 > 详细

Junit接口测试(2)

时间:2015-09-07 11:03:46      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

//使用JSON上传数组

 1 package junitTest;
 2 
 3 import java.util.ArrayList;
 4 import java.util.HashMap;
 5 import java.util.List;
 6 import java.util.Map;
 7 import org.junit.Test;
 8 import com.alibaba.fastjson.JSON;
 9 import Vo.ResVo;
10 import interfaceTest_1.HTTPUtil;
11 
12 public class UserInfo {
13     
14         //设置常用菜单
15             @Test
16             public void setMenu(){
17                 int menuId = 1;
18                 int order = 1;
19                 int action = 1;
20                 int userId=8;
21                 String website = "http://192.168.1.100/xxx.htm";        
22                 Map<String,Object> m = new HashMap<String,Object>();
23                 List<Map<String,Object>> menuList = new ArrayList<Map<String,Object>>();
24                 Map<String,Object> menus = new HashMap<String,Object>();
25                 menus.put("menuId", menuId);
26                 menus.put("order",order);
27                 menus.put("action", action);
28                 menuList.add(menus);
29                 m.put("userId",userId);
30                 m.put("menus", menuList);
31                 String res = HTTPUtil.postJson(website,JSON.toJSONString(m));
32                 System.out.println(JSON.toJSONString(m));
33                 ResVo resVo = JSON.parseObject(res,ResVo.class);
34                 System.out.println(res);
35                 org.junit.Assert.assertSame(0, resVo.getResult());            
36             }
37 
38 }

 

Junit接口测试(2)

标签:

原文地址:http://www.cnblogs.com/cvv54/p/4788209.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!