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 junit.framework.Test;
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23 import org.apache.commons.beanutils.PropertyUtils;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27
28
29
30
31
32
33 public class Jira349TestCase extends TestCase {
34
35 private Log log = LogFactory.getLog(Jira349TestCase .class);
36
37
38
39
40
41
42 public Jira349TestCase(String name) {
43 super(name);
44 }
45
46
47
48
49
50
51 public static void main(String[] args) {
52 junit.textui.TestRunner.run(suite());
53 }
54
55
56
57
58
59
60 public static Test suite() {
61 return (new TestSuite(Jira349TestCase.class));
62 }
63
64
65
66
67
68
69 protected void setUp() throws Exception {
70 super.setUp();
71 }
72
73
74
75
76
77
78 protected void tearDown() throws Exception {
79 super.tearDown();
80 }
81
82
83
84
85 public void testIssue_BEANUTILS_349_PropertyUtils_copyProperties() {
86 PrimitiveBean dest = new PrimitiveBean();
87 ObjectBean origin = new ObjectBean ();
88 try {
89 PropertyUtils.copyProperties(dest, origin);
90 } catch (NullPointerException e) {
91 log.error("Failed", e);
92 fail("Threw NullPointerException");
93 } catch (IllegalArgumentException e) {
94 log.warn("Expected Result", e);
95 } catch (Throwable t) {
96 log.error("Failed", t);
97 fail("Threw exception: " + t);
98 }
99 }
100
101
102
103
104 public static class PrimitiveBean {
105 private boolean testProperty;
106 public boolean getTestProperty() {
107 return testProperty;
108 }
109 public void setTestProperty(boolean testProperty) {
110 this.testProperty = testProperty;
111 }
112 }
113
114
115
116
117 public static class ObjectBean {
118 private Boolean testProperty;
119 public Boolean getTestProperty() {
120 return testProperty;
121 }
122 public void setTestProperty(Boolean testProperty) {
123 this.testProperty = testProperty;
124 }
125 }
126 }