SerializationStressTest4.java revision a99b695964e28a5906003d40db48cbd550fbcdf4
1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package tests.api.java.io;
19
20import dalvik.annotation.BrokenTest;
21import dalvik.annotation.KnownFailure;
22import dalvik.annotation.TestLevel;
23import dalvik.annotation.TestTargetNew;
24import dalvik.annotation.TestTargetClass;
25
26import java.io.File;
27import java.io.FilePermission;
28import java.io.IOException;
29import java.io.Serializable;
30import java.lang.reflect.InvocationHandler;
31import java.lang.reflect.Method;
32import java.lang.reflect.Proxy;
33import java.net.URI;
34import java.net.URISyntaxException;
35import java.security.AllPermission;
36import java.security.PermissionCollection;
37import java.security.cert.Certificate;
38import java.text.DateFormat;
39import java.text.MessageFormat;
40import java.text.NumberFormat;
41import java.util.Arrays;
42import java.util.Comparator;
43import java.util.Date;
44import java.util.Enumeration;
45import java.util.HashMap;
46import java.util.IdentityHashMap;
47import java.util.Iterator;
48import java.util.List;
49import java.util.Locale;
50import java.util.Map;
51import java.util.Set;
52import java.util.TimeZone;
53
54import tests.support.Support_Configuration;
55import tests.support.Support_Proxy_I1;
56
57@TestTargetClass(java.io.Serializable.class)
58public class SerializationStressTest4 extends SerializationStressTest {
59    // -----------------------------------------------------------------------------------
60    private static class GuardImplementation implements java.security.Guard,
61            java.io.Serializable {
62        public GuardImplementation() {
63        }
64
65        public void checkGuard(Object o) {
66        }
67    }
68
69    @TestTargetNew(
70        level = TestLevel.COMPLETE,
71        notes = "Verifies serialization.",
72        method = "!Serialization",
73        args = {}
74    )
75    public void test_writeObject_EventObject() {
76        // Test for method void
77        // java.io.ObjectOutputStream.writeObject(java.util.EventObject)
78
79        Object objToSave = null;
80        Object objLoaded = null;
81
82        try {
83            objToSave = new java.util.EventObject("Source");
84            if (DEBUG)
85                System.out.println("Obj = " + objToSave);
86            objLoaded = dumpAndReload(objToSave);
87
88            // Has to have worked
89            boolean equals;
90            equals = true;
91            // The the only data in EventObject that
92            // differentiates between instantiations is transient
93            assertTrue(MSG_TEST_FAILED + objToSave, equals);
94        } catch (IOException e) {
95            fail("IOException serializing " + objToSave + " : "
96                    + e.getMessage());
97        } catch (ClassNotFoundException e) {
98            fail("ClassNotFoundException reading Object type : "
99                    + e.getMessage());
100        } catch (Error err) {
101            System.out.println("Error when obj = " + objToSave);
102            // err.printStackTrace();
103            throw err;
104        }
105    }
106
107    @TestTargetNew(
108        level = TestLevel.COMPLETE,
109        notes = "Verifies serialization.",
110        method = "!Serialization",
111        args = {}
112    )
113    public void test_writeObject_PermissionCollection() {
114        // Test for method void
115        // java.io.ObjectOutputStream.writeObject(java.security.PermissionCollection)
116
117        Object objToSave = null;
118        Object objLoaded = null;
119
120        try {
121            objToSave = null;
122            objToSave = new java.security.PermissionCollection() {
123                boolean added = false;
124
125                public void add(java.security.Permission p1) {
126                    added = true;
127                }
128
129                public java.util.Enumeration elements() {
130                    return (new java.util.Vector()).elements();
131                }
132
133                public boolean implies(java.security.Permission p1) {
134                    return added;
135                }
136
137                public boolean equals(Object obj) {
138                    if (!(obj instanceof java.security.PermissionCollection))
139                        return false;
140                    return implies(null) == ((PermissionCollection) obj)
141                            .implies(null);
142                }
143            };
144
145            ((java.security.PermissionCollection) objToSave).add(null);
146            if (DEBUG)
147                System.out.println("Obj = " + objToSave);
148            objLoaded = dumpAndReload(objToSave);
149
150            // Has to have worked
151            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
152        } catch (IOException e) {
153            fail("IOException serializing " + objToSave + " : "
154                    + e.getMessage());
155        } catch (ClassNotFoundException e) {
156            fail("ClassNotFoundException reading Object type : "
157                    + e.getMessage());
158        } catch (Error err) {
159            System.out.println("Error when obj = " + objToSave);
160            // err.printStackTrace();
161            throw err;
162        }
163
164    }
165
166    @TestTargetNew(
167        level = TestLevel.COMPLETE,
168        notes = "Verifies serialization.",
169        method = "!Serialization",
170        args = {}
171    )
172    public void test_writeObject_Collections_EmptySet() {
173        // Test for method void
174        // java.io.ObjectOutputStream.writeObject(java.util.Collections.EmptySet)
175
176        Object objToSave = null;
177        Object objLoaded = null;
178
179        try {
180            objToSave = java.util.Collections.EMPTY_SET;
181            if (DEBUG)
182                System.out.println("Obj = " + objToSave);
183            objLoaded = dumpAndReload(objToSave);
184
185            // Has to have worked
186            boolean equals;
187            equals = objToSave.equals(objLoaded);
188            if (equals)
189                equals = ((Set) objLoaded).size() == 0;
190            assertTrue(MSG_TEST_FAILED + objToSave, equals);
191        } catch (IOException e) {
192            fail("IOException serializing " + objToSave + " : "
193                    + e.getMessage());
194        } catch (ClassNotFoundException e) {
195            fail("ClassNotFoundException reading Object type : "
196                    + e.getMessage());
197        } catch (Error err) {
198            System.out.println("Error when obj = " + objToSave);
199            // err.printStackTrace();
200            throw err;
201        }
202
203    }
204
205    @TestTargetNew(
206        level = TestLevel.COMPLETE,
207        notes = "Verifies serialization.",
208        method = "!Serialization",
209        args = {}
210    )
211    public void test_writeObject_Collections_EmptyMap() {
212        // Test for method void
213        // java.io.ObjectOutputStream.writeObject(java.util.Collections.EmptySet)
214
215        Object objToSave = null;
216        Object objLoaded = null;
217
218        try {
219            objToSave = java.util.Collections.EMPTY_MAP;
220            if (DEBUG)
221                System.out.println("Obj = " + objToSave);
222            objLoaded = dumpAndReload(objToSave);
223
224            // Has to have worked
225            boolean equals;
226            equals = objToSave.equals(objLoaded);
227            if (equals)
228                equals = ((Map) objLoaded).size() == 0;
229            assertTrue(MSG_TEST_FAILED + objToSave, equals);
230        } catch (IOException e) {
231            fail("IOException serializing " + objToSave + " : "
232                    + e.getMessage());
233        } catch (ClassNotFoundException e) {
234            fail("ClassNotFoundException reading Object type : "
235                    + e.getMessage());
236        } catch (Error err) {
237            System.out.println("Error when obj = " + objToSave);
238            // err.printStackTrace();
239            throw err;
240        }
241
242    }
243
244    @TestTargetNew(
245        level = TestLevel.COMPLETE,
246        notes = "Verifies serialization.",
247        method = "!Serialization",
248        args = {}
249    )
250    public void test_writeObject_BasicPermissionCollection() {
251        // Test for method void
252        // java.io.ObjectOutputStream.writeObject(java.security.BasicPermissionCollection)
253
254        Object objToSave = null;
255        Object objLoaded = null;
256
257        try {
258            objToSave = (new RuntimePermission("test"))
259                    .newPermissionCollection();
260            ((java.security.PermissionCollection) objToSave)
261                    .add(new RuntimePermission("test"));
262            if (DEBUG)
263                System.out.println("Obj = " + objToSave);
264            objLoaded = dumpAndReload(objToSave);
265
266            // Has to have worked
267            boolean equals;
268            Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
269                    .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
270                    .elements();
271
272            equals = true;
273            while (enum1.hasMoreElements() && equals) {
274                if (enum2.hasMoreElements())
275                    equals = enum1.nextElement().equals(enum2.nextElement());
276                else
277                    equals = false;
278            }
279
280            if (equals)
281                equals = !enum2.hasMoreElements();
282            assertTrue(MSG_TEST_FAILED + objToSave, equals);
283        } catch (IOException e) {
284            fail("IOException serializing " + objToSave + " : "
285                    + e.getMessage());
286        } catch (ClassNotFoundException e) {
287            fail("ClassNotFoundException reading Object type : "
288                    + e.getMessage());
289        } catch (Error err) {
290            System.out.println("Error when obj = " + objToSave);
291            // err.printStackTrace();
292            throw err;
293        }
294
295    }
296
297    @TestTargetNew(
298        level = TestLevel.COMPLETE,
299        notes = "Verifies serialization.",
300        method = "!Serialization",
301        args = {}
302    )
303    public void test_writeObject_UnresolvedPermission() {
304        // Test for method void
305        // java.io.ObjectOutputStream.writeObject(java.security.UnresolvedPermission)
306
307        Object objToSave = null;
308        Object objLoaded = null;
309
310        try {
311            objToSave = new java.security.UnresolvedPermission("type", "name",
312                    "actions", null);
313            if (DEBUG)
314                System.out.println("Obj = " + objToSave);
315            objLoaded = dumpAndReload(objToSave);
316
317            // Has to have worked
318            boolean equals;
319            equals = objToSave.toString().equals(objLoaded.toString());
320            assertTrue(MSG_TEST_FAILED + objToSave, equals);
321        } catch (IOException e) {
322            fail("Exception serializing " + objToSave + " : " + e.getMessage());
323        } catch (ClassNotFoundException e) {
324            fail("ClassNotFoundException reading Object type: "
325                    + e.getMessage());
326        } catch (Error err) {
327            System.out.println("Error when obj = " + objToSave);
328            // err.printStackTrace();
329            throw err;
330        }
331
332    }
333
334    @TestTargetNew(
335        level = TestLevel.COMPLETE,
336        notes = "Verifies serialization.",
337        method = "!Serialization",
338        args = {}
339    )
340    public void test_writeObject_Character() {
341        // Test for method void
342        // java.io.ObjectOutputStream.writeObject(java.lang.Character)
343
344        Object objToSave = null;
345        Object objLoaded = null;
346
347        try {
348            objToSave = new java.lang.Character('c');
349            if (DEBUG)
350                System.out.println("Obj = " + objToSave);
351            objLoaded = dumpAndReload(objToSave);
352
353            // Has to have worked
354            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
355        } catch (IOException e) {
356            fail("IOException serializing " + objToSave + " : "
357                    + e.getMessage());
358        } catch (ClassNotFoundException e) {
359            fail("ClassNotFoundException reading Object type : "
360                    + e.getMessage());
361        } catch (Error err) {
362            System.out.println("Error when obj = " + objToSave);
363            // err.printStackTrace();
364            throw err;
365        }
366
367    }
368
369    @TestTargetNew(
370        level = TestLevel.COMPLETE,
371        notes = "Verifies serialization.",
372        method = "!Serialization",
373        args = {}
374    )
375    public void test_writeObject_Collections_UnmodifiableCollection() {
376        // Test for method void
377        // java.io.ObjectOutputStream.writeObject(java.util.Collections.UnmodifiableCollection)
378
379        Object objToSave = null;
380        Object objLoaded = null;
381
382        try {
383            objToSave = java.util.Collections.unmodifiableCollection(SET);
384            if (DEBUG)
385                System.out.println("Obj = " + objToSave);
386            objLoaded = dumpAndReload(objToSave);
387
388            // Has to have worked
389            boolean equals;
390            equals = ((java.util.Collection) objToSave).size() == ((java.util.Collection) objLoaded)
391                    .size();
392            if (equals) {
393                java.util.Iterator iter1 = ((java.util.Collection) objToSave)
394                        .iterator(), iter2 = ((java.util.Collection) objLoaded)
395                        .iterator();
396                while (iter1.hasNext())
397                    equals = equals && iter1.next().equals(iter2.next());
398            }
399            assertTrue(MSG_TEST_FAILED + objToSave, equals);
400        } catch (IOException e) {
401            fail("IOException serializing " + objToSave + " : "
402                    + e.getMessage());
403        } catch (ClassNotFoundException e) {
404            fail("ClassNotFoundException reading Object type : "
405                    + e.getMessage());
406        } catch (Error err) {
407            System.out.println("Error when obj = " + objToSave);
408            // err.printStackTrace();
409            throw err;
410        }
411
412    }
413
414    @TestTargetNew(
415        level = TestLevel.COMPLETE,
416        notes = "Verifies serialization.",
417        method = "!Serialization",
418        args = {}
419    )
420    public void test_writeObject_Format() {
421        // Test for method void
422        // java.io.ObjectOutputStream.writeObject(java.text.Format)
423
424        Object objToSave = null;
425        Object objLoaded = null;
426
427        try {
428            objToSave = null;
429            objToSave = new java.text.Format() {
430                String save = "default";
431
432                public StringBuffer format(Object p1, StringBuffer p2,
433                        java.text.FieldPosition p3) {
434                    return new StringBuffer();
435                }
436
437                public Object parseObject(String p1, java.text.ParsePosition p2) {
438                    if (p1 != null)
439                        save = p1;
440                    return save;
441                }
442
443                public boolean equals(Object obj) {
444                    if (!(obj instanceof java.text.Format))
445                        return false;
446                    return save.equals(((java.text.Format) obj).parseObject(
447                            null, null));
448                }
449            };
450
451            ((java.text.Format) objToSave).parseObject("Test", null);
452            if (DEBUG)
453                System.out.println("Obj = " + objToSave);
454            objLoaded = dumpAndReload(objToSave);
455
456            // Has to have worked
457            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
458        } catch (IOException e) {
459            fail("IOException serializing " + objToSave + " : "
460                    + e.getMessage());
461        } catch (ClassNotFoundException e) {
462            fail("ClassNotFoundException reading Object type : "
463                    + e.getMessage());
464        } catch (Error err) {
465            System.out.println("Error when obj = " + objToSave);
466            // err.printStackTrace();
467            throw err;
468        }
469    }
470
471    @TestTargetNew(
472        level = TestLevel.COMPLETE,
473        notes = "Verifies serialization.",
474        method = "!Serialization",
475        args = {}
476    )
477    public void test_writeObject_BigDecimal() {
478        // Test for method void
479        // java.io.ObjectOutputStream.writeObject(java.math.BigDecimal)
480
481        Object objToSave = null;
482        Object objLoaded = null;
483
484        try {
485            objToSave = new java.math.BigDecimal("1.2345");
486            if (DEBUG)
487                System.out.println("Obj = " + objToSave);
488            objLoaded = dumpAndReload(objToSave);
489
490            // Has to have worked
491            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
492        } catch (IOException e) {
493            fail("Exception serializing " + objToSave + " : " + e.getMessage());
494        } catch (ClassNotFoundException e) {
495            fail("ClassNotFoundException reading Object type: "
496                    + e.getMessage());
497        } catch (Error err) {
498            System.out.println("Error when obj = " + objToSave);
499            // err.printStackTrace();
500            throw err;
501        }
502
503    }
504
505    @TestTargetNew(
506        level = TestLevel.COMPLETE,
507        notes = "Verifies serialization.",
508        method = "!Serialization",
509        args = {}
510    )
511    public void test_writeObject_UnresolvedPermissionCollection() {
512        // Test for method void
513        // java.io.ObjectOutputStream.writeObject(java.security.UnresolvedPermissionCollection)
514
515        Object objToSave = null;
516        Object objLoaded = null;
517
518        try {
519            objToSave = (new java.security.UnresolvedPermission("type", "name",
520                    "actions", null)).newPermissionCollection();
521            ((java.security.PermissionCollection) objToSave)
522                    .add(new java.security.UnresolvedPermission("type", "name",
523                            "actions", null));
524            if (DEBUG)
525                System.out.println("Obj = " + objToSave);
526            objLoaded = dumpAndReload(objToSave);
527
528            // Has to have worked
529            boolean equals;
530            Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
531                    .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
532                    .elements();
533
534            equals = true;
535            while (enum1.hasMoreElements() && equals) {
536                if (enum2.hasMoreElements())
537                    equals = enum1.nextElement().toString().equals(
538                            enum2.nextElement().toString());
539                else
540                    equals = false;
541            }
542
543            if (equals)
544                equals = !enum2.hasMoreElements();
545            assertTrue(MSG_TEST_FAILED + objToSave, equals);
546        } catch (IOException e) {
547            fail("IOException serializing " + objToSave + " : "
548                    + e.getMessage());
549        } catch (ClassNotFoundException e) {
550            fail("ClassNotFoundException reading Object type : "
551                    + e.getMessage());
552        } catch (Error err) {
553            System.out.println("Error when obj = " + objToSave);
554            // err.printStackTrace();
555            throw err;
556        }
557
558    }
559
560    @TestTargetNew(
561        level = TestLevel.COMPLETE,
562        notes = "Verifies serialization.",
563        method = "!Serialization",
564        args = {}
565    )
566    public void test_writeObject_SecureRandomSpi() {
567        // Test for method void
568        // java.io.ObjectOutputStream.writeObject(java.security.SecureRandomSpi)
569
570        Object objToSave = null;
571        Object objLoaded = null;
572
573        try {
574            objToSave = null;
575            objToSave = new java.security.SecureRandomSpi() {
576                protected byte[] engineGenerateSeed(int p1) {
577                    return new byte[0];
578                }
579
580                protected void engineNextBytes(byte[] p1) {
581                }
582
583                protected void engineSetSeed(byte[] p1) {
584                }
585
586                public boolean equals(Object obj) {
587                    return true;
588                }
589            };
590            if (DEBUG)
591                System.out.println("Obj = " + objToSave);
592            objLoaded = dumpAndReload(objToSave);
593
594            // Has to have worked
595            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
596        } catch (IOException e) {
597            fail("Exception serializing " + objToSave + " : " + e.getMessage());
598        } catch (ClassNotFoundException e) {
599            fail("ClassNotFoundException reading Object type: "
600                    + e.getMessage());
601        } catch (Error err) {
602            System.out.println("Error when obj = " + objToSave);
603            // err.printStackTrace();
604            throw err;
605        }
606    }
607
608    @TestTargetNew(
609        level = TestLevel.COMPLETE,
610        notes = "Verifies serialization.",
611        method = "!Serialization",
612        args = {}
613    )
614    public void test_writeObject_Short() {
615        // Test for method void
616        // java.io.ObjectOutputStream.writeObject(java.lang.Short)
617
618        Object objToSave = null;
619        Object objLoaded = null;
620
621        try {
622            objToSave = new java.lang.Short((short) 107);
623            if (DEBUG)
624                System.out.println("Obj = " + objToSave);
625            objLoaded = dumpAndReload(objToSave);
626
627            // Has to have worked
628            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
629        } catch (IOException e) {
630            fail("IOException serializing " + objToSave + " : "
631                    + e.getMessage());
632        } catch (ClassNotFoundException e) {
633            fail("ClassNotFoundException reading Object type : "
634                    + e.getMessage());
635        } catch (Error err) {
636            System.out.println("Error when obj = " + objToSave);
637            // err.printStackTrace();
638            throw err;
639        }
640
641    }
642
643    @TestTargetNew(
644        level = TestLevel.COMPLETE,
645        notes = "Verifies serialization.",
646        method = "!Serialization",
647        args = {}
648    )
649    public void test_writeObject_Byte() {
650        // Test for method void
651        // java.io.ObjectOutputStream.writeObject(java.lang.Byte)
652
653        Object objToSave = null;
654        Object objLoaded = null;
655
656        try {
657            objToSave = new java.lang.Byte((byte) 107);
658            if (DEBUG)
659                System.out.println("Obj = " + objToSave);
660            objLoaded = dumpAndReload(objToSave);
661
662            // Has to have worked
663            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
664        } catch (IOException e) {
665            fail("Exception serializing " + objToSave + " : " + e.getMessage());
666        } catch (ClassNotFoundException e) {
667            fail("ClassNotFoundException reading Object type: "
668                    + e.getMessage());
669        } catch (Error err) {
670            System.out.println("Error when obj = " + objToSave);
671            // err.printStackTrace();
672            throw err;
673        }
674
675    }
676
677    @TestTargetNew(
678        level = TestLevel.COMPLETE,
679        notes = "Verifies serialization.",
680        method = "!Serialization",
681        args = {}
682    )
683    public void test_writeObject_String_CaseInsensitiveComparator() {
684        // Test for method void
685        // java.io.ObjectOutputStream.writeObject(java.lang.String.CaseInsensitiveComparator)
686
687        Object objToSave = null;
688        Object objLoaded = null;
689
690        try {
691            objToSave = java.lang.String.CASE_INSENSITIVE_ORDER;
692            if (DEBUG)
693                System.out.println("Obj = " + objToSave);
694            objLoaded = dumpAndReload(objToSave);
695
696            // Has to have worked
697            boolean equals;
698            equals = ((Comparator) objToSave).compare("apple", "Banana") == ((Comparator) objLoaded)
699                    .compare("apple", "Banana");
700            assertTrue(MSG_TEST_FAILED + objToSave, equals);
701        } catch (IOException e) {
702            fail("IOException serializing " + objToSave + " : "
703                    + e.getMessage());
704        } catch (ClassNotFoundException e) {
705            fail("ClassNotFoundException reading Object type : "
706                    + e.getMessage());
707        } catch (Error err) {
708            System.out.println("Error when obj = " + objToSave);
709            // err.printStackTrace();
710            throw err;
711        }
712
713    }
714
715    @TestTargetNew(
716        level = TestLevel.COMPLETE,
717        notes = "Verifies serialization.",
718        method = "!Serialization",
719        args = {}
720    )
721    public void test_writeObject_Calendar() {
722        // Test for method void
723        // java.io.ObjectOutputStream.writeObject(java.util.Calendar)
724
725        Object objToSave = null;
726        Object objLoaded = null;
727
728        try {
729            objToSave = new java.util.Calendar(TimeZone.getTimeZone("EST"),
730                    Locale.CANADA) {
731                public void add(int p1, int p2) {
732                }
733
734                protected void computeFields() {
735                }
736
737                protected void computeTime() {
738                }
739
740                public int getGreatestMinimum(int p1) {
741                    return 0;
742                }
743
744                public int getLeastMaximum(int p1) {
745                    return 0;
746                }
747
748                public int getMaximum(int p1) {
749                    return 0;
750                }
751
752                public int getMinimum(int p1) {
753                    return 0;
754                }
755
756                public void roll(int p1, boolean p2) {
757                }
758            };
759            if (DEBUG)
760                System.out.println("Obj = " + objToSave);
761            objLoaded = dumpAndReload(objToSave);
762
763            // Has to have worked
764            assertTrue(MSG_TEST_FAILED + "Calendar", objToSave
765                    .equals(objLoaded));
766        } catch (IOException e) {
767            fail("Exception serializing " + objToSave + " : " + e.getMessage());
768        } catch (ClassNotFoundException e) {
769            fail("ClassNotFoundException reading Object type: "
770                    + e.getMessage());
771        } catch (Error err) {
772            System.out.println("Error when obj = " + objToSave);
773            // err.printStackTrace();
774            throw err;
775        }
776
777    }
778
779    @TestTargetNew(
780        level = TestLevel.COMPLETE,
781        notes = "Verifies serialization.",
782        method = "!Serialization",
783        args = {}
784    )
785    public void test_writeObject_ReflectPermission() {
786        // Test for method void
787        // java.io.ObjectOutputStream.writeObject(java.lang.reflect.ReflectPermission)
788
789        Object objToSave = null;
790        Object objLoaded = null;
791
792        try {
793            objToSave = new java.lang.reflect.ReflectPermission(
794                    "TestSerialization", "test");
795            if (DEBUG)
796                System.out.println("Obj = " + objToSave);
797            objLoaded = dumpAndReload(objToSave);
798
799            // Has to have worked
800            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
801        } catch (IOException e) {
802            fail("IOException serializing " + objToSave + " : "
803                    + e.getMessage());
804        } catch (ClassNotFoundException e) {
805            fail("ClassNotFoundException reading Object type : "
806                    + e.getMessage());
807        } catch (Error err) {
808            System.out.println("Error when obj = " + objToSave);
809            // err.printStackTrace();
810            throw err;
811        }
812
813    }
814
815    @TestTargetNew(
816        level = TestLevel.COMPLETE,
817        notes = "Verifies serialization.",
818        method = "!Serialization",
819        args = {}
820    )
821    public void test_writeObject_StringBuffer() {
822        // Test for method void
823        // java.io.ObjectOutputStream.writeObject(java.lang.StringBuffer)
824
825        Object objToSave = null;
826        Object objLoaded = null;
827
828        try {
829            objToSave = new java.lang.StringBuffer("This is a test.");
830            if (DEBUG)
831                System.out.println("Obj = " + objToSave);
832            objLoaded = dumpAndReload(objToSave);
833
834            // Has to have worked
835            boolean equals;
836            equals = ((java.lang.StringBuffer) objToSave).toString().equals(
837                    ((java.lang.StringBuffer) objLoaded).toString());
838            assertTrue(MSG_TEST_FAILED + objToSave, equals);
839        } catch (IOException e) {
840            fail("Exception serializing " + objToSave + " : " + e.getMessage());
841        } catch (ClassNotFoundException e) {
842            fail("ClassNotFoundException reading Object type: "
843                    + e.getMessage());
844        } catch (Error err) {
845            System.out.println("Error when obj = " + objToSave);
846            // err.printStackTrace();
847            throw err;
848        }
849
850    }
851
852    @TestTargetNew(
853        level = TestLevel.COMPLETE,
854        notes = "Verifies serialization.",
855        method = "!Serialization",
856        args = {}
857    )
858    public void test_writeObject_File() {
859        // Test for method void
860        // java.io.ObjectOutputStream.writeObject(java.io.File)
861
862        Object objToSave = null;
863        Object objLoaded = null;
864
865        try {
866            objToSave = new File("afile.txt");
867            if (DEBUG)
868                System.out.println("Obj = " + objToSave);
869            objLoaded = dumpAndReload(objToSave);
870
871            // Has to have worked
872            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
873        } catch (IOException e) {
874            fail("IOException serializing " + objToSave + " : "
875                    + e.getMessage());
876        } catch (ClassNotFoundException e) {
877            fail("ClassNotFoundException reading Object type : "
878                    + e.getMessage());
879        } catch (Error err) {
880            System.out.println("Error when obj = " + objToSave);
881            // err.printStackTrace();
882            throw err;
883        }
884
885    }
886
887    @TestTargetNew(
888        level = TestLevel.COMPLETE,
889        notes = "Verifies serialization.",
890        method = "!Serialization",
891        args = {}
892    )
893    public void test_writeObject_AllPermissionCollection() {
894        // Test for method void
895        // java.io.ObjectOutputStream.writeObject(java.security.AllPermissionCollection)
896
897        Object objToSave = null;
898        Object objLoaded = null;
899
900        try {
901            objToSave = (new java.security.AllPermission())
902                    .newPermissionCollection();
903            ((java.security.PermissionCollection) objToSave)
904                    .add(new java.security.AllPermission());
905            if (DEBUG)
906                System.out.println("Obj = " + objToSave);
907            objLoaded = dumpAndReload(objToSave);
908
909            // Has to have worked
910            boolean equals;
911            Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
912                    .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
913                    .elements();
914
915            equals = true;
916            while (enum1.hasMoreElements() && equals) {
917                if (enum2.hasMoreElements())
918                    equals = enum1.nextElement().equals(enum2.nextElement());
919                else
920                    equals = false;
921            }
922
923            if (equals)
924                equals = !enum2.hasMoreElements();
925            assertTrue(MSG_TEST_FAILED + objToSave, equals);
926        } catch (IOException e) {
927            fail("Exception serializing " + objToSave + " : " + e.getMessage());
928        } catch (ClassNotFoundException e) {
929            fail("ClassNotFoundException reading Object type: "
930                    + e.getMessage());
931        } catch (Error err) {
932            System.out.println("Error when obj = " + objToSave);
933            // err.printStackTrace();
934            throw err;
935        }
936
937    }
938
939    @TestTargetNew(
940        level = TestLevel.COMPLETE,
941        notes = "Verifies serialization.",
942        method = "!Serialization",
943        args = {}
944    )
945    public void test_writeObject_BitSet() {
946        // Test for method void
947        // java.io.ObjectOutputStream.writeObject(java.util.BitSet)
948
949        Object objToSave = null;
950        Object objLoaded = null;
951
952        try {
953            objToSave = new java.util.BitSet();
954            ((java.util.BitSet) objToSave).set(3);
955            ((java.util.BitSet) objToSave).set(5);
956            ((java.util.BitSet) objToSave).set(61, 89);
957            if (DEBUG)
958                System.out.println("Obj = " + objToSave);
959            objLoaded = dumpAndReload(objToSave);
960
961            // Has to have worked
962            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
963        } catch (IOException e) {
964            fail("IOException serializing " + objToSave + " : "
965                    + e.getMessage());
966        } catch (ClassNotFoundException e) {
967            fail("ClassNotFoundException reading Object type : "
968                    + e.getMessage());
969        } catch (Error err) {
970            System.out.println("Error when obj = " + objToSave);
971            // err.printStackTrace();
972            throw err;
973        }
974
975    }
976
977    @TestTargetNew(
978        level = TestLevel.COMPLETE,
979        notes = "Verifies serialization.",
980        method = "!Serialization",
981        args = {}
982    )
983    public void test_writeObject_DateFormat() {
984        // Test for method void
985        // java.io.ObjectOutputStream.writeObject(java.text.DateFormat)
986
987        Object objToSave = null;
988        Object objLoaded = null;
989
990        try {
991            objToSave = null;
992            objToSave = new java.text.DateFormat() {
993                // Thu Feb 01 01:01:01 EST 2001
994                java.util.Date save = new java.util.Date(981007261000L);
995
996                public StringBuffer format(Date p1, StringBuffer p2,
997                        java.text.FieldPosition p3) {
998                    if (p1 != null)
999                        save = p1;
1000                    return new StringBuffer(Long.toString(save.getTime()));
1001                }
1002
1003                public Date parse(String p1, java.text.ParsePosition p2) {
1004                    return save;
1005                }
1006
1007                public String toString() {
1008                    return save.toString();
1009                }
1010
1011                public boolean equals(Object obj) {
1012                    if (!(obj instanceof java.text.DateFormat))
1013                        return false;
1014                    return save.equals(((java.text.DateFormat) obj).parse(null,
1015                            null));
1016                }
1017            };
1018            if (DEBUG)
1019                System.out.println("Obj = " + objToSave);
1020            objLoaded = dumpAndReload(objToSave);
1021
1022            // Has to have worked
1023            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1024        } catch (IOException e) {
1025            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1026        } catch (ClassNotFoundException e) {
1027            fail("ClassNotFoundException reading Object type: "
1028                    + e.getMessage());
1029        } catch (Error err) {
1030            System.out.println("Error when obj = " + objToSave);
1031            // err.printStackTrace();
1032            throw err;
1033        }
1034
1035    }
1036
1037    @TestTargetNew(
1038        level = TestLevel.COMPLETE,
1039        notes = "Verifies serialization.",
1040        method = "!Serialization",
1041        args = {}
1042    )
1043    public void test_writeObject_Collections_CopiesList() {
1044        // Test for method void
1045        // java.io.ObjectOutputStream.writeObject(java.util.Collections.CopiesList)
1046
1047        Object objToSave = null;
1048        Object objLoaded = null;
1049
1050        try {
1051            objToSave = java.util.Collections.nCopies(2, new Integer(2));
1052            if (DEBUG)
1053                System.out.println("Obj = " + objToSave);
1054            objLoaded = dumpAndReload(objToSave);
1055
1056            // Has to have worked
1057            boolean equals;
1058            equals = ((List) objToSave).get(0)
1059                    .equals(((List) objLoaded).get(0));
1060            if (equals)
1061                equals = ((List) objToSave).get(1).equals(
1062                        ((List) objLoaded).get(1));
1063            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1064        } catch (IOException e) {
1065            fail("IOException serializing " + objToSave + " : "
1066                    + e.getMessage());
1067        } catch (ClassNotFoundException e) {
1068            fail("ClassNotFoundException reading Object type : "
1069                    + e.getMessage());
1070        } catch (Error err) {
1071            System.out.println("Error when obj = " + objToSave);
1072            // err.printStackTrace();
1073            throw err;
1074        }
1075
1076    }
1077
1078    @TestTargetNew(
1079        level = TestLevel.COMPLETE,
1080        notes = "Verifies serialization.",
1081        method = "!Serialization",
1082        args = {}
1083    )
1084    public void test_writeObject_SerializablePermission() {
1085        // Test for method void
1086        // java.io.ObjectOutputStream.writeObject(java.io.SerializablePermission)
1087
1088        Object objToSave = null;
1089        Object objLoaded = null;
1090
1091        try {
1092            objToSave = new java.io.SerializablePermission("TestSerialization",
1093                    "Test");
1094            if (DEBUG)
1095                System.out.println("Obj = " + objToSave);
1096            objLoaded = dumpAndReload(objToSave);
1097
1098            // Has to have worked
1099            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1100        } catch (IOException e) {
1101            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1102        } catch (ClassNotFoundException e) {
1103            fail("ClassNotFoundException reading Object type: "
1104                    + e.getMessage());
1105        } catch (Error err) {
1106            System.out.println("Error when obj = " + objToSave);
1107            // err.printStackTrace();
1108            throw err;
1109        }
1110
1111    }
1112
1113    @TestTargetNew(
1114        level = TestLevel.COMPLETE,
1115        notes = "Verifies serialization.",
1116        method = "!Serialization",
1117        args = {}
1118    )
1119    public void test_writeObject_Properties() {
1120        // Test for method void
1121        // java.io.ObjectOutputStream.writeObject(java.util.Properties)
1122
1123        Object objToSave = null;
1124        Object objLoaded = null;
1125
1126        try {
1127            objToSave = new java.util.Properties();
1128            ((java.util.Properties) objToSave).put("key1", "value1");
1129            ((java.util.Properties) objToSave).put("key2", "value2");
1130            if (DEBUG)
1131                System.out.println("Obj = " + objToSave);
1132            objLoaded = dumpAndReload(objToSave);
1133
1134            // Has to have worked
1135            boolean equals;
1136            Enumeration enum1 = ((java.util.Properties) objToSave).elements(), enum2 = ((java.util.Properties) objLoaded)
1137                    .elements();
1138
1139            equals = true;
1140            while (enum1.hasMoreElements() && equals) {
1141                if (enum2.hasMoreElements())
1142                    equals = enum1.nextElement().equals(enum2.nextElement());
1143                else
1144                    equals = false;
1145            }
1146
1147            if (equals)
1148                equals = !enum2.hasMoreElements();
1149            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1150        } catch (IOException e) {
1151            fail("IOException serializing " + objToSave + " : "
1152                    + e.getMessage());
1153        } catch (ClassNotFoundException e) {
1154            fail("ClassNotFoundException reading Object type : "
1155                    + e.getMessage());
1156        } catch (Error err) {
1157            System.out.println("Error when obj = " + objToSave);
1158            // err.printStackTrace();
1159            throw err;
1160        }
1161
1162    }
1163
1164    // TODO : requires working security implementation
1165    // public void test_writeObject_BasicPermission() {
1166    // // Test for method void
1167    // //
1168    // java.io.ObjectOutputStream.writeObject(tests.java.security.Test_BasicPermission.BasicPermissionSubclass)
1169    //
1170    // Object objToSave = null;
1171    // Object objLoaded = null;
1172    //
1173    // try {
1174    // objToSave = new
1175    // tests.java.security.Test_BasicPermission.BasicPermissionSubclass(
1176    // "TestSerialization");
1177    // if (DEBUG)
1178    // System.out.println("Obj = " + objToSave);
1179    // objLoaded = dumpAndReload(objToSave);
1180    //
1181    // // Has to have worked
1182    // assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1183    // } catch (IOException e) {
1184    // fail("Exception serializing " + objToSave + " : "
1185    // + e.getMessage());
1186    // } catch (ClassNotFoundException e) {
1187    // fail("ClassNotFoundException reading Object type : " + e.getMessage());
1188    // } catch (Error err) {
1189    // System.out.println("Error when obj = " + objToSave);
1190    // // err.printStackTrace();
1191    // throw err;
1192    // }
1193    //
1194    // }
1195
1196    @TestTargetNew(
1197        level = TestLevel.COMPLETE,
1198        notes = "Verifies serialization.",
1199        method = "!Serialization",
1200        args = {}
1201    )
1202    @BrokenTest("Needs investigation. Fails on RI and on Android with the same IOException.")
1203    public void test_writeObject_Collections_UnmodifiableMap_UnmodifiableEntrySet() {
1204        // Test for method void
1205        // java.io.ObjectOutputStream.writeObject(java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet)
1206
1207        Object objToSave = null;
1208        Object objLoaded = null;
1209
1210        try {
1211            objToSave = java.util.Collections.unmodifiableMap(MAP).entrySet();
1212            if (DEBUG)
1213                System.out.println("Obj = " + objToSave);
1214            objLoaded = dumpAndReload(objToSave);
1215
1216            // Has to have worked
1217            boolean equals;
1218            equals = ((java.util.Collection) objToSave).size() == ((java.util.Collection) objLoaded)
1219                    .size();
1220            if (equals) {
1221                java.util.Iterator iter1 = ((java.util.Collection) objToSave)
1222                        .iterator(), iter2 = ((java.util.Collection) objLoaded)
1223                        .iterator();
1224                while (iter1.hasNext())
1225                    equals = equals && iter1.next().equals(iter2.next());
1226            }
1227            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1228        } catch (IOException e) {
1229            fail("IOException serializing " + objToSave + " : "
1230                    + e.getMessage());
1231        } catch (ClassNotFoundException e) {
1232            fail("ClassNotFoundException reading Object type : "
1233                    + e.getMessage());
1234        } catch (Error err) {
1235            System.out.println("Error when obj = " + objToSave);
1236            // err.printStackTrace();
1237            throw err;
1238        }
1239
1240    }
1241
1242    @TestTargetNew(
1243        level = TestLevel.COMPLETE,
1244        notes = "Verifies serialization.",
1245        method = "!Serialization",
1246        args = {}
1247    )
1248    public void test_writeObject_NumberFormat() {
1249        // Test for method void
1250        // java.io.ObjectOutputStream.writeObject(java.text.NumberFormat)
1251
1252        Object objToSave = null;
1253        Object objLoaded = null;
1254
1255        try {
1256            objToSave = null;
1257            objToSave = new java.text.NumberFormat() {
1258                long save = 107;
1259
1260                public StringBuffer format(double p1, StringBuffer p2,
1261                        java.text.FieldPosition p3) {
1262                    return new StringBuffer();
1263                }
1264
1265                public StringBuffer format(long p1, StringBuffer p2,
1266                        java.text.FieldPosition p3) {
1267                    if (p1 != 0)
1268                        save = p1;
1269                    return new StringBuffer(Long.toString(save));
1270                }
1271
1272                public Number parse(String p1, java.text.ParsePosition p2) {
1273                    return new Long(save);
1274                }
1275
1276                public boolean equals(Object obj) {
1277                    if (!(obj instanceof java.text.NumberFormat))
1278                        return false;
1279                    return save == ((Long) ((java.text.NumberFormat) obj)
1280                            .parse(null, null)).longValue();
1281                }
1282            };
1283
1284            ((java.text.NumberFormat) objToSave).format(63L, null, null);
1285            if (DEBUG)
1286                System.out.println("Obj = " + objToSave);
1287            objLoaded = dumpAndReload(objToSave);
1288
1289            // Has to have worked
1290            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1291        } catch (IOException e) {
1292            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1293        } catch (ClassNotFoundException e) {
1294            fail("ClassNotFoundException reading Object type: "
1295                    + e.getMessage());
1296        } catch (Error err) {
1297            System.out.println("Error when obj = " + objToSave);
1298            // err.printStackTrace();
1299            throw err;
1300        }
1301
1302    }
1303
1304    @TestTargetNew(
1305        level = TestLevel.COMPLETE,
1306        notes = "Verifies serialization.",
1307        method = "!Serialization",
1308        args = {}
1309    )
1310    public void test_writeObject_TimeZone() {
1311        // Test for method void
1312        // java.io.ObjectOutputStream.writeObject(java.util.TimeZone)
1313
1314        Object objToSave = null;
1315        Object objLoaded = null;
1316
1317        try {
1318            objToSave = null;
1319            objToSave = new java.util.TimeZone() {
1320                int save = 0;
1321
1322                public int getOffset(int p1, int p2, int p3, int p4, int p5,
1323                        int p6) {
1324                    return 0;
1325                }
1326
1327                public int getRawOffset() {
1328                    return save;
1329                }
1330
1331                public boolean inDaylightTime(java.util.Date p1) {
1332                    return false;
1333                }
1334
1335                public void setRawOffset(int p1) {
1336                    save = p1;
1337                }
1338
1339                public boolean useDaylightTime() {
1340                    return false;
1341                }
1342
1343                public boolean equals(Object obj) {
1344                    if (obj instanceof TimeZone)
1345                        return save == ((TimeZone) obj).getRawOffset();
1346                    return false;
1347                }
1348            };
1349
1350            ((java.util.TimeZone) objToSave).setRawOffset(48);
1351            if (DEBUG)
1352                System.out.println("Obj = " + objToSave);
1353            objLoaded = dumpAndReload(objToSave);
1354
1355            // Has to have worked
1356            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1357        } catch (IOException e) {
1358            fail("IOException serializing " + objToSave + " : "
1359                    + e.getMessage());
1360        } catch (ClassNotFoundException e) {
1361            fail("ClassNotFoundException reading Object type : "
1362                    + e.getMessage());
1363        } catch (Error err) {
1364            System.out.println("Error when obj = " + objToSave);
1365            // err.printStackTrace();
1366            throw err;
1367        }
1368
1369    }
1370
1371    @TestTargetNew(
1372        level = TestLevel.COMPLETE,
1373        notes = "Verifies serialization.",
1374        method = "!Serialization",
1375        args = {}
1376    )
1377    public void test_writeObject_Double() {
1378        // Test for method void
1379        // java.io.ObjectOutputStream.writeObject(java.lang.Double)
1380
1381        Object objToSave = null;
1382        Object objLoaded = null;
1383
1384        try {
1385            objToSave = new java.lang.Double(1.23);
1386            if (DEBUG)
1387                System.out.println("Obj = " + objToSave);
1388            objLoaded = dumpAndReload(objToSave);
1389
1390            // Has to have worked
1391            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1392        } catch (IOException e) {
1393            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1394        } catch (ClassNotFoundException e) {
1395            fail("ClassNotFoundException reading Object type: "
1396                    + e.getMessage());
1397        } catch (Error err) {
1398            System.out.println("Error when obj = " + objToSave);
1399            // err.printStackTrace();
1400            throw err;
1401        }
1402
1403    }
1404
1405    @TestTargetNew(
1406        level = TestLevel.COMPLETE,
1407        notes = "Verifies serialization.",
1408        method = "!Serialization",
1409        args = {}
1410    )
1411    public void test_writeObject_Number() {
1412        // Test for method void
1413        // java.io.ObjectOutputStream.writeObject(java.lang.Number)
1414
1415        Object objToSave = null;
1416        Object objLoaded = null;
1417
1418        try {
1419            objToSave = null;
1420            objToSave = new Number() {
1421                int numCalls = 0;
1422
1423                public double doubleValue() {
1424                    return ++numCalls;
1425                }
1426
1427                public float floatValue() {
1428                    return ++numCalls;
1429                }
1430
1431                public int intValue() {
1432                    return numCalls;
1433                }
1434
1435                public long longValue() {
1436                    return ++numCalls;
1437                }
1438
1439                public boolean equals(Object obj) {
1440                    if (!(obj instanceof java.lang.Number))
1441                        return false;
1442                    return intValue() == ((Number) obj).intValue();
1443                }
1444            };
1445            ((java.lang.Number) objToSave).doubleValue();
1446            ((java.lang.Number) objToSave).floatValue();
1447            if (DEBUG)
1448                System.out.println("Obj = " + objToSave);
1449            objLoaded = dumpAndReload(objToSave);
1450
1451            // Has to have worked
1452            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1453        } catch (IOException e) {
1454            fail("IOException serializing " + objToSave + " : "
1455                    + e.getMessage());
1456        } catch (ClassNotFoundException e) {
1457            fail("ClassNotFoundException reading Object type : "
1458                    + e.getMessage());
1459        } catch (Error err) {
1460            System.out.println("Error when obj = " + objToSave);
1461            // err.printStackTrace();
1462            throw err;
1463        }
1464
1465    }
1466
1467    @TestTargetNew(
1468        level = TestLevel.COMPLETE,
1469        notes = "Verifies serialization.",
1470        method = "!Serialization",
1471        args = {}
1472    )
1473    public void test_writeObject_AllPermission() {
1474        // Test for method void
1475        // java.io.ObjectOutputStream.writeObject(java.security.AllPermission)
1476
1477        Object objToSave = null;
1478        Object objLoaded = null;
1479
1480        try {
1481            objToSave = new java.security.AllPermission();
1482            if (DEBUG)
1483                System.out.println("Obj = " + objToSave);
1484            objLoaded = dumpAndReload(objToSave);
1485
1486            // Has to have worked
1487            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1488        } catch (IOException e) {
1489            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1490        } catch (ClassNotFoundException e) {
1491            fail("ClassNotFoundException reading Object type: "
1492                    + e.getMessage());
1493        } catch (Error err) {
1494            System.out.println("Error when obj = " + objToSave);
1495            // err.printStackTrace();
1496            throw err;
1497        }
1498
1499    }
1500
1501    @TestTargetNew(
1502        level = TestLevel.COMPLETE,
1503        notes = "Verifies serialization.",
1504        method = "!Serialization",
1505        args = {}
1506    )
1507    public void test_writeObject_Collections_ReverseComparator() {
1508        // Test for method void
1509        // java.io.ObjectOutputStream.writeObject(java.util.Collections.ReverseComparator)
1510
1511        Object objToSave = null;
1512        Object objLoaded = null;
1513
1514        try {
1515            objToSave = java.util.Collections.reverseOrder();
1516            if (DEBUG)
1517                System.out.println("Obj = " + objToSave);
1518            objLoaded = dumpAndReload(objToSave);
1519
1520            // Has to have worked
1521            boolean equals;
1522            equals = ((Comparator) objToSave).compare("Hello", "Jello") == ((Comparator) objLoaded)
1523                    .compare("Hello", "Jello");
1524            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1525        } catch (IOException e) {
1526            fail("IOException serializing " + objToSave + " : "
1527                    + e.getMessage());
1528        } catch (ClassNotFoundException e) {
1529            fail("ClassNotFoundException reading Object type : "
1530                    + e.getMessage());
1531        } catch (Error err) {
1532            System.out.println("Error when obj = " + objToSave);
1533            // err.printStackTrace();
1534            throw err;
1535        }
1536
1537    }
1538
1539    @TestTargetNew(
1540        level = TestLevel.COMPLETE,
1541        notes = "Verifies serialization.",
1542        method = "!Serialization",
1543        args = {}
1544    )
1545    public void test_writeObject_DateFormatSymbols() {
1546        // Test for method void
1547        // java.io.ObjectOutputStream.writeObject(java.text.DateFormatSymbols)
1548
1549        Object objToSave = null;
1550        Object objLoaded = null;
1551
1552        try {
1553            objToSave = new java.text.DateFormatSymbols(Locale.CHINESE);
1554            ((java.text.DateFormatSymbols) objToSave)
1555                    .setZoneStrings(new String[][] { { "a", "b", "c", "d" },
1556                            { "e", "f", "g", "h" } });
1557            if (DEBUG)
1558                System.out.println("Obj = " + objToSave);
1559            objLoaded = dumpAndReload(objToSave);
1560
1561            // Has to have worked
1562            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1563        } catch (IOException e) {
1564            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1565        } catch (ClassNotFoundException e) {
1566            fail("ClassNotFoundException reading Object type: "
1567                    + e.getMessage());
1568        } catch (Error err) {
1569            System.out.println("Error when obj = " + objToSave);
1570            // err.printStackTrace();
1571            throw err;
1572        }
1573
1574    }
1575
1576    @TestTargetNew(
1577        level = TestLevel.COMPLETE,
1578        notes = "Verifies serialization.",
1579        method = "!Serialization",
1580        args = {}
1581    )
1582    public void test_writeObject_Collections_EmptyList() {
1583        // Test for method void
1584        // java.io.ObjectOutputStream.writeObject(java.util.Collections.EmptyList)
1585
1586        Object objToSave = null;
1587        Object objLoaded = null;
1588
1589        try {
1590            objToSave = java.util.Collections.EMPTY_LIST;
1591            if (DEBUG)
1592                System.out.println("Obj = " + objToSave);
1593            objLoaded = dumpAndReload(objToSave);
1594
1595            // Has to have worked
1596            boolean equals;
1597            equals = objToSave.equals(objLoaded);
1598            if (equals)
1599                equals = ((List) objLoaded).size() == 0;
1600            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1601        } catch (IOException e) {
1602            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1603        } catch (ClassNotFoundException e) {
1604            fail("ClassNotFoundException reading Object type: "
1605                    + e.getMessage());
1606        } catch (Error err) {
1607            System.out.println("Error when obj = " + objToSave);
1608            // err.printStackTrace();
1609            throw err;
1610        }
1611
1612    }
1613
1614    @TestTargetNew(
1615        level = TestLevel.COMPLETE,
1616        notes = "Verifies serialization.",
1617        method = "!Serialization",
1618        args = {}
1619    )
1620    public void test_writeObject_Boolean() {
1621        // Test for method void
1622        // java.io.ObjectOutputStream.writeObject(java.lang.Boolean)
1623
1624        Object objToSave = null;
1625        Object objLoaded = null;
1626
1627        try {
1628            objToSave = new java.lang.Boolean(true);
1629            if (DEBUG)
1630                System.out.println("Obj = " + objToSave);
1631            objLoaded = dumpAndReload(objToSave);
1632
1633            // Has to have worked
1634            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1635        } catch (IOException e) {
1636            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1637        } catch (ClassNotFoundException e) {
1638            fail("ClassNotFoundException reading Object type: "
1639                    + e.getMessage());
1640        } catch (Error err) {
1641            System.out.println("Error when obj = " + objToSave);
1642            // err.printStackTrace();
1643            throw err;
1644        }
1645
1646    }
1647
1648    @TestTargetNew(
1649        level = TestLevel.COMPLETE,
1650        notes = "Verifies serialization.",
1651        method = "!Serialization",
1652        args = {}
1653    )
1654    public void test_writeObject_Collections_SingletonSet() {
1655        // Test for method void
1656        // java.io.ObjectOutputStream.writeObject(java.util.Collections.SingletonSet)
1657
1658        Object objToSave = null;
1659        Object objLoaded = null;
1660
1661        try {
1662            objToSave = java.util.Collections.singleton(new Byte((byte) 107));
1663            if (DEBUG)
1664                System.out.println("Obj = " + objToSave);
1665            objLoaded = dumpAndReload(objToSave);
1666
1667            // Has to have worked
1668            boolean equals;
1669            java.util.Iterator iter = ((Set) objLoaded).iterator();
1670            equals = iter.hasNext();
1671            if (equals)
1672                equals = iter.next().equals(new Byte((byte) 107));
1673            if (equals)
1674                equals = !iter.hasNext();
1675            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1676        } catch (IOException e) {
1677            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1678        } catch (ClassNotFoundException e) {
1679            fail("ClassNotFoundException reading Object type: "
1680                    + e.getMessage());
1681        } catch (Error err) {
1682            System.out.println("Error when obj = " + objToSave);
1683            // err.printStackTrace();
1684            throw err;
1685        }
1686
1687    }
1688
1689    @TestTargetNew(
1690        level = TestLevel.COMPLETE,
1691        notes = "Verifies serialization.",
1692        method = "!Serialization",
1693        args = {}
1694    )
1695    public void test_writeObject_Collections_SingletonList() {
1696        // Test for method void
1697        // java.io.ObjectOutputStream.writeObject(java.util.Collections.SingletonSet)
1698
1699        Object objToSave = null;
1700        Object objLoaded = null;
1701
1702        try {
1703            objToSave = java.util.Collections
1704                    .singletonList(new Byte((byte) 107));
1705            if (DEBUG)
1706                System.out.println("Obj = " + objToSave);
1707            objLoaded = dumpAndReload(objToSave);
1708
1709            // Has to have worked
1710            boolean equals;
1711            java.util.Iterator iter = ((List) objLoaded).iterator();
1712            equals = objLoaded.equals(objToSave) && iter.hasNext()
1713                    && iter.next().equals(new Byte((byte) 107))
1714                    && !iter.hasNext();
1715            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1716        } catch (IOException e) {
1717            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1718        } catch (ClassNotFoundException e) {
1719            fail("ClassNotFoundException reading Object type: "
1720                    + e.getMessage());
1721        } catch (Error err) {
1722            System.out.println("Error when obj = " + objToSave);
1723            // err.printStackTrace();
1724            throw err;
1725        }
1726
1727    }
1728
1729    @TestTargetNew(
1730        level = TestLevel.COMPLETE,
1731        notes = "Verifies serialization.",
1732        method = "!Serialization",
1733        args = {}
1734    )
1735    public void test_writeObject_Collections_SingletonMap() {
1736        // Test for method void
1737        // java.io.ObjectOutputStream.writeObject(java.util.Collections.SingletonSet)
1738
1739        Object objToSave = null;
1740        Object objLoaded = null;
1741
1742        try {
1743            objToSave = java.util.Collections.singletonMap("key", new Byte(
1744                    (byte) 107));
1745            if (DEBUG)
1746                System.out.println("Obj = " + objToSave);
1747            objLoaded = dumpAndReload(objToSave);
1748
1749            // Has to have worked
1750            boolean equals;
1751            java.util.Iterator iter = ((Map) objLoaded).entrySet().iterator();
1752            equals = objLoaded.equals(objToSave) && iter.hasNext();
1753            Map.Entry entry = (Map.Entry) iter.next();
1754            equals = equals && entry.getKey().equals("key")
1755                    && entry.getValue().equals(new Byte((byte) 107))
1756                    && !iter.hasNext();
1757            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1758        } catch (IOException e) {
1759            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1760        } catch (ClassNotFoundException e) {
1761            fail("ClassNotFoundException reading Object type: "
1762                    + e.getMessage());
1763        } catch (Error err) {
1764            System.out.println("Error when obj = " + objToSave);
1765            // err.printStackTrace();
1766            throw err;
1767        }
1768
1769    }
1770
1771    @TestTargetNew(
1772        level = TestLevel.COMPLETE,
1773        notes = "Verifies serialization.",
1774        method = "!Serialization",
1775        args = {}
1776    )
1777    public void test_writeObject_FilePermission_FilePermissionCollection() {
1778        // Test for method void
1779        // java.io.ObjectOutputStream.writeObject(java.io.FilePermission.FilePermissionCollection)
1780
1781        Object objToSave = null;
1782        Object objLoaded = null;
1783
1784        try {
1785            objToSave = (new java.io.FilePermission("<<ALL FILES>>", "read"))
1786                    .newPermissionCollection();
1787            ((java.security.PermissionCollection) objToSave)
1788                    .add(new FilePermission("<<ALL FILES>>", "read"));
1789            ((java.security.PermissionCollection) objToSave)
1790                    .add(new FilePermission("d:\\", "read"));
1791            if (DEBUG)
1792                System.out.println("Obj = " + objToSave);
1793            objLoaded = dumpAndReload(objToSave);
1794
1795            // Has to have worked
1796            boolean equals;
1797            java.util.Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
1798                    .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
1799                    .elements();
1800
1801            equals = true;
1802            while (enum1.hasMoreElements() && equals) {
1803                if (enum2.hasMoreElements())
1804                    equals = enum1.nextElement().equals(enum2.nextElement());
1805                else
1806                    equals = false;
1807            }
1808
1809            if (equals)
1810                equals = !enum2.hasMoreElements();
1811            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1812        } catch (IOException e) {
1813            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1814        } catch (ClassNotFoundException e) {
1815            fail("ClassNotFoundException reading Object type: "
1816                    + e.getMessage());
1817        } catch (Error err) {
1818            System.out.println("Error when obj = " + objToSave);
1819            // err.printStackTrace();
1820            throw err;
1821        }
1822
1823    }
1824
1825    @TestTargetNew(
1826        level = TestLevel.COMPLETE,
1827        notes = "Verifies serialization.",
1828        method = "!Serialization",
1829        args = {}
1830    )
1831    public void test_writeObject_SecureRandom() {
1832        // Test for method void
1833        // java.io.ObjectOutputStream.writeObject(java.security.SecureRandom)
1834
1835        Object objToSave = null;
1836        Object objLoaded = null;
1837
1838        try {
1839            objToSave = new java.security.SecureRandom();
1840            if (DEBUG)
1841                System.out.println("Obj = " + objToSave);
1842            objLoaded = dumpAndReload(objToSave);
1843
1844            // Has to have worked
1845            boolean equals;
1846            equals = true; // assume fine because of the nature of the class,
1847            // it is difficult to determine if they are the same
1848            assertTrue(MSG_TEST_FAILED + objToSave, equals);
1849        } catch (IOException e) {
1850            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1851        } catch (ClassNotFoundException e) {
1852            fail("ClassNotFoundException reading Object type: "
1853                    + e.getMessage());
1854        } catch (Error err) {
1855            System.out.println("Error when obj = " + objToSave);
1856            // err.printStackTrace();
1857            throw err;
1858        }
1859
1860    }
1861
1862    @TestTargetNew(
1863        level = TestLevel.COMPLETE,
1864        notes = "Verifies serialization.",
1865        method = "!Serialization",
1866        args = {}
1867    )
1868    public void test_writeObject_FilePermission() {
1869        // Test for method void
1870        // java.io.ObjectOutputStream.writeObject(java.io.FilePermission)
1871
1872        Object objToSave = null;
1873        Object objLoaded = null;
1874
1875        try {
1876            objToSave = new java.io.FilePermission("<<ALL FILES>>", "read");
1877            if (DEBUG)
1878                System.out.println("Obj = " + objToSave);
1879            objLoaded = dumpAndReload(objToSave);
1880
1881            // Has to have worked
1882            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1883        } catch (IOException e) {
1884            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1885        } catch (ClassNotFoundException e) {
1886            fail("ClassNotFoundException reading Object type: "
1887                    + e.getMessage());
1888        } catch (Error err) {
1889            System.out.println("Error when obj = " + objToSave);
1890            // err.printStackTrace();
1891            throw err;
1892        }
1893
1894    }
1895
1896    @TestTargetNew(
1897        level = TestLevel.COMPLETE,
1898        notes = "Verifies serialization.",
1899        method = "!Serialization",
1900        args = {}
1901    )
1902    public void test_writeObject_InetAddress() {
1903        // Test for method void
1904        // java.io.ObjectOutputStream.writeObject(java.net.InetAddress)
1905
1906        Object objToSave = null;
1907        Object objLoaded = null;
1908
1909        try {
1910            objToSave = java.net.InetAddress
1911                    .getByName(Support_Configuration.InetTestIP);
1912            if (DEBUG)
1913                System.out.println("Obj = " + objToSave);
1914            objLoaded = dumpAndReload(objToSave);
1915
1916            // Has to have worked
1917            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1918        } catch (IOException e) {
1919            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1920        } catch (ClassNotFoundException e) {
1921            fail("ClassNotFoundException reading Object type: "
1922                    + e.getMessage());
1923        } catch (Error err) {
1924            System.out.println("Error when obj = " + objToSave);
1925            // err.printStackTrace();
1926            throw err;
1927        }
1928
1929    }
1930
1931    @TestTargetNew(
1932        level = TestLevel.COMPLETE,
1933        notes = "Verifies serialization.",
1934        method = "!Serialization",
1935        args = {}
1936    )
1937    public void test_writeObject_Inet6Address() {
1938        // Test for method void
1939        // java.io.ObjectOutputStream.writeObject(java.net.Inet6Address)
1940
1941        Object objToSave = null;
1942        Object objLoaded = null;
1943
1944        try {
1945            objToSave = java.net.Inet6Address
1946                    .getByName(Support_Configuration.InetTestIP6);
1947            if (DEBUG)
1948                System.out.println("Obj = " + objToSave);
1949            objLoaded = dumpAndReload(objToSave);
1950
1951            // Has to have worked
1952            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1953
1954        } catch (IOException e) {
1955            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1956        } catch (ClassNotFoundException e) {
1957            fail("ClassNotFoundException reading Object type: "
1958                    + e.getMessage());
1959        } catch (Error err) {
1960            System.out.println("Error when obj = " + objToSave);
1961            // err.printStackTrace();
1962            throw err;
1963        }
1964
1965    }
1966
1967    @TestTargetNew(
1968        level = TestLevel.COMPLETE,
1969        notes = "Verifies serialization.",
1970        method = "!Serialization",
1971        args = {}
1972    )
1973    public void test_writeObject_RuntimePermission() {
1974        // Test for method void
1975        // java.io.ObjectOutputStream.writeObject(java.lang.RuntimePermission)
1976
1977        Object objToSave = null;
1978        Object objLoaded = null;
1979
1980        try {
1981            objToSave = new java.lang.RuntimePermission("TestSerialization",
1982                    "Test");
1983            if (DEBUG)
1984                System.out.println("Obj = " + objToSave);
1985            objLoaded = dumpAndReload(objToSave);
1986
1987            // Has to have worked
1988            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
1989        } catch (IOException e) {
1990            fail("Exception serializing " + objToSave + " : " + e.getMessage());
1991        } catch (ClassNotFoundException e) {
1992            fail("ClassNotFoundException reading Object type: "
1993                    + e.getMessage());
1994        } catch (Error err) {
1995            System.out.println("Error when obj = " + objToSave);
1996            // err.printStackTrace();
1997            throw err;
1998        }
1999
2000    }
2001
2002    @TestTargetNew(
2003        level = TestLevel.COMPLETE,
2004        notes = "Verifies serialization.",
2005        method = "!Serialization",
2006        args = {}
2007    )
2008    public void test_writeObject_Permissions() {
2009        // Test for method void
2010        // java.io.ObjectOutputStream.writeObject(java.security.Permissions)
2011
2012        Object objToSave = null;
2013        Object objLoaded = null;
2014
2015        try {
2016            objToSave = new java.security.Permissions();
2017            ((java.security.Permissions) objToSave).add(new AllPermission());
2018            if (DEBUG)
2019                System.out.println("Obj = " + objToSave);
2020            objLoaded = dumpAndReload(objToSave);
2021
2022            // Has to have worked
2023            boolean equals;
2024            Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
2025                    .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
2026                    .elements();
2027            java.util.Vector vec1 = new java.util.Vector(), vec2 = new java.util.Vector();
2028
2029            while (enum1.hasMoreElements())
2030                vec1.add(enum1.nextElement());
2031            while (enum2.hasMoreElements())
2032                vec2.add(enum2.nextElement());
2033
2034            equals = vec1.size() == vec2.size();
2035            if (equals) {
2036                int length = vec1.size();
2037                Object[] perms1 = new Object[length], perms2 = new Object[length];
2038                for (int i = 0; i < length; ++i) {
2039                    perms1[i] = vec1.elementAt(i);
2040                    perms2[i] = vec2.elementAt(i);
2041                }
2042
2043                Comparator comparator = new Comparator() {
2044                    public int compare(Object o1, Object o2) {
2045                        return o1.toString().compareTo(o2.toString());
2046                    }
2047
2048                    public boolean equals(Object o1, Object o2) {
2049                        return o1.toString().equals(o2.toString());
2050                    }
2051                };
2052
2053                java.util.Arrays.sort(perms1, comparator);
2054                java.util.Arrays.sort(perms2, comparator);
2055
2056                for (int i = 0; i < length && equals; ++i)
2057                    equals = perms1[i].equals(perms2[i]);
2058            }
2059
2060            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2061        } catch (IOException e) {
2062            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2063        } catch (ClassNotFoundException e) {
2064            fail("ClassNotFoundException reading Object type: "
2065                    + e.getMessage());
2066        } catch (Error err) {
2067            System.out.println("Error when obj = " + objToSave);
2068            // err.printStackTrace();
2069            throw err;
2070        }
2071
2072    }
2073
2074    @TestTargetNew(
2075        level = TestLevel.COMPLETE,
2076        notes = "Verifies serialization.",
2077        method = "!Serialization",
2078        args = {}
2079    )
2080    public void test_writeObject_Date() {
2081        // Test for method void
2082        // java.io.ObjectOutputStream.writeObject(java.util.Date)
2083
2084        Object objToSave = null;
2085        Object objLoaded = null;
2086
2087        try {
2088            // Thu Feb 01 01:01:01 EST 2001
2089            objToSave = new java.util.Date(981007261000L);
2090            if (DEBUG)
2091                System.out.println("Obj = " + objToSave);
2092            objLoaded = dumpAndReload(objToSave);
2093
2094            // Has to have worked
2095            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2096        } catch (IOException e) {
2097            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2098        } catch (ClassNotFoundException e) {
2099            fail("ClassNotFoundException reading Object type: "
2100                    + e.getMessage());
2101        } catch (Error err) {
2102            System.out.println("Error when obj = " + objToSave);
2103            // err.printStackTrace();
2104            throw err;
2105        }
2106
2107    }
2108
2109    @TestTargetNew(
2110        level = TestLevel.COMPLETE,
2111        notes = "Verifies serialization.",
2112        method = "!Serialization",
2113        args = {}
2114    )
2115    public void test_writeObject_Float() {
2116        // Test for method void
2117        // java.io.ObjectOutputStream.writeObject(java.lang.Float)
2118
2119        Object objToSave = null;
2120        Object objLoaded = null;
2121
2122        try {
2123            objToSave = new java.lang.Float(1.23f);
2124            if (DEBUG)
2125                System.out.println("Obj = " + objToSave);
2126            objLoaded = dumpAndReload(objToSave);
2127
2128            // Has to have worked
2129            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2130        } catch (IOException e) {
2131            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2132        } catch (ClassNotFoundException e) {
2133            fail("ClassNotFoundException reading Object type: "
2134                    + e.getMessage());
2135        } catch (Error err) {
2136            System.out.println("Error when obj = " + objToSave);
2137            // err.printStackTrace();
2138            throw err;
2139        }
2140
2141    }
2142
2143    @TestTargetNew(
2144        level = TestLevel.COMPLETE,
2145        notes = "Verifies serialization.",
2146        method = "!Serialization",
2147        args = {}
2148    )
2149    public void test_writeObject_SecurityPermission() {
2150        // Test for method void
2151        // java.io.ObjectOutputStream.writeObject(java.security.SecurityPermission)
2152
2153        Object objToSave = null;
2154        Object objLoaded = null;
2155
2156        try {
2157            objToSave = new java.security.SecurityPermission(
2158                    "TestSerialization", "Test");
2159            if (DEBUG)
2160                System.out.println("Obj = " + objToSave);
2161            objLoaded = dumpAndReload(objToSave);
2162
2163            // Has to have worked
2164            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2165        } catch (IOException e) {
2166            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2167        } catch (ClassNotFoundException e) {
2168            fail("ClassNotFoundException reading Object type: "
2169                    + e.getMessage());
2170        } catch (Error err) {
2171            System.out.println("Error when obj = " + objToSave);
2172            // err.printStackTrace();
2173            throw err;
2174        }
2175
2176    }
2177
2178    @TestTargetNew(
2179        level = TestLevel.COMPLETE,
2180        notes = "Verifies serialization.",
2181        method = "!Serialization",
2182        args = {}
2183    )
2184    public void test_writeObject_SocketPermission_SocketPermissionCollection() {
2185        // Test for method void
2186        // java.io.ObjectOutputStream.writeObject(java.net.SocketPermission.SocketPermissionCollection)
2187
2188        Object objToSave = null;
2189        Object objLoaded = null;
2190
2191        try {
2192            objToSave = (new java.net.SocketPermission("www.yahoo.com",
2193                    "connect")).newPermissionCollection();
2194            ((java.security.PermissionCollection) objToSave)
2195                    .add(new java.net.SocketPermission("www.yahoo.com",
2196                            "connect"));
2197            if (DEBUG)
2198                System.out.println("Obj = " + objToSave);
2199            objLoaded = dumpAndReload(objToSave);
2200
2201            // Has to have worked
2202            boolean equals;
2203            Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
2204                    .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
2205                    .elements();
2206
2207            equals = true;
2208            while (enum1.hasMoreElements() && equals) {
2209                if (enum2.hasMoreElements())
2210                    equals = enum1.nextElement().equals(enum2.nextElement());
2211                else
2212                    equals = false;
2213            }
2214
2215            if (equals)
2216                equals = !enum2.hasMoreElements();
2217            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2218        } catch (IOException e) {
2219            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2220        } catch (ClassNotFoundException e) {
2221            fail("ClassNotFoundException reading Object type: "
2222                    + e.getMessage());
2223        } catch (Error err) {
2224            System.out.println("Error when obj = " + objToSave);
2225            // err.printStackTrace();
2226            throw err;
2227        }
2228
2229    }
2230
2231    @TestTargetNew(
2232        level = TestLevel.COMPLETE,
2233        notes = "Verifies serialization.",
2234        method = "!Serialization",
2235        args = {}
2236    )
2237    public void test_writeObject_Stack() {
2238        // Test for method void
2239        // java.io.ObjectOutputStream.writeObject(java.util.Stack)
2240
2241        Object objToSave = null;
2242        Object objLoaded = null;
2243
2244        try {
2245            objToSave = new java.util.Stack();
2246            ((java.util.Stack) objToSave).push("String 1");
2247            ((java.util.Stack) objToSave).push("String 2");
2248            if (DEBUG)
2249                System.out.println("Obj = " + objToSave);
2250            objLoaded = dumpAndReload(objToSave);
2251
2252            // Has to have worked
2253            boolean equals;
2254            equals = true;
2255            while (!((java.util.Stack) objToSave).empty() && equals) {
2256                if (!((java.util.Stack) objLoaded).empty())
2257                    equals = ((java.util.Stack) objToSave).pop().equals(
2258                            ((java.util.Stack) objLoaded).pop());
2259                else
2260                    equals = false;
2261            }
2262
2263            if (equals)
2264                equals = ((java.util.Stack) objLoaded).empty();
2265            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2266        } catch (IOException e) {
2267            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2268        } catch (ClassNotFoundException e) {
2269            fail("ClassNotFoundException reading Object type: "
2270                    + e.getMessage());
2271        } catch (Error err) {
2272            System.out.println("Error when obj = " + objToSave);
2273            // err.printStackTrace();
2274            throw err;
2275        }
2276
2277    }
2278
2279    @TestTargetNew(
2280        level = TestLevel.COMPLETE,
2281        notes = "Verifies serialization.",
2282        method = "!Serialization",
2283        args = {}
2284    )
2285    public void test_writeObject_DecimalFormatSymbols() {
2286        // Test for method void
2287        // java.io.ObjectOutputStream.writeObject(java.text.DecimalFormatSymbols)
2288
2289        Object objToSave = null;
2290        Object objLoaded = null;
2291
2292        try {
2293            objToSave = new java.text.DecimalFormatSymbols(Locale.CHINESE);
2294            if (DEBUG)
2295                System.out.println("Obj = " + objToSave);
2296            objLoaded = dumpAndReload(objToSave);
2297
2298            // Has to have worked
2299            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2300        } catch (IOException e) {
2301            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2302        } catch (ClassNotFoundException e) {
2303            fail("ClassNotFoundException reading Object type: "
2304                    + e.getMessage());
2305        } catch (Error err) {
2306            System.out.println("Error when obj = " + objToSave);
2307            // err.printStackTrace();
2308            throw err;
2309        }
2310
2311    }
2312
2313    @TestTargetNew(
2314        level = TestLevel.COMPLETE,
2315        notes = "Verifies serialization.",
2316        method = "!Serialization",
2317        args = {}
2318    )
2319    public void test_writeObject_NetPermission() {
2320        // Test for method void
2321        // java.io.ObjectOutputStream.writeObject(java.net.NetPermission)
2322
2323        Object objToSave = null;
2324        Object objLoaded = null;
2325
2326        try {
2327            objToSave = new java.net.NetPermission("TestSerialization", "Test");
2328            if (DEBUG)
2329                System.out.println("Obj = " + objToSave);
2330            objLoaded = dumpAndReload(objToSave);
2331
2332            // Has to have worked
2333            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2334        } catch (IOException e) {
2335            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2336        } catch (ClassNotFoundException e) {
2337            fail("ClassNotFoundException reading Object type: "
2338                    + e.getMessage());
2339        } catch (Error err) {
2340            System.out.println("Error when obj = " + objToSave);
2341            // err.printStackTrace();
2342            throw err;
2343        }
2344    }
2345
2346    @TestTargetNew(
2347        level = TestLevel.COMPLETE,
2348        notes = "Verifies serialization.",
2349        method = "!Serialization",
2350        args = {}
2351    )
2352    public void test_writeObject_AttributedCharacterIterator_Attribute() {
2353        // Test for method void
2354        // java.io.ObjectOutputStream.writeObject(java.text.AttributedCharacterIterator.Attribute)
2355
2356        Object objToSave = null;
2357        Object objLoaded = null;
2358
2359        try {
2360            objToSave = java.text.AttributedCharacterIterator.Attribute.LANGUAGE;
2361            if (DEBUG)
2362                System.out.println("Obj = " + objToSave);
2363            objLoaded = dumpAndReload(objToSave);
2364
2365            // Has to have worked
2366            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2367        } catch (IOException e) {
2368            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2369        } catch (ClassNotFoundException e) {
2370            fail("ClassNotFoundException reading Object type: "
2371                    + e.getMessage());
2372        } catch (Error err) {
2373            System.out.println("Error when obj = " + objToSave);
2374            // err.printStackTrace();
2375            throw err;
2376        }
2377    }
2378
2379    @TestTargetNew(
2380        level = TestLevel.COMPLETE,
2381        notes = "Verifies serialization.",
2382        method = "!Serialization",
2383        args = {}
2384    )
2385    public void test_writeObject_Long() {
2386        // Test for method void
2387        // java.io.ObjectOutputStream.writeObject(java.lang.Long)
2388
2389        Object objToSave = null;
2390        Object objLoaded = null;
2391
2392        try {
2393            objToSave = new java.lang.Long(107L);
2394            if (DEBUG)
2395                System.out.println("Obj = " + objToSave);
2396            objLoaded = dumpAndReload(objToSave);
2397
2398            // Has to have worked
2399            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2400        } catch (IOException e) {
2401            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2402        } catch (ClassNotFoundException e) {
2403            fail("ClassNotFoundException reading Object type: "
2404                    + e.getMessage());
2405        } catch (Error err) {
2406            System.out.println("Error when obj = " + objToSave);
2407            // err.printStackTrace();
2408            throw err;
2409        }
2410
2411    }
2412
2413    @TestTargetNew(
2414        level = TestLevel.COMPLETE,
2415        notes = "Verifies serialization.",
2416        method = "!Serialization",
2417        args = {}
2418    )
2419    public void test_writeObject_CodeSource() {
2420        // Test for method void
2421        // java.io.ObjectOutputStream.writeObject(java.security.CodeSource)
2422
2423        Object objToSave = null;
2424        Object objLoaded = null;
2425
2426        try {
2427            objToSave = null;
2428            try {
2429                objToSave = new java.security.CodeSource(new java.net.URL(
2430                        "http://localhost/a.txt"),
2431                        (Certificate[])null);
2432            } catch (Exception e) {
2433                fail("Exception creating object : " + e.getMessage());
2434            }
2435            if (DEBUG)
2436                System.out.println("Obj = " + objToSave);
2437            objLoaded = dumpAndReload(objToSave);
2438
2439            // Has to have worked
2440            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2441        } catch (IOException e) {
2442            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2443        } catch (ClassNotFoundException e) {
2444            fail("ClassNotFoundException reading Object type: "
2445                    + e.getMessage());
2446        } catch (Error err) {
2447            System.out.println("Error when obj = " + objToSave);
2448            // err.printStackTrace();
2449            throw err;
2450        }
2451
2452    }
2453
2454    @TestTargetNew(
2455        level = TestLevel.COMPLETE,
2456        notes = "Verifies serialization.",
2457        method = "!Serialization",
2458        args = {}
2459    )
2460    public void test_writeObject_Collections_SynchronizedCollection() {
2461        // Test for method void
2462        // java.io.ObjectOutputStream.writeObject(java.util.Collections.SynchronizedCollection)
2463
2464        Object objToSave = null;
2465        Object objLoaded = null;
2466
2467        try {
2468            objToSave = java.util.Collections.synchronizedCollection(SET);
2469            if (DEBUG)
2470                System.out.println("Obj = " + objToSave);
2471            objLoaded = dumpAndReload(objToSave);
2472
2473            // Has to have worked
2474            boolean equals;
2475            equals = ((java.util.Collection) objToSave).size() == ((java.util.Collection) objLoaded)
2476                    .size();
2477            if (equals) {
2478                java.util.Iterator iter1 = ((java.util.Collection) objToSave)
2479                        .iterator(), iter2 = ((java.util.Collection) objLoaded)
2480                        .iterator();
2481                while (iter1.hasNext())
2482                    equals = equals && iter1.next().equals(iter2.next());
2483            }
2484            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2485        } catch (IOException e) {
2486            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2487        } catch (ClassNotFoundException e) {
2488            fail("ClassNotFoundException reading Object type: "
2489                    + e.getMessage());
2490        } catch (Error err) {
2491            System.out.println("Error when obj = " + objToSave);
2492            // err.printStackTrace();
2493            throw err;
2494        }
2495
2496    }
2497
2498    @TestTargetNew(
2499        level = TestLevel.COMPLETE,
2500        notes = "Verifies serialization.",
2501        method = "!Serialization",
2502        args = {}
2503    )
2504    public void test_writeObject_Permission() {
2505        // Test for method void
2506        // java.io.ObjectOutputStream.writeObject(java.security.Permission)
2507
2508        Object objToSave = null;
2509        Object objLoaded = null;
2510
2511        try {
2512            objToSave = null;
2513            objToSave = new java.security.Permission("test") {
2514                public boolean equals(Object p1) {
2515                    if (!(p1 instanceof java.security.Permission))
2516                        return false;
2517                    return getName().equals(
2518                            ((java.security.Permission) p1).getName());
2519                }
2520
2521                public int hashCode() {
2522                    return 0;
2523                }
2524
2525                public String getActions() {
2526                    return null;
2527                }
2528
2529                public boolean implies(java.security.Permission p1) {
2530                    return false;
2531                }
2532            };
2533            if (DEBUG)
2534                System.out.println("Obj = " + objToSave);
2535            objLoaded = dumpAndReload(objToSave);
2536
2537            // Has to have worked
2538            assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
2539        } catch (IOException e) {
2540            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2541        } catch (ClassNotFoundException e) {
2542            fail("ClassNotFoundException reading Object type: "
2543                    + e.getMessage());
2544        } catch (Error err) {
2545            System.out.println("Error when obj = " + objToSave);
2546            // err.printStackTrace();
2547            throw err;
2548        }
2549
2550    }
2551
2552    @TestTargetNew(
2553        level = TestLevel.COMPLETE,
2554        notes = "Verifies serialization.",
2555        method = "!Serialization",
2556        args = {}
2557    )
2558    public void test_writeObject_Random() {
2559        // Test for method void
2560        // java.io.ObjectOutputStream.writeObject(java.util.Random)
2561
2562        Object objToSave = null;
2563        Object objLoaded = null;
2564
2565        try {
2566            objToSave = new java.util.Random(107L);
2567            if (DEBUG)
2568                System.out.println("Obj = " + objToSave);
2569            objLoaded = dumpAndReload(objToSave);
2570
2571            // Has to have worked
2572            boolean equals;
2573            equals = ((java.util.Random) objToSave).nextInt() == ((java.util.Random) objLoaded)
2574                    .nextInt();
2575            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2576        } catch (IOException e) {
2577            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2578        } catch (ClassNotFoundException e) {
2579            fail("ClassNotFoundException reading Object type: "
2580                    + e.getMessage());
2581        } catch (Error err) {
2582            System.out.println("Error when obj = " + objToSave);
2583            // err.printStackTrace();
2584            throw err;
2585        }
2586
2587    }
2588
2589    @TestTargetNew(
2590        level = TestLevel.COMPLETE,
2591        notes = "Verifies serialization.",
2592        method = "!Serialization",
2593        args = {}
2594    )
2595    public void test_writeObject_GuardedObject() {
2596        // Test for method void
2597        // java.io.ObjectOutputStream.writeObject(java.security.GuardedObject)
2598
2599        Object objToSave = null;
2600        Object objLoaded = null;
2601
2602        try {
2603            objToSave = new java.security.GuardedObject("Test Object",
2604                    new GuardImplementation());
2605            if (DEBUG)
2606                System.out.println("Obj = " + objToSave);
2607            objLoaded = dumpAndReload(objToSave);
2608
2609            // Has to have worked
2610            boolean equals;
2611            equals = ((java.security.GuardedObject) objToSave).getObject()
2612                    .equals(
2613                            ((java.security.GuardedObject) objLoaded)
2614                                    .getObject());
2615            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2616        } catch (IOException e) {
2617            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2618        } catch (ClassNotFoundException e) {
2619            fail("ClassNotFoundException reading Object type: "
2620                    + e.getMessage());
2621        } catch (Error err) {
2622            System.out.println("Error when obj = " + objToSave);
2623            // err.printStackTrace();
2624            throw err;
2625        }
2626
2627    }
2628
2629    // TODO : Reintroduce when we have a working security implementation
2630    // public void test_writeObject_KeyPair() {
2631    // // Test for method void
2632    // // java.io.ObjectOutputStream.writeObject(java.security.GuardedObject)
2633    //
2634    // Object objToSave = null;
2635    // Object objLoaded = null;
2636    //
2637    // try {
2638    // objToSave = new java.security.KeyPair(null, null);
2639    // if (DEBUG)
2640    // System.out.println("Obj = " + objToSave);
2641    // objLoaded = dumpAndReload(objToSave);
2642    //
2643    // // Has to have worked
2644    // boolean equals;
2645    // equals = true;
2646    // assertTrue(MSG_TEST_FAILED + objToSave, equals);
2647    // } catch (IOException e) {
2648    // fail("IOException serializing " + objToSave + " : "
2649    // + e.getMessage());
2650    // } catch (ClassNotFoundException e) {
2651    // fail("ClassNotFoundException reading Object type : " + e.getMessage());
2652    // } catch (Error err) {
2653    // System.out.println("Error when obj = " + objToSave);
2654    // // err.printStackTrace();
2655    // throw err;
2656    // }
2657    // }
2658
2659    static class MyInvocationHandler implements InvocationHandler, Serializable {
2660        public Object invoke(Object proxy, Method method, Object[] args)
2661                throws Throwable {
2662            if (method.getName().equals("equals"))
2663                return new Boolean(proxy == args[0]);
2664            if (method.getName().equals("array"))
2665                return new int[] { (int) ((long[]) args[0])[1], -1 };
2666            if (method.getName().equals("string")) {
2667                if ("error".equals(args[0]))
2668                    throw new ArrayStoreException();
2669                if ("any".equals(args[0]))
2670                    throw new IllegalAccessException();
2671            }
2672            return null;
2673        }
2674    }
2675
2676    @TestTargetNew(
2677        level = TestLevel.COMPLETE,
2678        notes = "Verifies serialization.",
2679        method = "!Serialization",
2680        args = {}
2681    )
2682    public void test_writeObject_Proxy() {
2683        // Test for method void
2684        // java.io.ObjectOutputStream.writeObject(java.security.GuardedObject)
2685
2686        Object objToSave = null;
2687        Object objLoaded = null;
2688
2689        try {
2690            objToSave = Proxy.getProxyClass(Support_Proxy_I1.class
2691                    .getClassLoader(), new Class[] { Support_Proxy_I1.class });
2692            if (DEBUG)
2693                System.out.println("Obj = " + objToSave);
2694            objLoaded = dumpAndReload(objToSave);
2695
2696            assertTrue(MSG_TEST_FAILED + "not a proxy class", Proxy
2697                    .isProxyClass((Class) objLoaded));
2698            Class[] interfaces = ((Class) objLoaded).getInterfaces();
2699            assertTrue(MSG_TEST_FAILED + "wrong interfaces length",
2700                    interfaces.length == 1);
2701            assertTrue(MSG_TEST_FAILED + "wrong interface",
2702                    interfaces[0] == Support_Proxy_I1.class);
2703
2704            InvocationHandler handler = new MyInvocationHandler();
2705            objToSave = Proxy.newProxyInstance(Support_Proxy_I1.class
2706                    .getClassLoader(), new Class[] { Support_Proxy_I1.class },
2707                    handler);
2708            if (DEBUG)
2709                System.out.println("Obj = " + objToSave);
2710            objLoaded = dumpAndReload(objToSave);
2711
2712            boolean equals = Proxy.getInvocationHandler(objLoaded).getClass() == MyInvocationHandler.class;
2713            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2714
2715        } catch (IOException e) {
2716            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2717        } catch (ClassNotFoundException e) {
2718            fail("ClassNotFoundException reading Object type: "
2719                    + e.getMessage());
2720        } catch (Error err) {
2721            System.out.println("Error when obj = " + objToSave);
2722            // err.printStackTrace();
2723            throw err;
2724        }
2725    }
2726
2727    @TestTargetNew(
2728        level = TestLevel.COMPLETE,
2729        notes = "Verifies serialization.",
2730        method = "!Serialization",
2731        args = {}
2732    )
2733    public void test_writeObject_URI() {
2734        // Test for method void
2735        // java.io.ObjectOutputStream.writeObject(java.net.URI)
2736
2737        Object objToSave = null;
2738        Object objLoaded = null;
2739
2740        try {
2741            try {
2742                objToSave = new URI[] {
2743                        // single arg constructor
2744                        new URI(
2745                                "http://user%60%20info@host/a%20path?qu%60%20ery#fr%5E%20ag"),
2746                        // escaped octets for illegal chars
2747                        new URI(
2748                                "http://user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery#fr%C3%A4%C3%A8g"),
2749                        // escaped octets for unicode chars
2750                        new URI(
2751                                "ascheme://user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery#fr\u00E4\u00E8g"),
2752                        // multiple arg constructors
2753                        new URI("http", "user%60%20info", "host", 80,
2754                                "/a%20path", "qu%60%20ery", "fr%5E%20ag"),
2755                        // escaped octets for illegal
2756                        new URI("http", "user%C3%9F%C2%A3info", "host", -1,
2757                                "/a%E2%82%ACpath", "qu%C2%A9%C2%AEery",
2758                                "fr%C3%A4%C3%A8g"),
2759                        // escaped octets for unicode
2760                        new URI("ascheme", "user\u00DF\u00A3info", "host", 80,
2761                                "/a\u20ACpath", "qu\u00A9\u00AEery",
2762                                "fr\u00E4\u00E8g"),
2763                        new URI("http", "user` info", "host", 81, "/a path",
2764                                "qu` ery", "fr^ ag"), // illegal chars
2765                        new URI("http", "user%info", "host", 0, "/a%path",
2766                                "que%ry", "f%rag"),
2767                        // % as illegal char, not escaped octet urls with
2768                        // undefined components
2769                        new URI("mailto", "user@domain.com", null),
2770                        // no host, path, query or fragment
2771                        new URI("../adirectory/file.html#"),
2772                        // relative path with empty fragment;
2773                        new URI("news", "comp.infosystems.www.servers.unix",
2774                                null),
2775                        new URI(null, null, null, "fragment"),
2776                        // only fragment
2777                        new URI("telnet://server.org"), // only host
2778                        new URI("http://reg:istry?query"),
2779                        // malformed hostname, therefore registry-based,
2780                        // with query
2781                        new URI("file:///c:/temp/calculate.pl?")
2782                        // empty authority, non empty path, empty query
2783                };
2784            } catch (URISyntaxException e) {
2785                fail("Unexpected Exception:" + e);
2786            }
2787            if (DEBUG)
2788                System.out.println("Obj = " + objToSave);
2789            objLoaded = dumpAndReload(objToSave);
2790
2791            // Has to have worked
2792            assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
2793                    (URI[]) objToSave, (URI[]) objLoaded));
2794        } catch (IOException e) {
2795            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2796        } catch (ClassNotFoundException e) {
2797            fail("ClassNotFoundException reading Object type: "
2798                    + e.getMessage());
2799        } catch (Error err) {
2800            System.out.println("Error when obj = " + objToSave);
2801            // err.printStackTrace();
2802            throw err;
2803        }
2804    }
2805
2806    @TestTargetNew(
2807        level = TestLevel.COMPLETE,
2808        notes = "Verifies serialization.",
2809        method = "!Serialization",
2810        args = {}
2811    )
2812    public void test_writeObject_URISyntaxException() {
2813        // Test for method void
2814        // java.io.ObjectOutputStream.writeObject(java.net.URISyntaxException)
2815
2816        URISyntaxException objToSave = null;
2817        URISyntaxException objLoaded = null;
2818
2819        try {
2820            objToSave = new URISyntaxException("str", "problem", 4);
2821            if (DEBUG)
2822                System.out.println("Obj = " + objToSave);
2823            objLoaded = (URISyntaxException) dumpAndReload(objToSave);
2824
2825            boolean equals = objToSave.getMessage().equals(
2826                    objLoaded.getMessage())
2827                    && objToSave.getInput().equals(objLoaded.getInput())
2828                    && objToSave.getIndex() == objLoaded.getIndex()
2829                    && objToSave.getReason().equals(objLoaded.getReason());
2830
2831            // Has to have worked
2832            assertTrue(MSG_TEST_FAILED + objToSave, equals);
2833        } catch (IOException e) {
2834            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2835        } catch (ClassNotFoundException e) {
2836            fail("ClassNotFoundException reading Object type: "
2837                    + e.getMessage());
2838        } catch (Error err) {
2839            System.out.println("Error when obj = " + objToSave);
2840            // err.printStackTrace();
2841            throw err;
2842        }
2843
2844    }
2845
2846    @TestTargetNew(
2847        level = TestLevel.COMPLETE,
2848        notes = "Verifies serialization.",
2849        method = "!Serialization",
2850        args = {}
2851    )
2852    public void test_writeObject_Currency() {
2853        // Test for method void
2854        // java.io.ObjectOutputStream.writeObject(java.util.Currency)
2855
2856        Object objToSave = null;
2857        Object objLoaded = null;
2858
2859        try {
2860            objToSave = java.util.Currency.getInstance("AMD");
2861            if (DEBUG)
2862                System.out.println("Obj = " + objToSave);
2863            objLoaded = dumpAndReload(objToSave);
2864
2865            // Has to have worked
2866            // we need same instance for the same currency code
2867            assertTrue(MSG_TEST_FAILED + objToSave, objToSave == objToSave);
2868        } catch (IOException e) {
2869            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2870        } catch (ClassNotFoundException e) {
2871            fail("ClassNotFoundException reading Object type: "
2872                    + e.getMessage());
2873        } catch (Error err) {
2874            System.out.println("Error when obj = " + objToSave);
2875            // err.printStackTrace();
2876            throw err;
2877        }
2878    }
2879
2880    @TestTargetNew(
2881        level = TestLevel.COMPLETE,
2882        notes = "Verifies serialization.",
2883        method = "!Serialization",
2884        args = {}
2885    )
2886    @KnownFailure("deserialization of a date fomat field seems to fail")
2887    public void test_writeObject_DateFormat_Field() {
2888        // Test for method void
2889        // java.io.ObjectOutputStream.writeObject(java.text.DateFormat.Field)
2890
2891        DateFormat.Field[] objToSave = null;
2892        DateFormat.Field[] objLoaded = null;
2893
2894        try {
2895            objToSave = new DateFormat.Field[] { DateFormat.Field.AM_PM,
2896                    DateFormat.Field.DAY_OF_MONTH, DateFormat.Field.ERA,
2897                    DateFormat.Field.HOUR0, DateFormat.Field.HOUR1,
2898                    DateFormat.Field.HOUR_OF_DAY0,
2899                    DateFormat.Field.HOUR_OF_DAY1, DateFormat.Field.TIME_ZONE,
2900                    DateFormat.Field.YEAR,
2901                    DateFormat.Field.DAY_OF_WEEK_IN_MONTH };
2902            if (DEBUG)
2903                System.out.println("Obj = " + objToSave);
2904
2905            objLoaded = (DateFormat.Field[]) dumpAndReload(objToSave);
2906
2907            // Has to have worked
2908            // we need same instances for the same field names
2909            for (int i = 0; i < objToSave.length; i++) {
2910                assertTrue(MSG_TEST_FAILED + objToSave[i],
2911                        objToSave[i] == objLoaded[i]);
2912            }
2913        } catch (IOException e) {
2914            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2915        } catch (ClassNotFoundException e) {
2916            fail("ClassNotFoundException reading Object type: "
2917                    + e.getMessage());
2918        } catch (Error err) {
2919            System.out.println("Error when obj = " + objToSave);
2920            // err.printStackTrace();
2921            throw err;
2922        }
2923    }
2924
2925    @TestTargetNew(
2926        level = TestLevel.COMPLETE,
2927        notes = "Verifies serialization.",
2928        method = "!Serialization",
2929        args = {}
2930    )
2931    @KnownFailure("deserialization of a number fomat field seems to fail")
2932    public void test_writeObject_NumberFormat_Field() {
2933        // Test for method void
2934        // java.io.ObjectOutputStream.writeObject(java.text.NumberFormat.Field)
2935
2936        NumberFormat.Field[] objToSave = null;
2937        NumberFormat.Field[] objLoaded = null;
2938
2939        try {
2940            objToSave = new NumberFormat.Field[] { NumberFormat.Field.CURRENCY,
2941                    NumberFormat.Field.DECIMAL_SEPARATOR,
2942                    NumberFormat.Field.EXPONENT,
2943                    NumberFormat.Field.EXPONENT_SIGN,
2944                    NumberFormat.Field.EXPONENT_SYMBOL,
2945                    NumberFormat.Field.FRACTION,
2946                    NumberFormat.Field.GROUPING_SEPARATOR,
2947                    NumberFormat.Field.INTEGER, NumberFormat.Field.PERCENT,
2948                    NumberFormat.Field.PERMILLE, NumberFormat.Field.SIGN };
2949            if (DEBUG)
2950                System.out.println("Obj = " + objToSave);
2951
2952            objLoaded = (NumberFormat.Field[]) dumpAndReload(objToSave);
2953
2954            // Has to have worked
2955            // we need same instances for the same field names
2956            for (int i = 0; i < objToSave.length; i++) {
2957                assertTrue(MSG_TEST_FAILED + objToSave[i],
2958                        objToSave[i] == objLoaded[i]);
2959            }
2960        } catch (IOException e) {
2961            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2962        } catch (ClassNotFoundException e) {
2963            fail("ClassNotFoundException reading Object type: "
2964                    + e.getMessage());
2965        } catch (Error err) {
2966            System.out.println("Error when obj = " + objToSave);
2967            // err.printStackTrace();
2968            throw err;
2969        }
2970    }
2971
2972    @TestTargetNew(
2973        level = TestLevel.COMPLETE,
2974        notes = "Verifies serialization.",
2975        method = "!Serialization",
2976        args = {}
2977    )
2978    public void test_writeObject_MessageFormat_Field() {
2979        // Test for method void
2980        // java.io.ObjectOutputStream.writeObject(java.text.MessageFormat.Field)
2981
2982        Object objToSave = null;
2983        Object objLoaded = null;
2984
2985        try {
2986            objToSave = MessageFormat.Field.ARGUMENT;
2987            if (DEBUG)
2988                System.out.println("Obj = " + objToSave);
2989
2990            objLoaded = dumpAndReload(objToSave);
2991
2992            // Has to have worked
2993            // we need same instance for the same field name
2994            assertTrue(MSG_TEST_FAILED + objToSave, objToSave == objLoaded);
2995        } catch (IOException e) {
2996            fail("Exception serializing " + objToSave + " : " + e.getMessage());
2997        } catch (ClassNotFoundException e) {
2998            fail("ClassNotFoundException reading Object type: "
2999                    + e.getMessage());
3000        } catch (Error err) {
3001            System.out.println("Error when obj = " + objToSave);
3002            // err.printStackTrace();
3003            throw err;
3004        }
3005    }
3006
3007    @TestTargetNew(
3008        level = TestLevel.COMPLETE,
3009        notes = "Verifies serialization.",
3010        method = "!Serialization",
3011        args = {}
3012    )
3013    public void test_writeObject_LinkedHashMap() {
3014        // Test for method void
3015        // java.io.ObjectOutputStream.writeObject(java.lang.Object)
3016
3017        Object objToSave = null;
3018        Object objLoaded;
3019
3020        try {
3021            objToSave = LINKEDMAP;
3022            if (DEBUG)
3023                System.out.println("Obj = " + objToSave);
3024            objLoaded = dumpAndReload(objToSave);
3025            // Has to have worked
3026            assertTrue(MSG_TEST_FAILED + objToSave, LINKEDMAP.equals(objLoaded));
3027
3028            Map mapLoaded = (Map) objLoaded;
3029            Iterator loadedIterator = mapLoaded.keySet().iterator();
3030            Iterator iterator = LINKEDMAP.keySet().iterator();
3031            while (loadedIterator.hasNext()) {
3032                assertTrue("invalid iterator order", loadedIterator.next()
3033                        .equals(iterator.next()));
3034            }
3035            assertTrue("invalid iterator size", !iterator.hasNext());
3036
3037            loadedIterator = mapLoaded.entrySet().iterator();
3038            iterator = LINKEDMAP.entrySet().iterator();
3039            while (loadedIterator.hasNext()) {
3040                assertTrue("invalid entry set iterator order", loadedIterator
3041                        .next().equals(iterator.next()));
3042            }
3043            assertTrue("invalid entry set iterator size", !iterator.hasNext());
3044
3045        } catch (IOException e) {
3046            fail("Exception serializing " + objToSave + " : " + e.getMessage());
3047        } catch (ClassNotFoundException e) {
3048            fail("ClassNotFoundException reading Object type: "
3049                    + e.getMessage());
3050        } catch (Error err) {
3051            System.out.println("Error when obj = " + objToSave);
3052            // err.printStackTrace();
3053            throw err;
3054        }
3055    }
3056
3057    @TestTargetNew(
3058        level = TestLevel.COMPLETE,
3059        notes = "Verifies serialization.",
3060        method = "!Serialization",
3061        args = {}
3062    )
3063    public void test_writeObject_LinkedHashSet() {
3064        // Test for method void
3065        // java.io.ObjectOutputStream.writeObject(java.lang.Object)
3066
3067        Object objToSave = null;
3068        Object objLoaded;
3069
3070        try {
3071            objToSave = LINKEDSET;
3072            if (DEBUG)
3073                System.out.println("Obj = " + objToSave);
3074            objLoaded = dumpAndReload(objToSave);
3075            // Has to have worked
3076            assertTrue(MSG_TEST_FAILED + objToSave, LINKEDSET.equals(objLoaded));
3077
3078        } catch (IOException e) {
3079            fail("Exception serializing " + objToSave + " : " + e.getMessage());
3080        } catch (ClassNotFoundException e) {
3081            fail("ClassNotFoundException reading Object type: "
3082                    + e.getMessage());
3083        } catch (Error err) {
3084            System.out.println("Error when obj = " + objToSave);
3085            // err.printStackTrace();
3086            throw err;
3087        }
3088    }
3089
3090    @TestTargetNew(
3091        level = TestLevel.COMPLETE,
3092        notes = "Verifies serialization.",
3093        method = "!Serialization",
3094        args = {}
3095    )
3096    public void test_writeObject_IdentityHashMap() {
3097        // Test for method void
3098        // java.io.ObjectOutputStream.writeObject(java.lang.Object)
3099
3100        IdentityHashMap objToSave = null;
3101        IdentityHashMap objLoaded;
3102
3103        try {
3104            objToSave = IDENTITYMAP;
3105            if (DEBUG)
3106                System.out.println("Obj = " + objToSave);
3107            objLoaded = (IdentityHashMap) dumpAndReload(objToSave);
3108            // Has to have worked
3109
3110            // a serialized identity hash map will not be equal to its original
3111            // because it is an "identity" mapping,
3112            // so we simply check for the usual meaning of equality
3113
3114            assertEquals(
3115                    "Loaded IdentityHashMap is not of the same size as the saved one.",
3116                    objToSave.size(), objLoaded.size());
3117            HashMap duplicateSaved = new HashMap();
3118            duplicateSaved.putAll(objToSave);
3119            HashMap duplicateLoaded = new HashMap();
3120            duplicateLoaded.putAll(objLoaded);
3121            assertTrue(MSG_TEST_FAILED + duplicateSaved, duplicateSaved
3122                    .equals(duplicateLoaded));
3123        } catch (IOException e) {
3124            fail("Exception serializing " + objToSave + " : " + e.getMessage());
3125        } catch (ClassNotFoundException e) {
3126            fail("ClassNotFoundException reading Object type: "
3127                    + e.getMessage());
3128        } catch (Error err) {
3129            System.out.println("Error when obj = " + objToSave);
3130            // err.printStackTrace();
3131            throw err;
3132        }
3133    }
3134}
3135