1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.beanutils.bugs;
18
19 import org.apache.commons.beanutils.AlphaBean;
20 import org.apache.commons.beanutils.BeanUtilsBean;
21 import org.apache.commons.beanutils.SuppressPropertiesBeanIntrospector;
22
23 import junit.framework.TestCase;
24
25
26
27
28
29
30 public class Jira520TestCase extends TestCase {
31
32
33
34 public void testSuppressClassPropertyByDefault() throws Exception {
35 final BeanUtilsBean bub = new BeanUtilsBean();
36 final AlphaBean bean = new AlphaBean();
37 try {
38 bub.getProperty(bean, "class");
39 fail("Could access class property!");
40 } catch (final NoSuchMethodException ex) {
41
42 }
43 }
44
45
46
47
48 public void testAllowAccessToClassProperty() throws Exception {
49 final BeanUtilsBean bub = new BeanUtilsBean();
50 bub.getPropertyUtils().removeBeanIntrospector(SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);
51 final AlphaBean bean = new AlphaBean();
52 String result = bub.getProperty(bean, "class");
53 assertEquals("Class property should have been accessed", "class org.apache.commons.beanutils.AlphaBean", result);
54 }
55 }