1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.action;
19
20 import junit.framework.Test;
21 import junit.framework.TestSuite;
22
23 import org.apache.commons.beanutils.DynaProperty;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.struts.config.FormBeanConfig;
27 import org.apache.struts.config.ModuleConfig;
28 import org.apache.struts.config.impl.ModuleConfigImpl;
29 import org.apache.struts.mock.MockHttpServletRequest;
30
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35
36 /***
37 * Suite of unit tests for the <code>org.apache.struts.action.DynaActionForm</code>
38 * class.
39 */
40 public class TestDynaActionForm extends TestDynaActionFormClass {
41 /***
42 * The set of property names we expect to have returned when calling
43 * <code>getDynaProperties()</code>. You should update this list when new
44 * properties are added to TestBean.
45 */
46 protected final static String[] properties =
47 {
48 "booleanProperty", "booleanSecond", "doubleProperty",
49 "floatProperty", "intArray", "intIndexed", "intProperty",
50 "listIndexed", "longProperty", "mappedProperty", "mappedIntProperty",
51
52
53
54 "shortProperty", "stringArray", "stringIndexed", "stringProperty",
55 };
56
57
58
59 /***
60 * Dummy ModuleConfig for calls to reset() and validate().
61 */
62 protected ModuleConfig moduleConfig = null;
63
64 /***
65 * The basic <code>DynaActionForm</code> to use for testing.
66 */
67 protected DynaActionForm dynaForm = null;
68
69 /***
70 * Dummy ActionMapping for calls to reset() and validate().
71 */
72 protected ActionMapping mapping = null;
73 protected Log log = null;
74
75 /***
76 * Defines the testcase name for JUnit.
77 *
78 * @param theName the testcase's name.
79 */
80 public TestDynaActionForm(String theName) {
81 super(theName);
82 }
83
84 /***
85 * Start the tests.
86 *
87 * @param theArgs the arguments. Not used
88 */
89 public static void main(String[] theArgs) {
90 junit.awtui.TestRunner.main(new String[] {
91 TestDynaActionForm.class.getName()
92 });
93 }
94
95 /***
96 * @return a test suite (<code>TestSuite</code>) that includes all methods
97 * starting with "test"
98 */
99 public static Test suite() {
100
101 return new TestSuite(TestDynaActionForm.class);
102 }
103
104
105 public void setUp() {
106 super.setUp();
107
108 try {
109 dynaForm = (DynaActionForm) dynaClass.newInstance();
110 } catch (IllegalAccessException e) {
111 throw new RuntimeException(e.getMessage());
112 } catch (InstantiationException e) {
113 throw new RuntimeException(e.getMessage());
114 }
115
116 setupComplexProperties();
117 moduleConfig = new DynaActionFormConfig(beanConfig);
118 mapping = new DynaActionFormMapping(moduleConfig);
119 log = LogFactory.getLog(this.getClass().getName() + "."
120 + this.getName());
121 }
122
123 public void tearDown() {
124 super.tearDown();
125 moduleConfig = null;
126 dynaForm = null;
127 mapping = null;
128 }
129
130
131
132 public void testBeanCreate() {
133 assertEquals("booleanProperty", Boolean.TRUE,
134 (Boolean) dynaForm.get("booleanProperty"));
135 assertEquals("booleanSecond", Boolean.TRUE,
136 (Boolean) dynaForm.get("booleanSecond"));
137 assertEquals("doubleProperty", new Double(321.0),
138 (Double) dynaForm.get("doubleProperty"));
139 assertEquals("floatProperty", new Float((float) 123.0),
140 (Float) dynaForm.get("floatProperty"));
141 assertEquals("intProperty", new Integer(123),
142 (Integer) dynaForm.get("intProperty"));
143
144
145 assertEquals("longProperty", new Long((long) 321),
146 (Long) dynaForm.get("longProperty"));
147
148
149
150
151
152 assertEquals("shortProperty", new Short((short) 987),
153 (Short) dynaForm.get("shortProperty"));
154 assertEquals("stringProperty", "This is a string",
155 (String) dynaForm.get("stringProperty"));
156 }
157
158
159
160 public void testIndexedInitialize() {
161
162 dynaForm.set("intArray", 1, new Integer(111));
163 assertEquals("intArray[1]", new Integer(111),
164 (Integer) dynaForm.get("intArray", 1));
165 dynaForm.set("intIndexed", 2, new Integer(222));
166 assertEquals("intIndexed[2]", new Integer(222),
167 (Integer) dynaForm.get("intIndexed", 2));
168 dynaForm.set("stringArray", 3, "New String 3");
169 assertEquals("stringArray[3]", "New String 3",
170 (String) dynaForm.get("stringArray", 3));
171 dynaForm.set("stringIndexed", 4, "New String 4");
172 assertEquals("stringIndexed[4]", "New String 4",
173 (String) dynaForm.get("stringIndexed", 4));
174
175
176
177 dynaForm.initialize(mapping);
178 setupComplexProperties();
179 testGetIndexedValues();
180 }
181
182
183 public void testScalarInitialize() {
184
185 dynaForm.set("booleanProperty", Boolean.FALSE);
186 assertEquals("booleanProperty", Boolean.FALSE,
187 (Boolean) dynaForm.get("booleanProperty"));
188 dynaForm.set("booleanSecond", Boolean.FALSE);
189 dynaForm.set("doubleProperty", new Double(654.0));
190 dynaForm.set("floatProperty", new Float((float) 543.0));
191 dynaForm.set("intProperty", new Integer(555));
192 dynaForm.set("longProperty", new Long((long) 777));
193 dynaForm.set("shortProperty", new Short((short) 222));
194 dynaForm.set("stringProperty", "New String Value");
195 assertEquals("stringProperty", "New String Value",
196 (String) dynaForm.get("stringProperty"));
197
198
199 dynaForm.initialize(mapping);
200 setupComplexProperties();
201 testBeanCreate();
202 }
203
204
205
206 /***
207 * Corner cases on getDynaProperty invalid arguments.
208 */
209 public void testGetDescriptorArguments() {
210 DynaProperty descriptor =
211 dynaForm.getDynaClass().getDynaProperty("unknown");
212
213 assertNull("Unknown property descriptor should be null", descriptor);
214
215 try {
216 dynaForm.getDynaClass().getDynaProperty(null);
217 fail("Should throw IllegalArgumentException");
218 } catch (IllegalArgumentException e) {
219 ;
220 }
221 }
222
223 /***
224 * Positive getDynaProperty on property <code>booleanProperty</code>.
225 */
226 public void testGetDescriptorBoolean() {
227 testGetDescriptorBase("booleanProperty", Boolean.TYPE);
228 }
229
230 /***
231 * Positive getDynaProperty on property <code>doubleProperty</code>.
232 */
233 public void testGetDescriptorDouble() {
234 testGetDescriptorBase("doubleProperty", Double.TYPE);
235 }
236
237 /***
238 * Positive getDynaProperty on property <code>floatProperty</code>.
239 */
240 public void testGetDescriptorFloat() {
241 testGetDescriptorBase("floatProperty", Float.TYPE);
242 }
243
244 /***
245 * Positive getDynaProperty on property <code>intProperty</code>.
246 */
247 public void testGetDescriptorInt() {
248 testGetDescriptorBase("intProperty", Integer.TYPE);
249 }
250
251 /***
252 * Positive getDynaProperty on property <code>longProperty</code>.
253 */
254 public void testGetDescriptorLong() {
255 testGetDescriptorBase("longProperty", Long.TYPE);
256 }
257
258 /***
259 * Positive getDynaProperty on property <code>booleanSecond</code> that
260 * uses an "is" method as the getter.
261 */
262 public void testGetDescriptorSecond() {
263 testGetDescriptorBase("booleanSecond", Boolean.TYPE);
264 }
265
266 /***
267 * Positive getDynaProperty on property <code>shortProperty</code>.
268 */
269 public void testGetDescriptorShort() {
270 testGetDescriptorBase("shortProperty", Short.TYPE);
271 }
272
273 /***
274 * Positive getDynaProperty on property <code>stringProperty</code>.
275 */
276 public void testGetDescriptorString() {
277 testGetDescriptorBase("stringProperty", String.class);
278 }
279
280 /***
281 * Positive test for getDynaPropertys(). Each property name listed in
282 * <code>properties</code> should be returned exactly once.
283 */
284 public void testGetDescriptors() {
285 DynaProperty[] pd = dynaForm.getDynaClass().getDynaProperties();
286
287 assertNotNull("Got descriptors", pd);
288
289 int[] count = new int[properties.length];
290
291 for (int i = 0; i < pd.length; i++) {
292 String name = pd[i].getName();
293
294 for (int j = 0; j < properties.length; j++) {
295 if (name.equals(properties[j])) {
296 count[j]++;
297 }
298 }
299 }
300
301 for (int j = 0; j < properties.length; j++) {
302 if (count[j] < 0) {
303 fail("Missing property " + properties[j]);
304 } else if (count[j] > 1) {
305 fail("Duplicate property " + properties[j]);
306 }
307 }
308 }
309
310 /***
311 * Corner cases on getIndexedProperty invalid arguments.
312 */
313 public void testGetIndexedArguments() {
314 try {
315 dynaForm.get("intArray", -1);
316 fail("Should throw IndexOutOfBoundsException");
317 } catch (IndexOutOfBoundsException e) {
318 ;
319 }
320 }
321
322 /***
323 * Positive and negative tests on getIndexedProperty valid arguments.
324 */
325 public void testGetIndexedValues() {
326 Object value = null;
327
328 for (int i = 0; i < 5; i++) {
329 value = dynaForm.get("intArray", i);
330 assertNotNull("intArray returned value " + i, value);
331 assertTrue("intArray returned Integer " + i,
332 value instanceof Integer);
333 assertEquals("intArray returned correct " + i, i * 10,
334 ((Integer) value).intValue());
335
336 value = dynaForm.get("intIndexed", i);
337 assertNotNull("intIndexed returned value " + i, value);
338 assertTrue("intIndexed returned Integer " + i,
339 value instanceof Integer);
340 assertEquals("intIndexed returned correct " + i, i * 100,
341 ((Integer) value).intValue());
342
343 value = dynaForm.get("listIndexed", i);
344 assertNotNull("listIndexed returned value " + i, value);
345 assertTrue("list returned String " + i, value instanceof String);
346 assertEquals("listIndexed returned correct " + i, "String " + i,
347 (String) value);
348
349 value = dynaForm.get("stringArray", i);
350 assertNotNull("stringArray returned value " + i, value);
351 assertTrue("stringArray returned String " + i,
352 value instanceof String);
353 assertEquals("stringArray returned correct " + i, "String " + i,
354 (String) value);
355
356 value = dynaForm.get("stringIndexed", i);
357 assertNotNull("stringIndexed returned value " + i, value);
358 assertTrue("stringIndexed returned String " + i,
359 value instanceof String);
360 assertEquals("stringIndexed returned correct " + i, "String " + i,
361 (String) value);
362 }
363 }
364
365 /***
366 * Corner cases on getMappedProperty invalid arguments.
367 */
368 public void testGetMappedArguments() {
369 Object value = dynaForm.get("mappedProperty", "unknown");
370
371 assertNull("Should not return a value", value);
372 }
373
374 /***
375 * Positive and negative tests on getMappedProperty valid arguments.
376 */
377 public void testGetMappedValues() {
378 Object value = null;
379
380 value = dynaForm.get("mappedProperty", "First Key");
381 assertEquals("Can find first value", "First Value", value);
382
383 value = dynaForm.get("mappedProperty", "Second Key");
384 assertEquals("Can find second value", "Second Value", value);
385
386 value = dynaForm.get("mappedProperty", "Third Key");
387 assertNull("Can not find third value", value);
388 }
389
390 /***
391 * Corner cases on getSimpleProperty invalid arguments.
392 */
393 public void testGetSimpleArguments() {
394 try {
395 dynaForm.get(null);
396 fail("Should throw IllegalArgumentException");
397 } catch (IllegalArgumentException e) {
398 ;
399 }
400 }
401
402 /***
403 * Test getSimpleProperty on a boolean property.
404 */
405 public void testGetSimpleBoolean() {
406 Object value = dynaForm.get("booleanProperty");
407
408 assertNotNull("Got a value", value);
409 assertTrue("Got correct type", (value instanceof Boolean));
410 assertTrue("Got correct value", ((Boolean) value).booleanValue() == true);
411 }
412
413 /***
414 * Test getSimpleProperty on a double property.
415 */
416 public void testGetSimpleDouble() {
417 Object value = dynaForm.get("doubleProperty");
418
419 assertNotNull("Got a value", value);
420 assertTrue("Got correct type", (value instanceof Double));
421 assertEquals("Got correct value", ((Double) value).doubleValue(),
422 (double) 321.0, (double) 0.005);
423 }
424
425 /***
426 * Test getSimpleProperty on a float property.
427 */
428 public void testGetSimpleFloat() {
429 Object value = dynaForm.get("floatProperty");
430
431 assertNotNull("Got a value", value);
432 assertTrue("Got correct type", (value instanceof Float));
433 assertEquals("Got correct value", ((Float) value).floatValue(),
434 (float) 123.0, (float) 0.005);
435 }
436
437 /***
438 * Test getSimpleProperty on a int property.
439 */
440 public void testGetSimpleInt() {
441 Object value = dynaForm.get("intProperty");
442
443 assertNotNull("Got a value", value);
444 assertTrue("Got correct type", (value instanceof Integer));
445 assertEquals("Got correct value", ((Integer) value).intValue(),
446 (int) 123);
447 }
448
449 /***
450 * Test getSimpleProperty on a long property.
451 */
452 public void testGetSimpleLong() {
453 Object value = dynaForm.get("longProperty");
454
455 assertNotNull("Got a value", value);
456 assertTrue("Got correct type", (value instanceof Long));
457 assertEquals("Got correct value", ((Long) value).longValue(), (long) 321);
458 }
459
460 /***
461 * Test getSimpleProperty on a short property.
462 */
463 public void testGetSimpleShort() {
464 Object value = dynaForm.get("shortProperty");
465
466 assertNotNull("Got a value", value);
467 assertTrue("Got correct type", (value instanceof Short));
468 assertEquals("Got correct value", ((Short) value).shortValue(),
469 (short) 987);
470 }
471
472 /***
473 * Test getSimpleProperty on a String property.
474 */
475 public void testGetSimpleString() {
476 Object value = dynaForm.get("stringProperty");
477
478 assertNotNull("Got a value", value);
479 assertTrue("Got correct type", (value instanceof String));
480 assertEquals("Got correct value", (String) value, "This is a string");
481 }
482
483 /***
484 * Test <code>contains()</code> method for mapped properties.
485 */
486 public void testMappedContains() {
487 assertTrue("Can see first key",
488 dynaForm.contains("mappedProperty", "First Key"));
489
490 assertTrue("Can not see unknown key",
491 !dynaForm.contains("mappedProperty", "Unknown Key"));
492 }
493
494 /***
495 * Test <code>remove()</code> method for mapped properties.
496 */
497 public void testMappedRemove() {
498 assertTrue("Can see first key",
499 dynaForm.contains("mappedProperty", "First Key"));
500 dynaForm.remove("mappedProperty", "First Key");
501 assertTrue("Can not see first key",
502 !dynaForm.contains("mappedProperty", "First Key"));
503
504 assertTrue("Can not see unknown key",
505 !dynaForm.contains("mappedProperty", "Unknown Key"));
506 dynaForm.remove("mappedProperty", "Unknown Key");
507 assertTrue("Can not see unknown key",
508 !dynaForm.contains("mappedProperty", "Unknown Key"));
509 }
510
511 /***
512 * Test the reset method when the request method is GET.
513 */
514 public void testResetGet() {
515
516 dynaForm.set("booleanProperty", Boolean.FALSE);
517 dynaForm.set("booleanSecond", Boolean.FALSE);
518 dynaForm.set("doubleProperty", new Double(456.0));
519 dynaForm.set("floatProperty", new Float((float) 456.0));
520 dynaForm.set("intProperty", new Integer(456));
521
522 MockHttpServletRequest request = new MockHttpServletRequest();
523
524 request.setMethod("GET");
525 dynaForm.reset(mapping, request);
526
527 assertEquals("booleanProperty should be reset", Boolean.TRUE,
528 (Boolean) dynaForm.get("booleanProperty"));
529 assertEquals("booleanSecond should be reset", Boolean.TRUE,
530 (Boolean) dynaForm.get("booleanSecond"));
531 assertEquals("doubleProperty should be reset", new Double(321.0),
532 (Double) dynaForm.get("doubleProperty"));
533 assertEquals("floatProperty should NOT be reset",
534 new Float((float) 456.0), (Float) dynaForm.get("floatProperty"));
535 assertEquals("intProperty should NOT be reset", new Integer(456),
536 (Integer) dynaForm.get("intProperty"));
537 }
538
539 /***
540 * Test the reset method when the request method is GET.
541 */
542 public void testResetPost() {
543
544 dynaForm.set("booleanProperty", Boolean.FALSE);
545 dynaForm.set("booleanSecond", Boolean.FALSE);
546 dynaForm.set("doubleProperty", new Double(456.0));
547 dynaForm.set("floatProperty", new Float((float) 456.0));
548 dynaForm.set("intProperty", new Integer(456));
549
550 MockHttpServletRequest request = new MockHttpServletRequest();
551
552 request.setMethod("POST");
553 dynaForm.reset(mapping, request);
554
555 assertEquals("booleanProperty should be reset", Boolean.TRUE,
556 (Boolean) dynaForm.get("booleanProperty"));
557 assertEquals("booleanSecond should be reset", Boolean.TRUE,
558 (Boolean) dynaForm.get("booleanSecond"));
559 assertEquals("doubleProperty should NOT be reset", new Double(456),
560 (Double) dynaForm.get("doubleProperty"));
561 assertEquals("floatProperty should be reset", new Float((float) 123.0),
562 (Float) dynaForm.get("floatProperty"));
563 assertEquals("intProperty should NOT be reset", new Integer(456),
564 (Integer) dynaForm.get("intProperty"));
565 }
566
567 /***
568 * Corner cases on setIndexedProperty invalid arguments.
569 */
570 public void testSetIndexedArguments() {
571 try {
572 dynaForm.set("intArray", -1, new Integer(0));
573 fail("Should throw IndexOutOfBoundsException");
574 } catch (IndexOutOfBoundsException e) {
575 ;
576 }
577 }
578
579 /***
580 * Positive and negative tests on setIndexedProperty valid arguments.
581 */
582 public void testSetIndexedValues() {
583 Object value = null;
584
585 dynaForm.set("intArray", 0, new Integer(1));
586 value = (Integer) dynaForm.get("intArray", 0);
587 assertNotNull("Returned new value 0", value);
588 assertTrue("Returned Integer new value 0", value instanceof Integer);
589 assertEquals("Returned correct new value 0", 1,
590 ((Integer) value).intValue());
591
592 dynaForm.set("intIndexed", 1, new Integer(11));
593 value = (Integer) dynaForm.get("intIndexed", 1);
594 assertNotNull("Returned new value 1", value);
595 assertTrue("Returned Integer new value 1", value instanceof Integer);
596 assertEquals("Returned correct new value 1", 11,
597 ((Integer) value).intValue());
598 dynaForm.set("listIndexed", 2, "New Value 2");
599 value = (String) dynaForm.get("listIndexed", 2);
600 assertNotNull("Returned new value 2", value);
601 assertTrue("Returned String new value 2", value instanceof String);
602 assertEquals("Returned correct new value 2", "New Value 2",
603 (String) value);
604
605 dynaForm.set("stringArray", 3, "New Value 3");
606 value = (String) dynaForm.get("stringArray", 3);
607 assertNotNull("Returned new value 3", value);
608 assertTrue("Returned String new value 3", value instanceof String);
609 assertEquals("Returned correct new value 3", "New Value 3",
610 (String) value);
611
612 dynaForm.set("stringIndexed", 4, "New Value 4");
613 value = (String) dynaForm.get("stringIndexed", 4);
614 assertNotNull("Returned new value 4", value);
615 assertTrue("Returned String new value 4", value instanceof String);
616 assertEquals("Returned correct new value 4", "New Value 4",
617 (String) value);
618 }
619
620 /***
621 * Positive and negative tests on setMappedProperty valid arguments.
622 */
623 public void testSetMappedValues() {
624 dynaForm.set("mappedProperty", "First Key", "New First Value");
625 assertEquals("Can replace old value", "New First Value",
626 (String) dynaForm.get("mappedProperty", "First Key"));
627
628 dynaForm.set("mappedProperty", "Fourth Key", "Fourth Value");
629 assertEquals("Can set new value", "Fourth Value",
630 (String) dynaForm.get("mappedProperty", "Fourth Key"));
631 }
632
633 /***
634 * Test setSimpleProperty on a boolean property.
635 */
636 public void testSetSimpleBoolean() {
637 boolean oldValue =
638 ((Boolean) dynaForm.get("booleanProperty")).booleanValue();
639 boolean newValue = !oldValue;
640
641 dynaForm.set("booleanProperty", new Boolean(newValue));
642 assertTrue("Matched new value",
643 newValue == ((Boolean) dynaForm.get("booleanProperty"))
644 .booleanValue());
645 }
646
647 /***
648 * Test setSimpleProperty on a double property.
649 */
650 public void testSetSimpleDouble() {
651 double oldValue =
652 ((Double) dynaForm.get("doubleProperty")).doubleValue();
653 double newValue = oldValue + 1.0;
654
655 dynaForm.set("doubleProperty", new Double(newValue));
656 assertEquals("Matched new value", newValue,
657 ((Double) dynaForm.get("doubleProperty")).doubleValue(),
658 (double) 0.005);
659 }
660
661 /***
662 * Test setSimpleProperty on a float property.
663 */
664 public void testSetSimpleFloat() {
665 float oldValue = ((Float) dynaForm.get("floatProperty")).floatValue();
666 float newValue = oldValue + (float) 1.0;
667
668 dynaForm.set("floatProperty", new Float(newValue));
669 assertEquals("Matched new value", newValue,
670 ((Float) dynaForm.get("floatProperty")).floatValue(), (float) 0.005);
671 }
672
673 /***
674 * Test setSimpleProperty on a int property.
675 */
676 public void testSetSimpleInt() {
677 int oldValue = ((Integer) dynaForm.get("intProperty")).intValue();
678 int newValue = oldValue + 1;
679
680 dynaForm.set("intProperty", new Integer(newValue));
681 assertEquals("Matched new value", newValue,
682 ((Integer) dynaForm.get("intProperty")).intValue());
683 }
684
685 /***
686 * Test setSimpleProperty on a long property.
687 */
688 public void testSetSimpleLong() {
689 long oldValue = ((Long) dynaForm.get("longProperty")).longValue();
690 long newValue = oldValue + 1;
691
692 dynaForm.set("longProperty", new Long(newValue));
693 assertEquals("Matched new value", newValue,
694 ((Long) dynaForm.get("longProperty")).longValue());
695 }
696
697 /***
698 * Test setSimpleProperty on a short property.
699 */
700 public void testSetSimpleShort() {
701 short oldValue = ((Short) dynaForm.get("shortProperty")).shortValue();
702 short newValue = (short) (oldValue + 1);
703
704 dynaForm.set("shortProperty", new Short(newValue));
705 assertEquals("Matched new value", newValue,
706 ((Short) dynaForm.get("shortProperty")).shortValue());
707 }
708
709 /***
710 * Test setSimpleProperty on a String property.
711 */
712 public void testSetSimpleString() {
713 String oldValue = (String) dynaForm.get("stringProperty");
714 String newValue = oldValue + " Extra Value";
715
716 dynaForm.set("stringProperty", newValue);
717 assertEquals("Matched new value", newValue,
718 (String) dynaForm.get("stringProperty"));
719 }
720
721
722
723 /***
724 * Set up the complex properties that cannot be configured from the
725 * initial value expression.
726 */
727 protected void setupComplexProperties() {
728 List listIndexed = new ArrayList();
729
730 listIndexed.add("String 0");
731 listIndexed.add("String 1");
732 listIndexed.add("String 2");
733 listIndexed.add("String 3");
734 listIndexed.add("String 4");
735 dynaForm.set("listIndexed", listIndexed);
736
737 Map mappedProperty = new HashMap();
738
739 mappedProperty.put("First Key", "First Value");
740 mappedProperty.put("Second Key", "Second Value");
741 dynaForm.set("mappedProperty", mappedProperty);
742
743 Map mappedIntProperty = new HashMap();
744
745 mappedIntProperty.put("One", new Integer(1));
746 mappedIntProperty.put("Two", new Integer(2));
747 dynaForm.set("mappedIntProperty", mappedIntProperty);
748 }
749
750 /***
751 * Base for testGetDescriptorXxxxx() series of tests.
752 *
753 * @param name Name of the property to be retrieved
754 * @param type Expected class type of this property
755 */
756 protected void testGetDescriptorBase(String name, Class type) {
757 DynaProperty descriptor = dynaForm.getDynaClass().getDynaProperty(name);
758
759 assertNotNull("Got descriptor", descriptor);
760 assertEquals("Got correct type", type, descriptor.getType());
761 }
762 }
763
764
765 class DynaActionFormMapping extends ActionMapping {
766 private ModuleConfig appConfig = null;
767
768 public DynaActionFormMapping(ModuleConfig appConfig) {
769 this.appConfig = appConfig;
770 }
771
772 public ModuleConfig getModuleConfig() {
773 return (this.appConfig);
774 }
775
776 public String getName() {
777 return ("dynaForm");
778 }
779 }
780
781
782 class DynaActionFormConfig extends ModuleConfigImpl {
783 private FormBeanConfig beanConfig = null;
784
785 public DynaActionFormConfig(FormBeanConfig beanConfig) {
786 super("");
787 this.beanConfig = beanConfig;
788 }
789
790 public FormBeanConfig findFormBeanConfig(String name) {
791 return (this.beanConfig);
792 }
793 }