1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718package org .apache .commons .beanutils2 .bugs ;
1819
19- import static org .junit .jupiter .api .Assertions .assertAll ;
2020import static org .junit .jupiter .api .Assertions .assertEquals ;
2121import static org .junit .jupiter .api .Assertions .assertFalse ;
2222import static org .junit .jupiter .api .Assertions .assertNotEquals ;
@@ -65,7 +65,6 @@ public void testIssue_BEANUTILS_61_BeanUtils_copyProperties_from_WrapDynaBean()
6565 final TestBean targetBean = Jira61BeanFactory .createBean ();
6666 targetBean .setSimpleWriteOnly (value );
6767 BeanUtils .copyProperties (targetBean , wrapDynaBean );
68-
6968 assertEquals (value , targetBean .getSimpleReadOnly ());
7069 }
7170
@@ -78,7 +77,6 @@ public void testIssue_BEANUTILS_61_BeanUtils_copyProperties_to_WrapDynaBean() th
7877 final Map <String , Object > source = new HashMap <>();
7978 source .put ("simpleReadOnly" , value );
8079 BeanUtils .copyProperties (wrapDynaBean , source );
81-
8280 assertNotEquals (value , testBean .getSimpleReadOnly ());
8381 }
8482
@@ -91,7 +89,6 @@ public void testIssue_BEANUTILS_61_PropertyUtils_copyProperties_from_WrapDynaBea
9189 final TestBean targetBean = Jira61BeanFactory .createBean ();
9290 targetBean .setSimpleWriteOnly (value );
9391 PropertyUtils .copyProperties (targetBean , wrapDynaBean );
94-
9592 assertEquals (value , targetBean .getSimpleReadOnly ());
9693 }
9794
@@ -104,133 +101,117 @@ public void testIssue_BEANUTILS_61_PropertyUtils_copyProperties_to_WrapDynaBean(
104101 final Map <String , Object > source = new HashMap <>();
105102 source .put ("simpleReadOnly" , expected );
106103 PropertyUtils .copyProperties (wrapDynaBean , source );
107-
108104 assertNotEquals (expected , testBean .getSimpleReadOnly ());
109105 }
110106
111107 /**
112108 * Test {@link PropertyUtils#getProperty(Object, String)} for simple properties.
113109 */
114110 @ Test
115- public void testIssue_BEANUTILS_61_PropertyUtils_getProperty () {
116- assertAll (() -> assertEquals (testBean .getSimpleReadOnly (), PropertyUtils .getProperty (wrapDynaBean , "simpleReadOnly" )),
117- () -> assertThrows (IllegalArgumentException .class , () -> {
118- PropertyUtils .getProperty (wrapDynaBean , "simpleWriteOnly" );
119- }));
111+ public void testIssue_BEANUTILS_61_PropertyUtils_getProperty () throws Exception {
112+ assertEquals (testBean .getSimpleReadOnly (), PropertyUtils .getProperty (wrapDynaBean , "simpleReadOnly" ));
113+ assertThrows (IllegalArgumentException .class , () -> PropertyUtils .getProperty (wrapDynaBean , "simpleWriteOnly" ));
120114 }
121115
122116 /**
123117 * Test {@link PropertyUtils#getProperty(Object, String)} for indexed properties.
124118 */
125119 @ Test
126- public void testIssue_BEANUTILS_61_PropertyUtils_getProperty_Indexed () {
127- assertAll (() -> assertEquals (testBean .getIndexedReadOnly (0 ), PropertyUtils .getProperty (wrapDynaBean , "indexedReadOnly[0]" )),
128- () -> assertThrows (IllegalArgumentException .class , () -> {
129- PropertyUtils .getProperty (wrapDynaBean , "indexedWriteOnly[0]" );
130- }));
120+ public void testIssue_BEANUTILS_61_PropertyUtils_getProperty_Indexed () throws Exception {
121+ assertEquals (testBean .getIndexedReadOnly (0 ), PropertyUtils .getProperty (wrapDynaBean , "indexedReadOnly[0]" ));
122+ assertThrows (IllegalArgumentException .class , () -> PropertyUtils .getProperty (wrapDynaBean , "indexedWriteOnly[0]" ));
131123 }
132124
133125 /**
134126 * Test {@link PropertyUtils#getProperty(Object, String)} for mapped properties.
135127 */
136128 @ Test
137- public void testIssue_BEANUTILS_61_PropertyUtils_getProperty_Mapped () {
138- assertAll (() -> assertEquals (testBean .getMappedReadOnly ("foo-key" ), PropertyUtils .getProperty (wrapDynaBean , "mappedReadOnly(foo-key)" )),
139- () -> assertThrows (IllegalArgumentException .class , () -> {
140- PropertyUtils .getProperty (wrapDynaBean , "mappedWriteOnly(foo-key)" );
141- }));
129+ public void testIssue_BEANUTILS_61_PropertyUtils_getProperty_Mapped () throws Exception {
130+ assertEquals (testBean .getMappedReadOnly ("foo-key" ), PropertyUtils .getProperty (wrapDynaBean , "mappedReadOnly(foo-key)" ));
131+ assertThrows (IllegalArgumentException .class , () -> PropertyUtils .getProperty (wrapDynaBean , "mappedWriteOnly(foo-key)" ));
142132 }
143133
144134 /**
145135 * Test {@link PropertyUtils#isReadable(Object, String)} for simple properties.
146136 */
147137 @ Test
148138 public void testIssue_BEANUTILS_61_PropertyUtils_isReadable () {
149- assertAll (() -> assertTrue (PropertyUtils .isReadable (wrapDynaBean , "simpleReadOnly" )),
150- () -> assertFalse (PropertyUtils .isReadable (wrapDynaBean , "simpleWriteOnly" ) ));
139+ assertTrue (PropertyUtils .isReadable (wrapDynaBean , "simpleReadOnly" ));
140+ assertFalse (PropertyUtils .isReadable (wrapDynaBean , "simpleWriteOnly" ));
151141 }
152142
153143 /**
154144 * Test {@link PropertyUtils#isReadable(Object, String)} for indexed properties.
155145 */
156146 @ Test
157147 public void testIssue_BEANUTILS_61_PropertyUtils_isReadable_Indexed () {
158- assertAll (() -> assertTrue (PropertyUtils .isReadable (wrapDynaBean , "indexedReadOnly" )),
159- () -> assertFalse (PropertyUtils .isReadable (wrapDynaBean , "indexedWriteOnly" ) ));
148+ assertTrue (PropertyUtils .isReadable (wrapDynaBean , "indexedReadOnly" ));
149+ assertFalse (PropertyUtils .isReadable (wrapDynaBean , "indexedWriteOnly" ));
160150 }
161151
162152 /**
163153 * Test {@link PropertyUtils#isReadable(Object, String)} for mapped properties.
164154 */
165155 @ Test
166156 public void testIssue_BEANUTILS_61_PropertyUtils_isReadable_Mapped () {
167- assertAll (() -> assertTrue (PropertyUtils .isReadable (wrapDynaBean , "mappedReadOnly" )),
168- () -> assertFalse (PropertyUtils .isReadable (wrapDynaBean , "mappedWriteOnly" ) ));
157+ assertTrue (PropertyUtils .isReadable (wrapDynaBean , "mappedReadOnly" ));
158+ assertFalse (PropertyUtils .isReadable (wrapDynaBean , "mappedWriteOnly" ));
169159 }
170160
171161 /**
172162 * Test {@link PropertyUtils#isWriteable(Object, String)} for simple properties.
173163 */
174164 @ Test
175165 public void testIssue_BEANUTILS_61_PropertyUtils_isWriteable () {
176- assertAll (() -> assertFalse (PropertyUtils .isWriteable (wrapDynaBean , "simpleReadOnly" )),
177- () -> assertTrue (PropertyUtils .isWriteable (wrapDynaBean , "simpleWriteOnly" ) ));
166+ assertFalse (PropertyUtils .isWriteable (wrapDynaBean , "simpleReadOnly" ));
167+ assertTrue (PropertyUtils .isWriteable (wrapDynaBean , "simpleWriteOnly" ));
178168 }
179169
180170 /**
181171 * Test {@link PropertyUtils#isWriteable(Object, String)} for indexed properties.
182172 */
183173 @ Test
184174 public void testIssue_BEANUTILS_61_PropertyUtils_isWriteable_Indexed () {
185- assertAll (() -> assertFalse (PropertyUtils .isWriteable (wrapDynaBean , "indexedReadOnly" )),
186- () -> assertTrue (PropertyUtils .isWriteable (wrapDynaBean , "indexedWriteOnly" ) ));
175+ assertFalse (PropertyUtils .isWriteable (wrapDynaBean , "indexedReadOnly" ));
176+ assertTrue (PropertyUtils .isWriteable (wrapDynaBean , "indexedWriteOnly" ));
187177 }
188178
189179 /**
190180 * Test {@link PropertyUtils#isWriteable(Object, String)} for mapped properties.
191181 */
192182 @ Test
193183 public void testIssue_BEANUTILS_61_PropertyUtils_isWriteable_Mapped () {
194- assertAll (() -> assertFalse (PropertyUtils .isWriteable (wrapDynaBean , "mappedReadOnly" )),
195- () -> assertTrue (PropertyUtils .isWriteable (wrapDynaBean , "mappedWriteOnly" ) ));
184+ assertFalse (PropertyUtils .isWriteable (wrapDynaBean , "mappedReadOnly" ));
185+ assertTrue (PropertyUtils .isWriteable (wrapDynaBean , "mappedWriteOnly" ));
196186 }
197187
198188 /**
199189 * Test {@link PropertyUtils#setProperty(Object, String, Object)} for simple properties.
200190 */
201191 @ Test
202- public void testIssue_BEANUTILS_61_PropertyUtils_setProperty () {
203- assertAll (() -> assertThrows (IllegalArgumentException .class , () -> {
204- PropertyUtils .setProperty (wrapDynaBean , "simpleReadOnly" , "READONLY-SIMPLE-BAR" );
205- }), () -> {
206- PropertyUtils .setProperty (wrapDynaBean , "simpleWriteOnly" , "SIMPLE-BAR" );
207- assertEquals ("SIMPLE-BAR" , testBean .getSimpleReadOnly ());
208- });
192+ public void testIssue_BEANUTILS_61_PropertyUtils_setProperty () throws Exception {
193+ assertThrows (IllegalArgumentException .class , () -> PropertyUtils .setProperty (wrapDynaBean , "simpleReadOnly" , "READONLY-SIMPLE-BAR" ));
194+ PropertyUtils .setProperty (wrapDynaBean , "simpleWriteOnly" , "SIMPLE-BAR" );
195+ assertEquals ("SIMPLE-BAR" , testBean .getSimpleReadOnly ());
209196 }
210197
211198 /**
212199 * Test {@link PropertyUtils#setProperty(Object, String, Object)} for indexed properties.
213200 */
214201 @ Test
215- public void testIssue_BEANUTILS_61_PropertyUtils_setProperty_Indexed () {
216- assertAll (() -> assertThrows (IllegalArgumentException .class , () -> {
217- PropertyUtils .setProperty (wrapDynaBean , "indexedReadOnly[0]" , "READONLY-INDEXED-BAR" );
218- }), () -> {
219- PropertyUtils .setProperty (wrapDynaBean , "indexedWriteOnly[0]" , "INDEXED-BAR" );
220- assertEquals ("INDEXED-BAR" , testBean .getIndexedReadOnly (0 ));
221- });
202+ public void testIssue_BEANUTILS_61_PropertyUtils_setProperty_Indexed () throws Exception {
203+ assertThrows (IllegalArgumentException .class , () -> PropertyUtils .setProperty (wrapDynaBean , "indexedReadOnly[0]" , "READONLY-INDEXED-BAR" ));
204+ PropertyUtils .setProperty (wrapDynaBean , "indexedWriteOnly[0]" , "INDEXED-BAR" );
205+ assertEquals ("INDEXED-BAR" , testBean .getIndexedReadOnly (0 ));
222206 }
223207
224208 /**
225209 * Test {@link PropertyUtils#setProperty(Object, String, Object)} for mapped properties.
226210 */
227211 @ Test
228- public void testIssue_BEANUTILS_61_PropertyUtils_setProperty_Mapped () {
229- assertAll (() -> assertThrows (IllegalArgumentException .class , () -> {
230- PropertyUtils .setProperty (wrapDynaBean , "mappedReadOnly(foo-key)" , "READONLY-MAPPED-BAR" );
231- }), () -> {
232- PropertyUtils .setProperty (wrapDynaBean , "mappedWriteOnly(foo-key)" , "MAPPED-BAR" );
233- assertEquals ("MAPPED-BAR" , testBean .getMappedReadOnly ("foo-key" ));
234- });
212+ public void testIssue_BEANUTILS_61_PropertyUtils_setProperty_Mapped () throws Exception {
213+ assertThrows (IllegalArgumentException .class , () -> PropertyUtils .setProperty (wrapDynaBean , "mappedReadOnly(foo-key)" , "READONLY-MAPPED-BAR" ));
214+ PropertyUtils .setProperty (wrapDynaBean , "mappedWriteOnly(foo-key)" , "MAPPED-BAR" );
215+ assertEquals ("MAPPED-BAR" , testBean .getMappedReadOnly ("foo-key" ));
235216 }
236217}
0 commit comments