assertEquals("nameB", bw.getPropertyValue("map[key4][1].name"));
}
@Test
public void testIndexedPropertiesWithDirectAccess() {
IndexedTestBean bean = new IndexedTestBean();
BeanWrapper bw = new BeanWrapperImpl(bean);
TestBean tb0 = bean.getArray()[0];
TestBean tb1 = bean.getArray()[1];
TestBean tb2 = ((TestBean) bean.getList().get(0));
TestBean tb3 = ((TestBean) bean.getList().get(1));
TestBean tb6 = ((TestBean) bean.getSet().toArray()[0]);
TestBean tb7 = ((TestBean) bean.getSet().toArray()[1]);
TestBean tb4 = ((TestBean) bean.getMap().get("key1"));
TestBean tb5 = ((TestBean) bean.getMap().get("key2"));
assertEquals(tb0, bw.getPropertyValue("array[0]"));
assertEquals(tb1, bw.getPropertyValue("array[1]"));
assertEquals(tb2, bw.getPropertyValue("list[0]"));
assertEquals(tb3, bw.getPropertyValue("list[1]"));
assertEquals(tb6, bw.getPropertyValue("set[0]"));
assertEquals(tb7, bw.getPropertyValue("set[1]"));
assertEquals(tb4, bw.getPropertyValue("map[key1]"));
assertEquals(tb5, bw.getPropertyValue("map[key2]"));
assertEquals(tb4, bw.getPropertyValue("map['key1']"));
assertEquals(tb5, bw.getPropertyValue("map[\"key2\"]"));
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("array[0]", tb5);
pvs.add("array[1]", tb4);
pvs.add("list[0]", tb3);
pvs.add("list[1]", tb2);
pvs.add("list[2]", tb0);
pvs.add("list[4]", tb1);
pvs.add("map[key1]", tb1);
pvs.add("map['key2']", tb0);
pvs.add("map[key5]", tb4);
pvs.add("map['key9']", tb5);
bw.setPropertyValues(pvs);
assertEquals(tb5, bean.getArray()[0]);
assertEquals(tb4, bean.getArray()[1]);
assertEquals(tb3, (bean.getList().get(0)));
assertEquals(tb2, (bean.getList().get(1)));
assertEquals(tb0, (bean.getList().get(2)));
assertEquals(null, (bean.getList().get(3)));
assertEquals(tb1, (bean.getList().get(4)));
assertEquals(tb1, (bean.getMap().get("key1")));
assertEquals(tb0, (bean.getMap().get("key2")));
assertEquals(tb4, (bean.getMap().get("key5")));
assertEquals(tb5, (bean.getMap().get("key9")));
assertEquals(tb5, bw.getPropertyValue("array[0]"));
assertEquals(tb4, bw.getPropertyValue("array[1]"));
assertEquals(tb3, bw.getPropertyValue("list[0]"));
assertEquals(tb2, bw.getPropertyValue("list[1]"));
assertEquals(tb0, bw.getPropertyValue("list[2]"));