1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.struts.form.pojo;
17
18 import org.apache.commons.beanutils.PropertyUtils;
19 import org.junit.Before;
20 import org.junit.Test;
21
22 import static org.junit.Assert.assertFalse;
23
24 public class PojoPropertyUtilsBeanTest {
25
26 @Before
27
28
29
30
31 public void setup() {
32 PojoPlugin.initBeanUtils();
33 }
34
35
36
37
38
39 @Test
40
41
42
43
44
45 public void testNestedPropertyIsWriteable() {
46 ReadonlyBean testBean = new ReadonlyBean();
47 ReadonlyWrappingBean readonlyBean = new ReadonlyWrappingBean(testBean);
48 WriteableWrappingBean writeableBean = new WriteableWrappingBean(testBean);
49
50 assertFalse(PropertyUtils.isWriteable(readonlyBean, "bean.value"));
51 assertFalse(PropertyUtils.isWriteable(writeableBean, "bean.value"));
52 }
53
54 private static class ReadonlyBean {
55
56 private Boolean value;
57
58 public Boolean getValue() {
59 return value;
60 }
61 }
62
63 private static class ReadonlyWrappingBean {
64
65 private ReadonlyBean bean;
66
67 public ReadonlyWrappingBean(ReadonlyBean bean) {
68 this.bean = bean;
69 }
70
71 public ReadonlyBean getBean() {
72 return bean;
73 }
74 }
75
76 private static class WriteableWrappingBean {
77
78 private ReadonlyBean bean;
79
80 public WriteableWrappingBean(ReadonlyBean bean) {
81 this.bean = bean;
82 }
83
84 public ReadonlyBean getBean() {
85 return bean;
86 }
87
88 public void setBean(ReadonlyBean bean) {
89 this.bean = bean;
90 }
91 }
92 }