user.setUsername("maurice");
Map<String, Object> map = Maps.newHashMap();
//测试include属性
map = MapUtils.toMap(new BeanResourceBundle(user,new String[]{"username","password","realname"}));
assertEquals(map.size(), 3);
assertEquals(map.get("username"), user.getUsername());
assertEquals(map.get("realname"), user.getRealname());
assertEquals(map.get("password"), user.getPassword());
assertFalse(map.containsKey("email"));
//测试exclude属性
map = MapUtils.toMap(new BeanResourceBundle(user,null,new String[]{"username","password","realname"}));
assertEquals(map.size(), 2);
assertEquals(map.get("id"), user.getId());
assertEquals(map.get("state"),user.getState());
assertFalse(map.containsKey("email"));
//测试ignoreEmptyValue属性
map = MapUtils.toMap(new BeanResourceBundle(user,null,null,false));
assertEquals(map.get("id"), user.getId());
assertEquals(map.get("state"),user.getState());
assertEquals(map.get("username"), user.getUsername());
assertEquals(map.get("realname"), user.getRealname());