异乡客

我一生戎马刀上飘 见过英雄弯下小蛮腰 飞檐走壁能飞多高 我坐船练习水上漂

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

//使用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 }

 

posted on 2015-09-07 10:23  cvv54  阅读(493)  评论(0编辑  收藏  举报