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 public class Jira349TestCase extends TestCase {
32
33 private final Log log = LogFactory.getLog(Jira349TestCase .class);
34
35
36
37
38
39
40 public Jira349TestCase(final String name) {
41 super(name);
42 }
43
44
45
46
47
48
49 public static void main(final String[] args) {
50 junit.textui.TestRunner.run(suite());
51 }
52
53
54
55
56
57
58 public static Test suite() {
59 return (new TestSuite(Jira349TestCase.class));
60 }
61
62
63
64
65
66
67 @Override
68 protected void setUp() throws Exception {
69 super.setUp();
70 }
71
72
73
74
75
76
77 @Override
78 protected void tearDown() throws Exception {
79 super.tearDown();
80 }
81
82
83
84
85 public void testIssue_BEANUTILS_349_PropertyUtils_copyProperties() {
86 final PrimitiveBean dest = new PrimitiveBean();
87 final ObjectBean origin = new ObjectBean ();
88 try {
89 PropertyUtils.copyProperties(dest, origin);
90 } catch (final NullPointerException e) {
91 log.error("Failed", e);
92 fail("Threw NullPointerException");
93 } catch (final IllegalArgumentException e) {
94 log.warn("Expected Result", e);
95 } catch (final 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(final 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(final Boolean testProperty) {
123 this.testProperty = testProperty;
124 }
125 }
126 }