KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > beanutils > DynaPropertyUtilsTestCase


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17
18 package org.apache.commons.beanutils;
19
20
21 import java.lang.reflect.InvocationTargetException JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import junit.framework.TestCase;
28 import junit.framework.Test;
29 import junit.framework.TestSuite;
30
31
32 /**
33  * Test accessing DynaBeans transparently via PropertyUtils.
34  *
35  * @author Craig R. McClanahan
36  * @version $Revision: 1.12 $ $Date: 2004/02/28 13:18:36 $
37  */

38
39 public class DynaPropertyUtilsTestCase extends TestCase {
40
41
42     // ----------------------------------------------------- Instance Variables
43

44
45     /**
46      * The basic test bean for each test.
47      */

48     protected DynaBean bean = null;
49
50
51     /**
52      * The set of properties that should be described.
53      */

54     protected String JavaDoc describes[] =
55     { "booleanProperty",
56       "booleanSecond",
57       "doubleProperty",
58       "floatProperty",
59       "intArray",
60       "intIndexed",
61       "intProperty",
62       "listIndexed",
63       "longProperty",
64       "mappedObjects",
65       "mappedProperty",
66       "mappedIntProperty",
67       "nested",
68       "nullProperty",
69       // "readOnlyProperty",
70
"shortProperty",
71       "stringArray",
72       "stringIndexed",
73       "stringProperty"
74     };
75
76
77     /**
78      * The nested bean pointed at by the "nested" property.
79      */

80     protected TestBean nested = null;
81
82
83     // ----------------------------------------------------------- Constructors
84

85
86     /**
87      * Construct a new instance of this test case.
88      *
89      * @param name Name of the test case
90      */

91     public DynaPropertyUtilsTestCase(String JavaDoc name) {
92
93         super(name);
94
95     }
96
97
98     // --------------------------------------------------- Overall Test Methods
99

100
101     /**
102      * Set up instance variables required by this test case.
103      */

104     public void setUp() throws Exception JavaDoc {
105
106         // Instantiate a new DynaBean instance
107
DynaClass dynaClass = createDynaClass();
108         bean = dynaClass.newInstance();
109
110         // Initialize the DynaBean's property values (like TestBean)
111
bean.set("booleanProperty", new Boolean JavaDoc(true));
112         bean.set("booleanSecond", new Boolean JavaDoc(true));
113         bean.set("doubleProperty", new Double JavaDoc(321.0));
114         bean.set("floatProperty", new Float JavaDoc((float) 123.0));
115         int intArray[] = { 0, 10, 20, 30, 40 };
116         bean.set("intArray", intArray);
117         int intIndexed[] = { 0, 10, 20, 30, 40 };
118         bean.set("intIndexed", intIndexed);
119         bean.set("intProperty", new Integer JavaDoc(123));
120         List JavaDoc listIndexed = new ArrayList JavaDoc();
121         listIndexed.add("String 0");
122         listIndexed.add("String 1");
123         listIndexed.add("String 2");
124         listIndexed.add("String 3");
125         listIndexed.add("String 4");
126         bean.set("listIndexed", listIndexed);
127         bean.set("longProperty", new Long JavaDoc((long) 321));
128         HashMap JavaDoc mapProperty = new HashMap JavaDoc();
129         mapProperty.put("First Key", "First Value");
130         mapProperty.put("Second Key", "Second Value");
131         bean.set("mapProperty", mapProperty);
132         HashMap JavaDoc mappedObjects = new HashMap JavaDoc();
133         mappedObjects.put("First Key", "First Value");
134         mappedObjects.put("Second Key", "Second Value");
135         bean.set("mappedObjects", mappedObjects);
136         HashMap JavaDoc mappedProperty = new HashMap JavaDoc();
137         mappedProperty.put("First Key", "First Value");
138         mappedProperty.put("Second Key", "Second Value");
139         bean.set("mappedProperty", mappedProperty);
140         HashMap JavaDoc mappedIntProperty = new HashMap JavaDoc();
141         mappedIntProperty.put("One", new Integer JavaDoc(1));
142         mappedIntProperty.put("Two", new Integer JavaDoc(2));
143         bean.set("mappedIntProperty", mappedIntProperty);
144         nested = new TestBean();
145         bean.set("nested", nested);
146         // Property "nullProperty" is not initialized, so it should return null
147
bean.set("shortProperty", new Short JavaDoc((short) 987));
148         String JavaDoc stringArray[] =
149                 { "String 0", "String 1", "String 2", "String 3", "String 4" };
150         bean.set("stringArray", stringArray);
151         String JavaDoc stringIndexed[] =
152                 { "String 0", "String 1", "String 2", "String 3", "String 4" };
153         bean.set("stringIndexed", stringIndexed);
154         bean.set("stringProperty", "This is a string");
155
156     }
157
158
159     /**
160      * Return the tests included in this test suite.
161      */

162     public static Test suite() {
163
164         return (new TestSuite(DynaPropertyUtilsTestCase.class));
165
166     }
167
168
169     /**
170      * Tear down instance variables required by this test case.
171      */

172     public void tearDown() {
173
174         bean = null;
175         nested = null;
176
177     }
178
179
180
181     // ------------------------------------------------ Individual Test Methods
182

183
184     /**
185      * Test copyProperties() when the origin is a a <code>Map</code>.
186      */

187     public void testCopyPropertiesMap() {
188
189         Map JavaDoc map = new HashMap JavaDoc();
190         map.put("booleanProperty", Boolean.FALSE);
191         map.put("doubleProperty", new Double JavaDoc(333.0));
192         map.put("dupProperty", new String JavaDoc[] { "New 0", "New 1", "New 2" });
193         map.put("floatProperty", new Float JavaDoc((float) 222.0));
194         map.put("intArray", new int[] { 0, 100, 200 });
195         map.put("intProperty", new Integer JavaDoc(111));
196         map.put("longProperty", new Long JavaDoc(444));
197         map.put("shortProperty", new Short JavaDoc((short) 555));
198         map.put("stringProperty", "New String Property");
199
200         try {
201             PropertyUtils.copyProperties(bean, map);
202         } catch (Throwable JavaDoc t) {
203             fail("Threw " + t.toString());
204         }
205
206         // Scalar properties
207
assertEquals("booleanProperty", false,
208                      ((Boolean JavaDoc) bean.get("booleanProperty")).booleanValue());
209         assertEquals("doubleProperty", 333.0,
210                      ((Double JavaDoc) bean.get("doubleProperty")).doubleValue(),
211                      0.005);
212         assertEquals("floatProperty", (float) 222.0,
213                      ((Float JavaDoc) bean.get("floatProperty")).floatValue(),
214                      (float) 0.005);
215         assertEquals("intProperty", 111,
216                      ((Integer JavaDoc) bean.get("intProperty")).intValue());
217         assertEquals("longProperty", (long) 444,
218                      ((Long JavaDoc) bean.get("longProperty")).longValue());
219         assertEquals("shortProperty", (short) 555,
220                      ((Short JavaDoc) bean.get("shortProperty")).shortValue());
221         assertEquals("stringProperty", "New String Property",
222                      (String JavaDoc) bean.get("stringProperty"));
223                      
224         // Indexed Properties
225
String JavaDoc dupProperty[] = (String JavaDoc[]) bean.get("dupProperty");
226         assertNotNull("dupProperty present", dupProperty);
227         assertEquals("dupProperty length", 3, dupProperty.length);
228         assertEquals("dupProperty[0]", "New 0", dupProperty[0]);
229         assertEquals("dupProperty[1]", "New 1", dupProperty[1]);
230         assertEquals("dupProperty[2]", "New 2", dupProperty[2]);
231         int intArray[] = (int[]) bean.get("intArray");
232         assertNotNull("intArray present", intArray);
233         assertEquals("intArray length", 3, intArray.length);
234         assertEquals("intArray[0]", 0, intArray[0]);
235         assertEquals("intArray[1]", 100, intArray[1]);
236         assertEquals("intArray[2]", 200, intArray[2]);
237
238     }
239
240
241     /**
242      * Test the describe() method.
243      */

244     public void testDescribe() {
245
246         Map JavaDoc map = null;
247         try {
248             map = PropertyUtils.describe(bean);
249         } catch (Exception JavaDoc e) {
250             fail("Threw exception " + e);
251         }
252
253         // Verify existence of all the properties that should be present
254
for (int i = 0; i < describes.length; i++) {
255             assertTrue("Property '" + describes[i] + "' is present",
256                        map.containsKey(describes[i]));
257         }
258         assertTrue("Property 'writeOnlyProperty' is not present",
259                    !map.containsKey("writeOnlyProperty"));
260
261         // Verify the values of scalar properties
262
assertEquals("Value of 'booleanProperty'",
263                      Boolean.TRUE,
264                      (Boolean JavaDoc) map.get("booleanProperty"));
265         assertEquals("Value of 'doubleProperty'",
266                      new Double JavaDoc(321.0),
267                      (Double JavaDoc) map.get("doubleProperty"));
268         assertEquals("Value of 'floatProperty'",
269                      new Float JavaDoc((float) 123.0),
270                      (Float JavaDoc) map.get("floatProperty"));
271         assertEquals("Value of 'intProperty'",
272                      new Integer JavaDoc(123),
273                      (Integer JavaDoc) map.get("intProperty"));
274         assertEquals("Value of 'longProperty'",
275                      new Long JavaDoc(321),
276                      (Long JavaDoc) map.get("longProperty"));
277         assertEquals("Value of 'shortProperty'",
278                      new Short JavaDoc((short) 987),
279                      (Short JavaDoc) map.get("shortProperty"));
280         assertEquals("Value of 'stringProperty'",
281                      "This is a string",
282                      (String JavaDoc) map.get("stringProperty"));
283
284     }
285
286
287     /**
288      * Corner cases on getIndexedProperty invalid arguments.
289      */

290     public void testGetIndexedArguments() {
291
292         // Use explicit index argument
293

294         try {
295             PropertyUtils.getIndexedProperty(null, "intArray", 0);
296             fail("Should throw IllegalArgumentException 1");
297         } catch (IllegalArgumentException JavaDoc e) {
298             ; // Expected response
299
} catch (Throwable JavaDoc t) {
300             fail("Threw " + t + " instead of IllegalArgumentException 1");
301         }
302
303         try {
304             PropertyUtils.getIndexedProperty(bean, null, 0);
305             fail("Should throw IllegalArgumentException 2");
306         } catch (IllegalArgumentException JavaDoc e) {
307             ; // Expected response
308
} catch (Throwable JavaDoc t) {
309             fail("Threw " + t + " instead of IllegalArgumentException 2");
310         }
311
312         // Use index expression
313

314         try {
315             PropertyUtils.getIndexedProperty(null,
316                     "intArray[0]");
317             fail("Should throw IllegalArgumentException 3");
318         } catch (IllegalArgumentException JavaDoc e) {
319             ; // Expected response
320
} catch (Throwable JavaDoc t) {
321             fail("Threw " + t + " instead of IllegalArgumentException 3");
322         }
323
324         try {
325             PropertyUtils.getIndexedProperty(bean, "[0]");
326             fail("Should throw NoSuchMethodException 4");
327         } catch (NoSuchMethodException JavaDoc e) {
328             ; // Expected response
329
} catch (Throwable JavaDoc t) {
330             fail("Threw " + t + " instead of NoSuchMethodException 4");
331         }
332
333         try {
334             PropertyUtils.getIndexedProperty(bean, "intArray");
335             fail("Should throw IllegalArgumentException 5");
336         } catch (IllegalArgumentException JavaDoc e) {
337             ; // Expected response
338
} catch (Throwable JavaDoc t) {
339             fail("Threw " + t + " instead of IllegalArgumentException 5");
340         }
341
342         // Use explicit index argument
343

344         try {
345             PropertyUtils.getIndexedProperty(null, "intIndexed", 0);
346             fail("Should throw IllegalArgumentException 1");
347         } catch (IllegalArgumentException JavaDoc e) {
348             ; // Expected response
349
} catch (Throwable JavaDoc t) {
350             fail("Threw " + t + " instead of IllegalArgumentException 1");
351         }
352
353         try {
354             PropertyUtils.getIndexedProperty(bean, null, 0);
355             fail("Should throw IllegalArgumentException 2");
356         } catch (IllegalArgumentException JavaDoc e) {
357             ; // Expected response
358
} catch (Throwable JavaDoc t) {
359             fail("Threw " + t + " instead of IllegalArgumentException 2");
360         }
361
362         // Use index expression
363

364         try {
365             PropertyUtils.getIndexedProperty(null,
366                     "intIndexed[0]");
367             fail("Should throw IllegalArgumentException 3");
368         } catch (IllegalArgumentException JavaDoc e) {
369             ; // Expected response
370
} catch (Throwable JavaDoc t) {
371             fail("Threw " + t + " instead of IllegalArgumentException 3");
372         }
373
374         try {
375             PropertyUtils.getIndexedProperty(bean, "[0]");
376             fail("Should throw NoSuchMethodException 4");
377         } catch (NoSuchMethodException JavaDoc e) {
378             ; // Expected response
379
} catch (Throwable JavaDoc t) {
380             fail("Threw " + t + " instead of NoSuchMethodException 4");
381         }
382
383         try {
384             PropertyUtils.getIndexedProperty(bean, "intIndexed");
385             fail("Should throw IllegalArgumentException 5");
386         } catch (IllegalArgumentException JavaDoc e) {
387             ; // Expected response
388
} catch (Throwable JavaDoc t) {
389             fail("Threw " + t + " instead of IllegalArgumentException 5");
390         }
391
392     }
393
394
395     /**
396      * Positive and negative tests on getIndexedProperty valid arguments.
397      */

398     public void testGetIndexedValues() {
399
400         Object JavaDoc value = null;
401
402         // Use explicit key argument
403

404         for (int i = 0; i < 5; i++) {
405
406             try {
407                 value =
408                         PropertyUtils.getIndexedProperty(bean, "intArray", i);
409                 assertNotNull("intArray returned value " + i, value);
410                 assertTrue("intArray returned Integer " + i,
411                         value instanceof Integer JavaDoc);
412                 assertEquals("intArray returned correct " + i, i * 10,
413                         ((Integer JavaDoc) value).intValue());
414             } catch (Throwable JavaDoc t) {
415                 fail("intArray " + i + " threw " + t);
416             }
417
418             try {
419                 value =
420                         PropertyUtils.getIndexedProperty(bean, "intIndexed", i);
421                 assertNotNull("intIndexed returned value " + i, value);
422                 assertTrue("intIndexed returned Integer " + i,
423                         value instanceof Integer JavaDoc);
424                 assertEquals("intIndexed returned correct " + i, i * 10,
425                         ((Integer JavaDoc) value).intValue());
426             } catch (Throwable JavaDoc t) {
427                 fail("intIndexed " + i + " threw " + t);
428             }
429
430             try {
431                 value =
432                         PropertyUtils.getIndexedProperty(bean, "listIndexed", i);
433                 assertNotNull("listIndexed returned value " + i, value);
434                 assertTrue("list returned String " + i,
435                         value instanceof String JavaDoc);
436                 assertEquals("listIndexed returned correct " + i,
437                         "String " + i, (String JavaDoc) value);
438             } catch (Throwable JavaDoc t) {
439                 fail("listIndexed " + i + " threw " + t);
440             }
441
442             try {
443                 value =
444                         PropertyUtils.getIndexedProperty(bean, "stringArray", i);
445                 assertNotNull("stringArray returned value " + i, value);
446                 assertTrue("stringArray returned String " + i,
447                         value instanceof String JavaDoc);
448                 assertEquals("stringArray returned correct " + i,
449                         "String " + i, (String JavaDoc) value);
450             } catch (Throwable JavaDoc t) {
451                 fail("stringArray " + i + " threw " + t);
452             }
453
454             try {
455                 value =
456                         PropertyUtils.getIndexedProperty(bean, "stringIndexed", i);
457                 assertNotNull("stringIndexed returned value " + i, value);
458                 assertTrue("stringIndexed returned String " + i,
459                         value instanceof String JavaDoc);
460                 assertEquals("stringIndexed returned correct " + i,
461                         "String " + i, (String JavaDoc) value);
462             } catch (Throwable JavaDoc t) {
463                 fail("stringIndexed " + i + " threw " + t);
464             }
465
466         }
467
468         // Use key expression
469

470         for (int i = 0; i < 5; i++) {
471
472             try {
473                 value =
474                         PropertyUtils.getIndexedProperty(bean,
475                                 "intArray[" + i + "]");
476                 assertNotNull("intArray returned value " + i, value);
477                 assertTrue("intArray returned Integer " + i,
478                         value instanceof Integer JavaDoc);
479                 assertEquals("intArray returned correct " + i, i * 10,
480                         ((Integer JavaDoc) value).intValue());
481             } catch (Throwable JavaDoc t) {
482                 fail("intArray " + i + " threw " + t);
483             }
484
485             try {
486                 value =
487                         PropertyUtils.getIndexedProperty(bean,
488                                 "intIndexed[" + i + "]");
489                 assertNotNull("intIndexed returned value " + i, value);
490                 assertTrue("intIndexed returned Integer " + i,
491                         value instanceof Integer JavaDoc);
492                 assertEquals("intIndexed returned correct " + i, i * 10,
493                         ((Integer JavaDoc) value).intValue());
494             } catch (Throwable JavaDoc t) {
495                 fail("intIndexed " + i + " threw " + t);
496             }
497
498             try {
499                 value =
500                         PropertyUtils.getIndexedProperty(bean,
501                                 "listIndexed[" + i + "]");
502                 assertNotNull("listIndexed returned value " + i, value);
503                 assertTrue("listIndexed returned String " + i,
504                         value instanceof String JavaDoc);
505                 assertEquals("listIndexed returned correct " + i,
506                         "String " + i, (String JavaDoc) value);
507             } catch (Throwable JavaDoc t) {
508                 fail("listIndexed " + i + " threw " + t);
509             }
510
511             try {
512                 value =
513                         PropertyUtils.getIndexedProperty(bean,
514                                 "stringArray[" + i + "]");
515                 assertNotNull("stringArray returned value " + i, value);
516                 assertTrue("stringArray returned String " + i,
517                         value instanceof String JavaDoc);
518                 assertEquals("stringArray returned correct " + i,
519                         "String " + i, (String JavaDoc) value);
520             } catch (Throwable JavaDoc t) {
521                 fail("stringArray " + i + " threw " + t);
522             }
523
524             try {
525                 value =
526                         PropertyUtils.getIndexedProperty(bean,
527                                 "stringIndexed[" + i + "]");
528                 assertNotNull("stringIndexed returned value " + i, value);
529                 assertTrue("stringIndexed returned String " + i,
530                         value instanceof String JavaDoc);
531                 assertEquals("stringIndexed returned correct " + i,
532                         "String " + i, (String JavaDoc) value);
533             } catch (Throwable JavaDoc t) {
534                 fail("stringIndexed " + i + " threw " + t);
535             }
536
537         }
538
539         // Index out of bounds tests
540

541         try {
542             value =
543                     PropertyUtils.getIndexedProperty(bean,
544                             "intArray", -1);
545             fail("Should have thrown ArrayIndexOutOfBoundsException");
546         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
547             ; // Expected results
548
} catch (Throwable JavaDoc t) {
549             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
550         }
551
552         try {
553             value =
554                     PropertyUtils.getIndexedProperty(bean,
555                             "intArray", 5);
556             fail("Should have thrown ArrayIndexOutOfBoundsException");
557         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
558             ; // Expected results
559
} catch (Throwable JavaDoc t) {
560             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
561         }
562
563         try {
564             value =
565                     PropertyUtils.getIndexedProperty(bean,
566                             "intIndexed", -1);
567             fail("Should have thrown ArrayIndexOutOfBoundsException");
568         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
569             ; // Expected results
570
} catch (Throwable JavaDoc t) {
571             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
572         }
573
574         try {
575             value =
576                     PropertyUtils.getIndexedProperty(bean,
577                             "intIndexed", 5);
578             fail("Should have thrown ArrayIndexOutOfBoundsException");
579         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
580             ; // Expected results
581
} catch (Throwable JavaDoc t) {
582             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
583         }
584
585         try {
586             value =
587                     PropertyUtils.getIndexedProperty(bean,
588                             "listIndexed", -1);
589             fail("Should have thrown IndexOutOfBoundsException");
590         } catch (IndexOutOfBoundsException JavaDoc t) {
591             ; // Expected results
592
} catch (Throwable JavaDoc t) {
593             fail("Threw " + t + " instead of IndexOutOfBoundsException");
594         }
595
596         try {
597             value =
598                     PropertyUtils.getIndexedProperty(bean,
599                             "listIndexed", 5);
600             fail("Should have thrown IndexOutOfBoundsException");
601         } catch (IndexOutOfBoundsException JavaDoc t) {
602             ; // Expected results
603
} catch (Throwable JavaDoc t) {
604             fail("Threw " + t + " instead of IndexOutOfBoundsException");
605         }
606
607         try {
608             value =
609                     PropertyUtils.getIndexedProperty(bean,
610                             "stringArray", -1);
611             fail("Should have thrown ArrayIndexOutOfBoundsException");
612         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
613             ; // Expected results
614
} catch (Throwable JavaDoc t) {
615             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
616         }
617
618         try {
619             value =
620                     PropertyUtils.getIndexedProperty(bean,
621                             "stringArray", 5);
622             fail("Should have thrown ArrayIndexOutOfBoundsException");
623         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
624             ; // Expected results
625
} catch (Throwable JavaDoc t) {
626             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
627         }
628
629         try {
630             value =
631                     PropertyUtils.getIndexedProperty(bean,
632                             "stringIndexed", -1);
633             fail("Should have thrown ArrayIndexOutOfBoundsException");
634         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
635             ; // Expected results
636
} catch (Throwable JavaDoc t) {
637             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
638         }
639
640         try {
641             value =
642                     PropertyUtils.getIndexedProperty(bean,
643                             "stringIndexed", 5);
644             fail("Should have thrown ArrayIndexOutOfBoundsException");
645         } catch (ArrayIndexOutOfBoundsException JavaDoc t) {
646             ; // Expected results
647
} catch (Throwable JavaDoc t) {
648             fail("Threw " + t + " instead of ArrayIndexOutOfBoundsException");
649         }
650
651     }
652
653
654     /**
655      * Corner cases on getMappedProperty invalid arguments.
656      */

657     public void testGetMappedArguments() {
658
659         // Use explicit key argument
660

661         try {
662             PropertyUtils.getMappedProperty(null, "mappedProperty",
663                     "First Key");
664             fail("Should throw IllegalArgumentException 1");
665         } catch (IllegalArgumentException JavaDoc e) {
666             ; // Expected response
667
} catch (Throwable JavaDoc t) {
668             fail("Threw " + t + " instead of IllegalArgumentException 1");
669         }
670
671         try {
672             PropertyUtils.getMappedProperty(bean, null, "First Key");
673             fail("Should throw IllegalArgumentException 2");
674         } catch (IllegalArgumentException JavaDoc e) {
675             ; // Expected response
676
} catch (Throwable JavaDoc t) {
677             fail("Threw " + t + " instead of IllegalArgumentException 2");
678         }
679
680         try {
681             PropertyUtils.getMappedProperty(bean, "mappedProperty", null);
682             fail("Should throw IllegalArgumentException 3");
683         } catch (IllegalArgumentException JavaDoc e) {
684             ; // Expected response
685 <