1 package com.freemindcafe.apache.commons.beanutils.sample1;
3 import java.util.ArrayList;
6 import junit.framework.Assert;
8 import org.
apache.commons.beanutils.PropertyUtils;
13 public void it_is_easy_to_pull_the_indexed_properties()
throws Exception{
16 List<String> profiles =
new ArrayList<String>(10);
17 profiles.add(
"profile 1");
18 profiles.add(
"profile 2");
21 List<DeviceConfigurationProfile> deviceConfigurationProfiles =
new ArrayList<>();
23 deviceConfigurationProfile.setXmlMessage(
"first xml message");
24 deviceConfigurationProfiles.add(deviceConfigurationProfile);
27 Assert.assertTrue(PropertyUtils.getProperty(req,
"profiles[0]").equals(
"profile 1"));
28 Assert.assertTrue(PropertyUtils.getProperty(req,
"profiles[1]").equals(
"profile 2"));
29 Assert.assertTrue(PropertyUtils.getProperty(req,
"deviceConfigurations[0].xmlMessage").equals(
"first xml message"));
34 public void can_we_set_the_indexed_property()
throws Exception{
39 PropertyUtils.setProperty(req,
"profiles[0]",
"profile 1");
40 PropertyUtils.setProperty(req,
"profiles[1]",
"profile 2");
41 PropertyUtils.setProperty(req,
"deviceConfigurations[0].xmlMessage",
"First xml message");
43 Assert.assertTrue(req.getProfiles().get(0).equalsIgnoreCase(
"profile 1"));
44 Assert.assertTrue(req.getProfiles().get(1).equalsIgnoreCase(
"profile 2"));
void setDeviceConfigurations(int index, DeviceConfigurationProfile deviceConfiguration)
List< DeviceConfigurationProfile > getDeviceConfigurations()