Skip to main content
summaryrefslogtreecommitdiffstats
blob: ddfb348e1e2635dba1dac065091bc69108fa9b2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
/*******************************************************************************
 * Copyright (c) 2001, 2008 Oracle Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Oracle Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.common.runtime.tests.model;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import junit.framework.Assert;

import org.eclipse.jst.jsf.common.runtime.internal.model.ViewObject;
import org.eclipse.jst.jsf.common.runtime.internal.model.bean.DataModelInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IActionSource2Info;
import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IActionSourceInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IEditableValueHolderInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IValueHolderInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentTypeInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.UICommandInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIDataInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIFormInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIInputInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIOutputInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ActionListenerDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ComponentDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterTypeInfo;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.Decorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.FacetDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorDecorator;
import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorTypeInfo;

public final class RuntimeTestUtil extends Assert
{
    // expected type info for jsf/core components
    public static final ComponentTypeInfo COMPINFO_PARAM = new ComponentTypeInfo(
            "javax.faces.Parameter", "javax.faces.component.UIParameter",
            new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.Parameter",
            null);

    public static final ComponentTypeInfo COMPINFO_SELECTITEM = new ComponentTypeInfo(
            "javax.faces.SelectItem", "javax.faces.component.UISelectItem",
            new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.SelectItem",
            null);

    public static final ComponentTypeInfo COMPINFO_SELECTITEMS = new ComponentTypeInfo(
            "javax.faces.SelectItems", "javax.faces.component.UISelectItems",
            new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", },
            "javax.faces.SelectItems", null);

    public static final ComponentTypeInfo COMPINFO_SUBVIEW = new ComponentTypeInfo(
            "javax.faces.NamingContainer",
            "javax.faces.component.UINamingContainer", new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.NamingContainer",
                    "javax.faces.component.StateHolder", },
            "javax.faces.NamingContainer", null);

    public static final ComponentTypeInfo COMPINFO_VERBATIM = new ComponentTypeInfo(
            "javax.faces.Output", "javax.faces.component.UIOutput",
            new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Output", "javax.faces.Text");

    public static final ComponentTypeInfo COMPINFO_VIEW = new ComponentTypeInfo(
            "javax.faces.ViewRoot", "javax.faces.component.UIViewRoot",
            new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.ViewRoot",
            null);

    // expected type info for jsf/html components
    public static final ComponentTypeInfo COMPINFO_COLUMN = new ComponentTypeInfo(
            "javax.faces.Column", "javax.faces.component.UIColumn",
            new String[]
            { "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object" },
            new String[]
            { "javax.faces.component.StateHolder" }, "javax.faces.Column", null);
    public static final ComponentTypeInfo COMPINFO_COMMAND = new ComponentTypeInfo(
            "javax.faces.HtmlCommandButton",
            "javax.faces.component.html.HtmlCommandButton", new String[]
            { "javax.faces.component.UICommand",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object" },
            new String[]
            { "javax.faces.component.ActionSource",
                    "javax.faces.component.StateHolder" },
            "javax.faces.Command", "javax.faces.Button");
    public static final ComponentTypeInfo COMPINFO_COMMANDLINK = new ComponentTypeInfo(
            "javax.faces.HtmlCommandLink",
            "javax.faces.component.html.HtmlCommandLink",
            new String[]
                       { "javax.faces.component.UICommand",
                               "javax.faces.component.UIComponentBase",
                               "javax.faces.component.UIComponent", "java.lang.Object" },
                       new String[]
                       { "javax.faces.component.ActionSource",
                               "javax.faces.component.StateHolder" },
                       "javax.faces.Command", "javax.faces.Link");
    public static final ComponentTypeInfo COMPINFO_DATATABLE = new ComponentTypeInfo(
            "javax.faces.HtmlDataTable",
            "javax.faces.component.html.HtmlDataTable", new String[]
            { "javax.faces.component.UIData",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object" },
            new String[]
            { "javax.faces.component.NamingContainer",
                    "javax.faces.component.StateHolder", }, "javax.faces.Data",
            "javax.faces.Table");
    public static final ComponentTypeInfo COMPINFO_FORM = new ComponentTypeInfo(
            "javax.faces.HtmlForm", "javax.faces.component.html.HtmlForm",
            new String[]
            { "javax.faces.component.UIForm",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object" },
            new String[]
            { "javax.faces.component.NamingContainer",
                    "javax.faces.component.StateHolder" }, "javax.faces.Form",
            "javax.faces.Form");
    public static final ComponentTypeInfo COMPINFO_GRAPHIC = new ComponentTypeInfo(
            "javax.faces.HtmlGraphicImage",
            "javax.faces.component.html.HtmlGraphicImage", new String[]
            { "javax.faces.component.UIGraphic",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.Graphic",
            "javax.faces.Image");
    public static final ComponentTypeInfo COMPINFO_HIDDEN = new ComponentTypeInfo(
            "javax.faces.HtmlInputHidden",
            "javax.faces.component.html.HtmlInputHidden", new String[]
            { "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Input", "javax.faces.Hidden");
    public static final ComponentTypeInfo COMPINFO_SECRET = new ComponentTypeInfo(
            "javax.faces.HtmlInputSecret",
            "javax.faces.component.html.HtmlInputSecret", new String[]
            { "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder" }, "javax.faces.Input",
            "javax.faces.Secret");
    public static final ComponentTypeInfo COMPINFO_INPUTTEXT = new ComponentTypeInfo(
            "javax.faces.HtmlInputText",
            "javax.faces.component.html.HtmlInputText", new String[]
            { "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object" },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder" }, "javax.faces.Input",
            "javax.faces.Text");
    public static final ComponentTypeInfo COMPINFO_INPUTTEXTAREA = new ComponentTypeInfo(
            "javax.faces.HtmlInputTextarea",
            "javax.faces.component.html.HtmlInputTextarea", new String[]
            { "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Input", "javax.faces.Textarea");
    public static final ComponentTypeInfo COMPINFO_MESSAGE = new ComponentTypeInfo(
            "javax.faces.HtmlMessage",
            "javax.faces.component.html.HtmlMessage", new String[]
            { "javax.faces.component.UIMessage",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.Message",
            "javax.faces.Message");
    public static final ComponentTypeInfo COMPINFO_MESSAGES = new ComponentTypeInfo(
            "javax.faces.HtmlMessages",
            "javax.faces.component.html.HtmlMessages", new String[]
            { "javax.faces.component.UIMessages",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.Messages",
            "javax.faces.Messages");
    public static final ComponentTypeInfo COMPINFO_OUTPUTFORMAT = new ComponentTypeInfo(
            "javax.faces.HtmlOutputFormat",
            "javax.faces.component.html.HtmlOutputFormat", new String[]
            { "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Output", "javax.faces.Format");
    public static final ComponentTypeInfo COMPINFO_OUTPUTLABEL = new ComponentTypeInfo(
            "javax.faces.HtmlOutputLabel",
            "javax.faces.component.html.HtmlOutputLabel", new String[]
            { "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Output", "javax.faces.Label");
    public static final ComponentTypeInfo COMPINFO_OUTPUTLINK = new ComponentTypeInfo(
            "javax.faces.HtmlOutputLink",
            "javax.faces.component.html.HtmlOutputLink", new String[]
            { "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Output", "javax.faces.Link");
    public static final ComponentTypeInfo COMPINFO_OUTPUTTEXT = new ComponentTypeInfo(
            "javax.faces.HtmlOutputText",
            "javax.faces.component.html.HtmlOutputText", new String[]
            { "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.Output", "javax.faces.Text");
    public static final ComponentTypeInfo COMPINFO_PANELGRID = new ComponentTypeInfo(
            "javax.faces.HtmlPanelGrid",
            "javax.faces.component.html.HtmlPanelGrid", new String[]
            { "javax.faces.component.UIPanel",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.Panel",
            "javax.faces.Grid");
    public static final ComponentTypeInfo COMPINFO_PANELGROUP = new ComponentTypeInfo(
            "javax.faces.HtmlPanelGroup",
            "javax.faces.component.html.HtmlPanelGroup", new String[]
            { "javax.faces.component.UIPanel",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.StateHolder", }, "javax.faces.Panel",
            "javax.faces.Group");
    public static final ComponentTypeInfo COMPINFO_SELECTBOOLEANCHECKBOX = new ComponentTypeInfo(
            "javax.faces.HtmlSelectBooleanCheckbox",
            "javax.faces.component.html.HtmlSelectBooleanCheckbox",
            new String[]
            { "javax.faces.component.UISelectBoolean",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectBoolean", "javax.faces.Checkbox");
    public static final ComponentTypeInfo COMPINFO_SELECTMANYCHECKBOX = new ComponentTypeInfo(
            "javax.faces.HtmlSelectManyCheckbox",
            "javax.faces.component.html.HtmlSelectManyCheckbox", new String[]
            { "javax.faces.component.UISelectMany",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectMany", "javax.faces.Checkbox");
    public static final ComponentTypeInfo COMPINFO_SELECTMANYLISTBOX = new ComponentTypeInfo(
            "javax.faces.HtmlSelectManyListbox",
            "javax.faces.component.html.HtmlSelectManyListbox", new String[]
            { "javax.faces.component.UISelectMany",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectMany", "javax.faces.Listbox");
    public static final ComponentTypeInfo COMPINFO_SELECTMANYMENU = new ComponentTypeInfo(
            "javax.faces.HtmlSelectManyMenu",
            "javax.faces.component.html.HtmlSelectManyMenu", new String[]
            { "javax.faces.component.UISelectMany",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectMany", "javax.faces.Menu");
    public static final ComponentTypeInfo COMPINFO_SELECTONELISTBOX = new ComponentTypeInfo(
            "javax.faces.HtmlSelectOneListbox",
            "javax.faces.component.html.HtmlSelectOneListbox", new String[]
            { "javax.faces.component.UISelectOne",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectOne", "javax.faces.Listbox");
    public static final ComponentTypeInfo COMPINFO_SELECTONEMENU = new ComponentTypeInfo(
            "javax.faces.HtmlSelectOneMenu",
            "javax.faces.component.html.HtmlSelectOneMenu", new String[]
            { "javax.faces.component.UISelectOne",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectOne", "javax.faces.Menu");
    public static final ComponentTypeInfo COMPINFO_SELECTONERADIO = new ComponentTypeInfo(
            "javax.faces.HtmlSelectOneRadio",
            "javax.faces.component.html.HtmlSelectOneRadio", new String[]
            { "javax.faces.component.UISelectOne",
                    "javax.faces.component.UIInput",
                    "javax.faces.component.UIOutput",
                    "javax.faces.component.UIComponentBase",
                    "javax.faces.component.UIComponent", "java.lang.Object", },
            new String[]
            { "javax.faces.component.EditableValueHolder",
                    "javax.faces.component.ValueHolder",
                    "javax.faces.component.StateHolder", },
            "javax.faces.SelectOne", "javax.faces.Radio");

    // default converters
    public static final ConverterTypeInfo CONVERTERINFO_DATETIME = new ConverterTypeInfo(
            "javax.faces.convert.DateTimeConverter", "javax.faces.DateTime");

    public static final ConverterTypeInfo CONVERTERINFO_NUMBER = new ConverterTypeInfo(
            "javax.faces.convert.NumberConverter", "javax.faces.Number");

    // default validators
    public static final ValidatorTypeInfo VALIDATORINFO_DOUBLERANGE = new ValidatorTypeInfo(
            "javax.faces.validator.DoubleRangeValidator",
            "javax.faces.DoubleRange");

    public static final ValidatorTypeInfo VALIDATORINFO_LENGTH = new ValidatorTypeInfo(
            "javax.faces.validator.LengthValidator", "javax.faces.Length");

    public static final ValidatorTypeInfo VALIDATORINFO_LONGRANGE = new ValidatorTypeInfo(
            "javax.faces.validator.LongRangeValidator", "javax.faces.LongRange");

    // public static final ValidatorTypeInfo VALIDATORINFO_METHODEXPRESSION =
    // new ValidatorTypeInfo(
    // "javax.faces.validator.MethodExpressionValidator ",
    // "javax.faces.LongRange");

    @SuppressWarnings("unchecked")
    public static <COMPONENT_T> COMPONENT_T serializeDeserialize(
            final COMPONENT_T object) throws IOException,
            ClassNotFoundException
    {
        final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        final ObjectOutputStream outStream = new ObjectOutputStream(byteStream);

        outStream.writeObject(object);

        final ByteArrayInputStream byteArray = new ByteArrayInputStream(
                byteStream.toByteArray());
        final ObjectInputStream inStream = new ObjectInputStream(byteArray);

        return (COMPONENT_T) inStream.readObject();
    }

    public static void verifyImplicitAdapter(final ViewObject check,
            final Class<?> adapterType, final Object explicitAdapter)
    {
        assertEquals(check, check.getAdapter(adapterType));
        // cannot add explicit adapter if check is already that type
        boolean caughtException = false;
        
        try
        {
            check.addAdapter(adapterType, explicitAdapter);
        }
        catch (IllegalArgumentException iae)
        {
            caughtException = true;
        }
        
        assertTrue(caughtException);

        // should be unaffected by the attempt
        assertEquals(check, check.getAdapter(adapterType));
    }

    public static void verifySame(final ComponentTypeInfo truth,
            final ComponentTypeInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getClassName(), check.getClassName());
        assertEquals(truth.getComponentFamily(), check.getComponentFamily());
        assertEquals(truth.getComponentType(), check.getComponentType());
        assertEquals(truth.getRenderFamily(), check.getRenderFamily());
        
        verifyArraysSame(truth.getInterfaces(), check.getInterfaces());
        verifyArraysSame(truth.getSuperClasses(), check.getSuperClasses());
    }

    public static <T> void verifyArraysSame(T[]  expected, T[] check)
    {
        assertEquals("Arrays must be same size", expected.length, check.length);
        
        Set<T>  expectedValues = new HashSet<T>();
        
        for (final T e : expected)
        {
            expectedValues.add(e);
        }
        
        for (final T e : check)
        {
            assertTrue("Must contain "+e,expectedValues.contains(e));
        }
    }
    
    public static void verifySame(final DataModelInfo truth,
            final DataModelInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getRowCount(), check.getRowCount());
        assertEquals(truth.getRowIndex(), check.getRowIndex());

        // assertEquals(truth.getRowData(), check.getRowData());
        // assertEquals(truth.getWrappedData(), check.getWrappedData());
    }

    public static void verifySame(final ViewObject truth, final ViewObject check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getAllDecorators().size(), check.getAllDecorators()
                .size());

        for (int i = 0; i < check.getAllDecorators().size(); i++)
        {
            verifySame((Decorator) truth.getAllDecorators().get(i),
                    (Decorator) check.getAllDecorators().get(i));
        }

        // TODO: hard to check adapters since they are arbitrary
        assertEquals(truth.getAllAdapters().size(), truth.getAllAdapters()
                .size());
        // can at least check that the keys match
        assertEquals(truth.getAllAdapters().keySet(), check.getAllAdapters()
                .keySet());
    }

    public static void verifySame(final ComponentInfo truth,
            final ComponentInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ViewObject) truth, (ViewObject) check);
        verifySame(truth.getComponentTypeInfo(), check.getComponentTypeInfo());

        assertEquals(truth.getId(), check.getId());
        assertEquals(truth.isRendered(), check.isRendered());
//        assertEquals(truth.getMostSpecificComponentName(), check
//                .getMostSpecificComponentName());
        // assertEquals(truth.getParent(), t);
        // TestRenderNode.verifySame(truth.getRenderNode(),
        // check.getRenderNode());

        assertEquals(truth.getChildren().size(), check.getChildren().size());

        for (int i = 0; i < check.getChildren().size(); i++)
        {
            final ComponentInfo checkChild = (ComponentInfo) check
                    .getChildren().get(i);
            verifySame((ComponentInfo) truth.getChildren().get(i), checkChild);
        }

        final List<?> truthGetAllDecorators = truth.getAllDecorators();
        final List<?> checkGetAllDecorators = check.getAllDecorators();

        for (int i = 0; i < checkGetAllDecorators.size(); i++)
        {
            final Decorator checkDecorator = (Decorator) checkGetAllDecorators
                    .get(i);

            verifySame((Decorator) truthGetAllDecorators.get(i), checkDecorator);
        }
    }

    public static void verifySame(final UIOutputInfo truth,
            final UIOutputInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ComponentInfo) truth, (ComponentInfo) check);
        verifySame((IValueHolderInfo) truth, (IValueHolderInfo) check);
    }

    public static void verifySame(final UIInputInfo truth,
            final UIInputInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((UIOutputInfo) truth, (UIOutputInfo) check);
        verifySame((IEditableValueHolderInfo) truth,
                (IEditableValueHolderInfo) check);
    }

    public static void verifySame(final UICommandInfo truth,
            final UICommandInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ComponentInfo) truth, (ComponentInfo) check);
        verifySame((IActionSourceInfo) truth, (IActionSourceInfo) check);
    }

    public static void verifySame(final UIFormInfo truth, final UIFormInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ComponentInfo) truth, (ComponentInfo) check);
        assertEquals(truth.isPrependId(), check.isPrependId());
        assertEquals(truth.isSubmitted(), check.isSubmitted());
    }

    public static void verifySame(final UIDataInfo truth, final UIDataInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ComponentInfo) truth, (ComponentInfo) check);

        assertEquals(truth.getFirst(), check.getFirst());
        assertEquals(truth.getRowCount(), check.getRowCount());
        assertEquals(truth.isRowAvailable(), check.isRowAvailable());
        assertEquals(truth.getRowIndex(), check.getRowIndex());
        assertEquals(truth.getRows(), check.getRows());
        assertEquals(truth.getVar(), check.getVar());
    }

    public static void verifySame(final Decorator truth, final Decorator check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getClass(), check.getClass());

        verifySame((ViewObject) truth, (ViewObject) check);

        if (truth instanceof FacetDecorator)
        {
            verifySame((FacetDecorator) truth, (FacetDecorator) check);
        }
        else if (truth instanceof ActionListenerDecorator)
        {
            verifySame((ActionListenerDecorator) truth,
                    (ActionListenerDecorator) check);
        }
        else if (truth instanceof ValidatorDecorator)
        {
            verifySame((ValidatorDecorator) truth, (ValidatorDecorator) check);
        }
        else if (truth instanceof ConverterDecorator)
        {
            verifySame((ConverterDecorator) truth, (ConverterDecorator) check);
        }
        else if (truth instanceof ComponentDecorator)
        {
            verifySame((ComponentDecorator) truth, (ComponentDecorator) check);
        }
    }

    private static void verifySame(final ComponentDecorator truth,
            final ComponentDecorator check)
    {
        verifySame(truth.getDecorates(), check.getDecorates());
    }

    private static void verifySame(final ActionListenerDecorator truth,
            final ActionListenerDecorator check)
    {
        verifySame((ComponentDecorator) truth, (ComponentDecorator) check);
    }

    private static void verifySame(final FacetDecorator truth,
            final FacetDecorator check)
    {
        verifySame((ComponentDecorator) truth, (ComponentDecorator) check);
        assertEquals(truth.getName(), check.getName());
    }

    private static void verifySame(final ConverterDecorator truth,
            final ConverterDecorator check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ComponentDecorator) truth, (ComponentDecorator) check);
    }

    public static void verifySame(final ConverterTypeInfo truth,
            final ConverterTypeInfo check)
    {
        if (truth == check)
        {
            return;
        }
        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getClassName(), check.getClassName());
        assertEquals(truth.getConverterId(), check.getConverterId());
    }

    private static void verifySame(final ValidatorDecorator truth,
            final ValidatorDecorator check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((ComponentDecorator) truth, (ComponentDecorator) check);
    }

    public static void verifySame(final ValidatorTypeInfo truth,
            final ValidatorTypeInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getClassName(), check.getClassName());
        assertEquals(truth.getValidatorId(), check.getValidatorId());
    }

    public static ComponentTypeInfo createComponentTypeInfo()
    {
        return new ComponentTypeInfo("org.eclipse.jst.jsf.test",
                "org.eclipse.jst.jsf.test.ComponentClass",
                "org.eclipse.jst.jsf.test.ComponentFamily",
                "org.eclipse.jst.jsf.test.RenderFamily");
    }

    public static void verifySame(final IValueHolderInfo truth,
            final IValueHolderInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getLocalValue(), check.getLocalValue());
        assertEquals(truth.getValue(), check.getValue());
        verifySame(truth.getConverter(), check.getConverter());
    }

    public static void verifySame(final IEditableValueHolderInfo truth,
            final IEditableValueHolderInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        verifySame((IValueHolderInfo) truth, (IValueHolderInfo) check);

        assertEquals(truth.isImmediate(), truth.isImmediate());
        assertEquals(truth.isLocalSetValue(), truth.isLocalSetValue());
        assertEquals(truth.isRequired(), truth.isRequired());
        assertEquals(truth.isValid(), truth.isValid());

        assertEquals(truth.getSubmittedValue(), check.getSubmittedValue());
        assertEquals(truth.getValidator(), check.getValidator());
        assertEquals(truth.getValueChangeListener(), truth
                .getValueChangeListener());

        // check validators
        assertEquals(truth.getValidators().size(), check.getValidators().size());

        for (int i = 0; i < check.getValidators().size(); i++)
        {
            verifySame((Decorator) truth.getValidators().get(i),
                    (Decorator) check.getValidators().get(i));
        }

        for (int i = 0; i < check.getValueChangeListeners().size(); i++)
        {
            verifySame((Decorator) truth.getValidators().get(i),
                    (Decorator) check.getValidators().get(i));
        }
    }

    public static void verifySame(final IActionSourceInfo truth,
            final IActionSourceInfo check)
    {
        if (truth == check)
        {
            return;
        }

        // the only way having truth or check null is valid is if
        // the are both null, which we check above
        assertNotNull(truth);
        assertNotNull(check);

        assertEquals(truth.getAction(), check.getAction());
        assertEquals(truth.getActionListener(), check.getActionListener());
        assertEquals(truth.isImmediate(), check.isImmediate());

        if (truth instanceof IActionSource2Info)
        {
            assertTrue(check instanceof IActionSource2Info);
            assertEquals(((IActionSource2Info) truth).getActionExpression(),
                    ((IActionSource2Info) check).getActionExpression());
        }

        // check action listener
        assertEquals(truth.getActionListeners().size(), check
                .getActionListeners().size());

        for (int i = 0; i < check.getActionListeners().size(); i++)
        {
            verifySame((Decorator) truth.getActionListeners().get(i),
                    (Decorator) check.getActionListeners().get(i));
        }
    }
}

Back to the top