1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.beanutils2.bugs;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20
21 import java.lang.reflect.Method;
22
23 import org.apache.commons.beanutils2.MethodUtils;
24 import org.apache.commons.beanutils2.PropertyUtils;
25 import org.apache.commons.beanutils2.bugs.other.Jira298BeanFactory;
26 import org.apache.commons.beanutils2.bugs.other.Jira298BeanFactory.IX;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.junit.jupiter.api.AfterEach;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
32
33
34
35
36 public class Jira298Test {
37
38 private static final Log LOG = LogFactory.getLog(Jira298Test.class);
39
40
41
42
43
44
45 @BeforeEach
46 protected void setUp() throws Exception {
47 }
48
49
50
51
52
53
54 @AfterEach
55 protected void tearDown() throws Exception {
56 }
57
58
59
60
61 @Test
62 public void testIssue_BEANUTILS_298_MethodUtils_getAccessibleMethod() throws Exception {
63 final Object bean = Jira298BeanFactory.createImplX();
64 Object result = null;
65 final Method m2 = MethodUtils.getAccessibleMethod(bean.getClass(), "getName", new Class[0]);
66 result = m2.invoke(bean);
67 assertEquals("BaseX name value", result);
68 }
69
70
71
72
73 @Test
74 public void testIssue_BEANUTILS_298_PropertyUtils_getProperty() throws Exception {
75 final Object bean = Jira298BeanFactory.createImplX();
76 final Object result = PropertyUtils.getProperty(bean, "name");
77 assertEquals("BaseX name value", result);
78 }
79
80
81
82
83 @Test
84 public void testIssue_BEANUTILS_298_PropertyUtils_setProperty() throws Exception {
85 final Object bean = Jira298BeanFactory.createImplX();
86 assertEquals("BaseX name value", ((IX) bean).getName());
87 PropertyUtils.setProperty(bean, "name", "new name");
88 assertEquals("new name", ((IX) bean).getName());
89 }
90 }