1 package org.apache.commons.beanutils2;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24
25 import java.lang.reflect.Method;
26
27 import org.apache.commons.beanutils2.testbeans.TestBean;
28 import org.junit.Test;
29
30 public class MethodUtilsTest
31 {
32
33 @Test
34 public void isMappedSetterWithMappedPropertySetter()
35 throws Exception
36 {
37 Method mappedPropertySetter =
38 TestBean.class.getMethod( "setMappedProperty", new Class<?>[] { String.class, String.class } );
39 assertTrue( MethodUtils.isMappedSetter( mappedPropertySetter ) );
40 }
41
42 @Test
43 public void isMappedSetterWithIndexedPropertySetter()
44 throws Exception
45 {
46 Method indexedPropertySetter =
47 TestBean.class.getMethod( "setIntIndexed", new Class<?>[] { int.class, int.class } );
48 assertFalse( MethodUtils.isMappedSetter( indexedPropertySetter ) );
49 }
50
51 @Test
52 public void isMappedSetterWithStringPropertySetter()
53 throws Exception
54 {
55
56 Method stringPropertySetter = TestBean.class.getMethod( "setStringProperty", new Class<?>[] { String.class } );
57 assertFalse( MethodUtils.isMappedSetter( stringPropertySetter ) );
58 }
59
60 @Test
61 public void isMappedGetterWithMappedPropertyGetter()
62 throws Exception
63 {
64 Method mappedPropertyGetter = TestBean.class.getMethod( "getMappedProperty", new Class<?>[] { String.class } );
65 assertTrue( MethodUtils.isMappedGetter( mappedPropertyGetter ) );
66 }
67
68 @Test
69 public void isMappedGetterWithIndexedPropertyGetter()
70 throws Exception
71 {
72 Method indexedPropertyGetter = TestBean.class.getMethod( "getIntIndexed", new Class<?>[] { int.class } );
73 assertFalse( MethodUtils.isMappedGetter( indexedPropertyGetter ) );
74 }
75
76 @Test
77 public void isMappedGetterWithStringPropertyGetter()
78 throws Exception
79 {
80
81 Method stringPropertyGetter = TestBean.class.getMethod( "getStringProperty", new Class<?>[] {} );
82 assertFalse( MethodUtils.isMappedGetter( stringPropertyGetter ) );
83 }
84
85 }