0001: /*
0002: * Licensed to the Apache Software Foundation (ASF) under one or more
0003: * contributor license agreements. See the NOTICE file distributed with
0004: * this work for additional information regarding copyright ownership.
0005: * The ASF licenses this file to You under the Apache License, Version 2.0
0006: * (the "License"); you may not use this file except in compliance with
0007: * the License. You may obtain a copy of the License at
0008: *
0009: * http://www.apache.org/licenses/LICENSE-2.0
0010: *
0011: * Unless required by applicable law or agreed to in writing, software
0012: * distributed under the License is distributed on an "AS IS" BASIS,
0013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014: * See the License for the specific language governing permissions and
0015: * limitations under the License.
0016: */
0017: package org.apache.harmony.luni.tests.java.io;
0018:
0019: import java.io.ByteArrayInputStream;
0020: import java.io.ByteArrayOutputStream;
0021: import java.io.DataOutputStream;
0022: import java.io.IOException;
0023: import java.io.ObjectInputStream;
0024: import java.io.ObjectOutputStream;
0025: import java.io.ObjectStreamConstants;
0026: import java.io.ObjectStreamField;
0027: import java.io.OptionalDataException;
0028: import java.math.BigInteger;
0029: import java.security.PermissionCollection;
0030: import java.util.Arrays;
0031: import java.util.BitSet;
0032: import java.util.Collections;
0033: import java.util.Enumeration;
0034: import java.util.Locale;
0035: import java.util.PropertyPermission;
0036: import java.util.TimeZone;
0037: import java.util.Vector;
0038:
0039: @SuppressWarnings({"serial","unused"})
0040: public class SerializationStressTest3 extends SerializationStressTest {
0041:
0042: // -----------------------------------------------------------------------------------
0043: private static class DefaultConstructor implements
0044: java.io.Serializable {
0045: int f1;
0046:
0047: static int valueAfterConstructor = 5;
0048:
0049: DefaultConstructor() {
0050: f1 = valueAfterConstructor;
0051: }
0052:
0053: public boolean equals(Object obj) {
0054: /*
0055: * This method is not answering it the objs is equal. It is
0056: * answering if the vars have the value that it have to have after
0057: * dumping and loading
0058: */
0059:
0060: if (obj == null)
0061: return false;
0062: if (!(obj instanceof DefaultConstructor))
0063: return false;
0064:
0065: DefaultConstructor inst = (DefaultConstructor) obj;
0066: return inst.f1 == valueAfterConstructor;
0067: }
0068: }
0069:
0070: // -----------------------------------------------------------------------------------
0071: private static class NonSerDefaultConstructor {
0072: public int f1;
0073:
0074: public static int valueAfterConstructor = 5;
0075:
0076: NonSerDefaultConstructor() {
0077: f1 = valueAfterConstructor;
0078: }
0079:
0080: public NonSerDefaultConstructor(String notUsed) {
0081: }
0082: }
0083:
0084: private static class NonSerPrivateConstructor {
0085: public int f1;
0086:
0087: public static int valueAfterConstructor = 5;
0088:
0089: private NonSerPrivateConstructor() {
0090: f1 = valueAfterConstructor;
0091: }
0092:
0093: public NonSerPrivateConstructor(String notUsed) {
0094: }
0095: }
0096:
0097: private static class NonSerProtectedConstructor {
0098: public int f1;
0099:
0100: public static int valueAfterConstructor = 5;
0101:
0102: protected NonSerProtectedConstructor() {
0103: f1 = valueAfterConstructor;
0104: }
0105: }
0106:
0107: private static class NonSerPublicConstructor {
0108: public int f1;
0109:
0110: public static int valueAfterConstructor = 5;
0111:
0112: public NonSerPublicConstructor() {
0113: f1 = valueAfterConstructor;
0114: }
0115: }
0116:
0117: // -----------------------------------------------------------------------------------
0118: private static class DefaultConstructorSub extends
0119: NonSerDefaultConstructor implements java.io.Serializable {
0120: int fsub;
0121:
0122: static int subValueAfterConstructor = 11;
0123:
0124: public DefaultConstructorSub() {
0125: f1 = 7;
0126: fsub = subValueAfterConstructor;
0127: }
0128:
0129: public boolean equals(Object obj) {
0130: /*
0131: * This method is not answering it the objs is equal. It is
0132: * answering if the vars have the value that it have to have after
0133: * dumping and loading
0134: */
0135:
0136: if (obj == null)
0137: return false;
0138: if (!(obj instanceof DefaultConstructorSub))
0139: return false;
0140:
0141: DefaultConstructorSub inst = (DefaultConstructorSub) obj;
0142: if (inst.f1 != valueAfterConstructor)
0143: return false;
0144: return inst.fsub == subValueAfterConstructor;
0145: }
0146: }
0147:
0148: // -----------------------------------------------------------------------------------
0149: private static class PrivateConstructor implements
0150: java.io.Serializable {
0151: int f1;
0152:
0153: static int valueAfterConstructor = 5;
0154:
0155: private PrivateConstructor() {
0156: f1 = valueAfterConstructor;
0157: }
0158:
0159: public boolean equals(Object obj) {
0160: /*
0161: * This method is not answering it the objs is equal. Is is
0162: * answering if the vars have the value that it have to have after
0163: * dumping and loading
0164: */
0165:
0166: if (obj == null)
0167: return false;
0168: if (!(obj instanceof PrivateConstructor))
0169: return false;
0170:
0171: PrivateConstructor inst = (PrivateConstructor) obj;
0172: return inst.f1 == valueAfterConstructor;
0173: }
0174: }
0175:
0176: // -----------------------------------------------------------------------------------
0177: private static class PrivateConstructorSub extends
0178: NonSerPrivateConstructor implements java.io.Serializable {
0179: int fsub;
0180:
0181: static int subValueAfterConstructor = 11;
0182:
0183: public PrivateConstructorSub() {
0184: super ("notUsed");
0185: f1 = 7;
0186: fsub = subValueAfterConstructor;
0187: }
0188:
0189: public boolean equals(Object obj) {
0190: /*
0191: * This method is not answering it the objs is equal. Is is
0192: * answering if the vars have the value that it have to have after
0193: * dumping and loading
0194: */
0195:
0196: if (obj == null)
0197: return false;
0198: if (!(obj instanceof PrivateConstructorSub))
0199: return false;
0200:
0201: PrivateConstructorSub inst = (PrivateConstructorSub) obj;
0202: return inst.f1 == valueAfterConstructor
0203: && inst.fsub == subValueAfterConstructor;
0204: }
0205: }
0206:
0207: // -----------------------------------------------------------------------------------
0208: private static class ProtectedConstructor implements
0209: java.io.Serializable {
0210: int f1;
0211:
0212: static int valueAfterConstructor = 5;
0213:
0214: protected ProtectedConstructor() {
0215: f1 = valueAfterConstructor;
0216: }
0217:
0218: public boolean equals(Object obj) {
0219: /*
0220: * This method is not answering it the objs is equal. Is is
0221: * answering if the vars have the value that it have to have after
0222: * dumping and loading
0223: */
0224:
0225: if (obj == null)
0226: return false;
0227: if (!(obj instanceof ProtectedConstructor))
0228: return false;
0229:
0230: ProtectedConstructor inst = (ProtectedConstructor) obj;
0231: return inst.f1 == valueAfterConstructor;
0232: }
0233: }
0234:
0235: // -----------------------------------------------------------------------------------
0236: private static class ProtectedConstructorSub extends
0237: NonSerProtectedConstructor implements java.io.Serializable {
0238: int fsub;
0239:
0240: static int subValueAfterConstructor = 11;
0241:
0242: public ProtectedConstructorSub() {
0243: f1 = 7;
0244: fsub = subValueAfterConstructor;
0245: }
0246:
0247: public boolean equals(Object obj) {
0248: /*
0249: * This method is not answering it the objs is equal. Is is
0250: * answering if the vars have the value that it have to have after
0251: * dumping and loading
0252: */
0253:
0254: if (obj == null)
0255: return false;
0256: if (!(obj instanceof ProtectedConstructorSub))
0257: return false;
0258:
0259: ProtectedConstructorSub inst = (ProtectedConstructorSub) obj;
0260: return inst.f1 == valueAfterConstructor
0261: && inst.fsub == subValueAfterConstructor;
0262: }
0263: }
0264:
0265: // -----------------------------------------------------------------------------------
0266: private static class PublicConstructor implements
0267: java.io.Serializable {
0268: int f1;
0269:
0270: static int valueAfterConstructor = 5;
0271:
0272: public PublicConstructor() {
0273: f1 = valueAfterConstructor;
0274: }
0275:
0276: public boolean equals(Object obj) {
0277: /*
0278: * This method is not answering it the objs is equal. Is is
0279: * answering if the vars have the value that it have to have after
0280: * dumping and loading
0281: */
0282:
0283: if (obj == null)
0284: return false;
0285: if (!(obj instanceof PublicConstructor))
0286: return false;
0287:
0288: PublicConstructor inst = (PublicConstructor) obj;
0289: return inst.f1 == valueAfterConstructor;
0290: }
0291: }
0292:
0293: // -----------------------------------------------------------------------------------
0294: private static class PublicConstructorSub extends
0295: NonSerPublicConstructor implements java.io.Serializable {
0296: int fsub;
0297:
0298: static final int subValueAfterConstructor = 11;
0299:
0300: public PublicConstructorSub() {
0301: f1 = 7;
0302: fsub = subValueAfterConstructor;
0303: }
0304:
0305: public boolean equals(Object obj) {
0306: /*
0307: * This method is not answering it the objs is equal. It is
0308: * answering if the vars have the value that it have to have after
0309: * dumping and loading
0310: */
0311:
0312: if (obj == null)
0313: return false;
0314: if (!(obj instanceof PublicConstructorSub))
0315: return false;
0316:
0317: PublicConstructorSub inst = (PublicConstructorSub) obj;
0318: return inst.f1 == valueAfterConstructor
0319: && inst.fsub == subValueAfterConstructor;
0320: }
0321: }
0322:
0323: // Tests the behavior of ObjectOutputStream.PutField.write()
0324: private static class WriteFieldsUsingPutFieldWrite implements
0325: java.io.Serializable {
0326: private static final ObjectStreamField[] serialPersistentFields = {
0327: new ObjectStreamField("object1", Vector.class),
0328: new ObjectStreamField("int1", Integer.TYPE) };
0329:
0330: private static Vector v1 = new Vector<String>(Arrays
0331: .asList(new String[] { "1st", "2nd" }));
0332:
0333: private boolean passed = false;
0334:
0335: public WriteFieldsUsingPutFieldWrite() {
0336: super ();
0337: }
0338:
0339: public boolean passed() {
0340: return passed;
0341: }
0342:
0343: private void readObject(java.io.ObjectInputStream in)
0344: throws java.io.IOException, ClassNotFoundException {
0345: int int1 = in.readInt();
0346: Vector object1 = (Vector) in.readObject();
0347: passed = int1 == 0xA9 && object1.equals(v1);
0348: }
0349:
0350: @SuppressWarnings("deprecation")
0351: private void writeObject(java.io.ObjectOutputStream out)
0352: throws java.io.IOException, ClassNotFoundException {
0353: ObjectOutputStream.PutField fields = out.putFields();
0354: fields.put("object1", v1);
0355: fields.put("int1", 0xA9);
0356: // Use fields.write() instead of out.writeFields();
0357: fields.write(out);
0358: }
0359: }
0360:
0361: public SerializationStressTest3(String name) {
0362: super (name);
0363: }
0364:
0365: public void test_18_81_writeObject() {
0366: // Test for method void
0367: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0368:
0369: try {
0370: ByteArrayOutputStream out = new ByteArrayOutputStream();
0371: DataOutputStream dos = new DataOutputStream(out);
0372: new ObjectOutputStream(dos); // just to make sure we get a header
0373: dos.writeByte(ObjectStreamConstants.TC_BLOCKDATALONG);
0374: int length = 333; // Bigger than 1 byte
0375: dos.writeInt(length);
0376: for (int i = 0; i < length; i++) {
0377: dos.writeByte(0); // actual value does not matter
0378: }
0379: dos.flush();
0380: int lengthRead = 0;
0381: try {
0382: ObjectInputStream ois = new ObjectInputStream(
0383: new ByteArrayInputStream(out.toByteArray()));
0384: Object obj = ois.readObject();
0385: } catch (OptionalDataException e) {
0386: lengthRead = e.length;
0387: }
0388: assertTrue(
0389: "Did not throw exception with optional data size ",
0390: length == lengthRead);
0391: } catch (ClassNotFoundException e) {
0392: fail("Unable to read BLOCKDATA : " + e.getMessage());
0393: } catch (IOException e) {
0394: fail("IOException testing BLOCKDATALONG : "
0395: + e.getMessage());
0396: } catch (Error err) {
0397: System.out.println("Error " + err
0398: + " when testing BLOCKDATALONG");
0399: throw err;
0400: }
0401: }
0402:
0403: public void test_18_82_writeObject() {
0404: // Test for method void
0405: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0406:
0407: Object objToSave = null;
0408: Object objLoaded;
0409:
0410: try {
0411: DefaultConstructor test = new DefaultConstructor();
0412: objToSave = test;
0413: if (DEBUG)
0414: System.out.println("Obj = " + objToSave);
0415: objLoaded = dumpAndReload(objToSave);
0416: // Has to have worked
0417: assertTrue(MSG_TEST_FAILED + objToSave, test
0418: .equals(objLoaded));
0419:
0420: } catch (IOException e) {
0421: fail("IOException serializing " + objToSave + " : "
0422: + e.getMessage());
0423: } catch (ClassNotFoundException e) {
0424: fail("ClassNotFoundException reading Object type : "
0425: + e.getMessage());
0426: } catch (Error err) {
0427: System.out.println("Error when obj = " + objToSave);
0428: // err.printStackTrace();
0429: throw err;
0430: }
0431: }
0432:
0433: public void test_18_83_writeObject() {
0434: // Test for method void
0435: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0436:
0437: Object objToSave = null;
0438: Object objLoaded;
0439:
0440: try {
0441: DefaultConstructorSub test = new DefaultConstructorSub();
0442: objToSave = test;
0443: if (DEBUG)
0444: System.out.println("Obj = " + objToSave);
0445: objLoaded = dumpAndReload(objToSave);
0446: // Has to have worked
0447: assertTrue(MSG_TEST_FAILED + objToSave, test
0448: .equals(objLoaded));
0449:
0450: } catch (IOException e) {
0451: fail("IOException serializing " + objToSave + " : "
0452: + e.getMessage());
0453: } catch (ClassNotFoundException e) {
0454: fail("ClassNotFoundException reading Object type : "
0455: + e.getMessage());
0456: } catch (Error err) {
0457: System.out.println("Error when obj = " + objToSave);
0458: // err.printStackTrace();
0459: throw err;
0460: }
0461: }
0462:
0463: public void test_18_84_writeObject() {
0464: // Test for method void
0465: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0466:
0467: Object objToSave = null;
0468: Object objLoaded;
0469:
0470: try {
0471: PrivateConstructor test = new PrivateConstructor();
0472: objToSave = test;
0473: if (DEBUG)
0474: System.out.println("Obj = " + objToSave);
0475: objLoaded = dumpAndReload(objToSave);
0476: // Has to have worked
0477: assertTrue(MSG_TEST_FAILED + objToSave, test
0478: .equals(objLoaded));
0479:
0480: } catch (IOException e) {
0481: fail("IOException serializing " + objToSave + " : "
0482: + e.getMessage());
0483: } catch (ClassNotFoundException e) {
0484: fail("ClassNotFoundException reading Object type : "
0485: + e.getMessage());
0486: } catch (Error err) {
0487: System.out.println("Error when obj = " + objToSave);
0488: // err.printStackTrace();
0489: throw err;
0490: }
0491: }
0492:
0493: public void test_18_85_writeObject() {
0494: // Test for method void
0495: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0496:
0497: Object objToSave = null;
0498: Object objLoaded;
0499:
0500: try {
0501: PrivateConstructorSub test = new PrivateConstructorSub();
0502: objToSave = test;
0503: if (DEBUG)
0504: System.out.println("Obj = " + objToSave);
0505: objLoaded = dumpAndReload(objToSave);
0506: // Has to have worked
0507: assertTrue(MSG_TEST_FAILED + objToSave, test
0508: .equals(objLoaded));
0509:
0510: } catch (IOException e) {
0511: fail("IOException serializing " + objToSave + " : "
0512: + e.getMessage());
0513: } catch (ClassNotFoundException e) {
0514: fail("ClassNotFoundException reading Object type : "
0515: + e.getMessage());
0516: } catch (Error err) {
0517: System.out.println("Error when obj = " + objToSave);
0518: // err.printStackTrace();
0519: throw err;
0520: }
0521: }
0522:
0523: public void test_18_86_writeObject() {
0524: // Test for method void
0525: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0526:
0527: Object objToSave = null;
0528: Object objLoaded;
0529:
0530: try {
0531: ProtectedConstructor test = new ProtectedConstructor();
0532: objToSave = test;
0533: if (DEBUG)
0534: System.out.println("Obj = " + objToSave);
0535: objLoaded = dumpAndReload(objToSave);
0536: // Has to have worked
0537: assertTrue(MSG_TEST_FAILED + objToSave, test
0538: .equals(objLoaded));
0539:
0540: } catch (IOException e) {
0541: fail("IOException serializing " + objToSave + " : "
0542: + e.getMessage());
0543: } catch (ClassNotFoundException e) {
0544: fail("ClassNotFoundException reading Object type : "
0545: + e.getMessage());
0546: } catch (Error err) {
0547: System.out.println("Error when obj = " + objToSave);
0548: // err.printStackTrace();
0549: throw err;
0550: }
0551: }
0552:
0553: public void test_18_87_writeObject() {
0554: // Test for method void
0555: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0556:
0557: Object objToSave = null;
0558: Object objLoaded;
0559:
0560: try {
0561: ProtectedConstructorSub test = new ProtectedConstructorSub();
0562: objToSave = test;
0563: if (DEBUG)
0564: System.out.println("Obj = " + objToSave);
0565: objLoaded = dumpAndReload(objToSave);
0566: // Has to have worked
0567: assertTrue(MSG_TEST_FAILED + objToSave, test
0568: .equals(objLoaded));
0569:
0570: } catch (IOException e) {
0571: fail("IOException serializing " + objToSave + " : "
0572: + e.getMessage());
0573: } catch (ClassNotFoundException e) {
0574: fail("ClassNotFoundException reading Object type : "
0575: + e.getMessage());
0576: } catch (Error err) {
0577: System.out.println("Error when obj = " + objToSave);
0578: // err.printStackTrace();
0579: throw err;
0580: }
0581: }
0582:
0583: public void test_18_88_writeObject() {
0584: // Test for method void
0585: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0586:
0587: Object objToSave = null;
0588: Object objLoaded;
0589:
0590: try {
0591: PublicConstructor test = new PublicConstructor();
0592: objToSave = test;
0593: if (DEBUG)
0594: System.out.println("Obj = " + objToSave);
0595: objLoaded = dumpAndReload(objToSave);
0596: // Has to have worked
0597: assertTrue(MSG_TEST_FAILED + objToSave, test
0598: .equals(objLoaded));
0599:
0600: } catch (IOException e) {
0601: fail("IOException serializing " + objToSave + " : "
0602: + e.getMessage());
0603: } catch (ClassNotFoundException e) {
0604: fail("ClassNotFoundException reading Object type : "
0605: + e.getMessage());
0606: } catch (Error err) {
0607: System.out.println("Error when obj = " + objToSave);
0608: // err.printStackTrace();
0609: throw err;
0610: }
0611: }
0612:
0613: public void test_18_89_writeObject() {
0614: // Test for method void
0615: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0616:
0617: Object objToSave = null;
0618: Object objLoaded;
0619:
0620: try {
0621: PublicConstructorSub test = new PublicConstructorSub();
0622: objToSave = test;
0623: if (DEBUG)
0624: System.out.println("Obj = " + objToSave);
0625: objLoaded = dumpAndReload(objToSave);
0626: // Has to have worked
0627: assertTrue(MSG_TEST_FAILED + objToSave, test
0628: .equals(objLoaded));
0629:
0630: } catch (IOException e) {
0631: fail("IOException serializing " + objToSave + " : "
0632: + e.getMessage());
0633: } catch (ClassNotFoundException e) {
0634: fail("ClassNotFoundException reading Object type : "
0635: + e.getMessage());
0636: } catch (Error err) {
0637: System.out.println("Error when obj = " + objToSave);
0638: // err.printStackTrace();
0639: throw err;
0640: }
0641: }
0642:
0643: public void test_18_90_writeObject() {
0644: // Test for method void
0645: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0646:
0647: Object objToSave = null;
0648: Object objLoaded;
0649:
0650: try {
0651: objToSave = TABLE;
0652: if (DEBUG)
0653: System.out.println("Obj = " + objToSave);
0654: objLoaded = dumpAndReload(objToSave);
0655: // Has to have worked
0656: assertTrue(MSG_TEST_FAILED + objToSave, TABLE
0657: .equals(objLoaded));
0658:
0659: } catch (IOException e) {
0660: fail("IOException serializing " + objToSave + " : "
0661: + e.getMessage());
0662: } catch (ClassNotFoundException e) {
0663: fail("ClassNotFoundException reading Object type : "
0664: + e.getMessage());
0665: } catch (Error err) {
0666: System.out.println("Error when obj = " + objToSave);
0667: // err.printStackTrace();
0668: throw err;
0669: }
0670: }
0671:
0672: public void test_18_91_writeObject() {
0673: // Test for method void
0674: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0675:
0676: Object objToSave = null;
0677: Object objLoaded;
0678:
0679: try {
0680: Object col = Collections.synchronizedMap(TABLE);
0681: objToSave = col;
0682: if (DEBUG)
0683: System.out.println("Obj = " + objToSave);
0684: objLoaded = dumpAndReload(objToSave);
0685: // Has to have worked
0686: assertTrue(MSG_TEST_FAILED + objToSave, col
0687: .equals(objLoaded));
0688:
0689: } catch (IOException e) {
0690: fail("IOException serializing " + objToSave + " : "
0691: + e.getMessage());
0692: } catch (ClassNotFoundException e) {
0693: fail("ClassNotFoundException reading Object type : "
0694: + e.getMessage());
0695: } catch (Error err) {
0696: System.out.println("Error when obj = " + objToSave);
0697: // err.printStackTrace();
0698: throw err;
0699: }
0700: }
0701:
0702: public void test_18_92_writeObject() {
0703: // Test for method void
0704: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0705:
0706: Object objToSave = null;
0707: Object objLoaded;
0708:
0709: try {
0710: Object col = Collections.unmodifiableMap(TABLE);
0711: objToSave = col;
0712: if (DEBUG)
0713: System.out.println("Obj = " + objToSave);
0714: objLoaded = dumpAndReload(objToSave);
0715: // Has to have worked
0716: assertTrue(MSG_TEST_FAILED + objToSave, col
0717: .equals(objLoaded));
0718:
0719: } catch (IOException e) {
0720: fail("IOException serializing " + objToSave + " : "
0721: + e.getMessage());
0722: } catch (ClassNotFoundException e) {
0723: fail("ClassNotFoundException reading Object type : "
0724: + e.getMessage());
0725: } catch (Error err) {
0726: System.out.println("Error when obj = " + objToSave);
0727: // err.printStackTrace();
0728: throw err;
0729: }
0730: }
0731:
0732: public void test_18_93_writeObject() {
0733: // Test for method void
0734: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0735:
0736: Object objToSave = null;
0737: Object objLoaded;
0738:
0739: try {
0740: objToSave = MAP;
0741: if (DEBUG)
0742: System.out.println("Obj = " + objToSave);
0743: objLoaded = dumpAndReload(objToSave);
0744: // Has to have worked
0745: assertTrue(MSG_TEST_FAILED + objToSave, MAP
0746: .equals(objLoaded));
0747:
0748: } catch (IOException e) {
0749: fail("IOException serializing " + objToSave + " : "
0750: + e.getMessage());
0751: } catch (ClassNotFoundException e) {
0752: fail("ClassNotFoundException reading Object type : "
0753: + e.getMessage());
0754: } catch (Error err) {
0755: System.out.println("Error when obj = " + objToSave);
0756: // err.printStackTrace();
0757: throw err;
0758: }
0759: }
0760:
0761: public void test_18_94_writeObject() {
0762: // Test for method void
0763: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0764:
0765: Object objToSave = null;
0766: Object objLoaded;
0767:
0768: try {
0769: Object col = Collections.synchronizedMap(MAP);
0770: objToSave = col;
0771: if (DEBUG)
0772: System.out.println("Obj = " + objToSave);
0773: objLoaded = dumpAndReload(objToSave);
0774: // Has to have worked
0775: assertTrue(MSG_TEST_FAILED + objToSave, col
0776: .equals(objLoaded));
0777:
0778: } catch (IOException e) {
0779: fail("IOException serializing " + objToSave + " : "
0780: + e.getMessage());
0781: } catch (ClassNotFoundException e) {
0782: fail("ClassNotFoundException reading Object type : "
0783: + e.getMessage());
0784: } catch (Error err) {
0785: System.out.println("Error when obj = " + objToSave);
0786: // err.printStackTrace();
0787: throw err;
0788: }
0789: }
0790:
0791: public void test_18_95_writeObject() {
0792: // Test for method void
0793: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0794:
0795: Object objToSave = null;
0796: Object objLoaded;
0797:
0798: try {
0799: Object col = Collections.unmodifiableMap(MAP);
0800: objToSave = col;
0801: if (DEBUG)
0802: System.out.println("Obj = " + objToSave);
0803: objLoaded = dumpAndReload(objToSave);
0804: // Has to have worked
0805: assertTrue(MSG_TEST_FAILED + objToSave, col
0806: .equals(objLoaded));
0807:
0808: } catch (IOException e) {
0809: fail("IOException serializing " + objToSave + " : "
0810: + e.getMessage());
0811: } catch (ClassNotFoundException e) {
0812: fail("ClassNotFoundException reading Object type : "
0813: + e.getMessage());
0814: } catch (Error err) {
0815: System.out.println("Error when obj = " + objToSave);
0816: // err.printStackTrace();
0817: throw err;
0818: }
0819: }
0820:
0821: public void test_18_96_writeObject() {
0822: // Test for method void
0823: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0824:
0825: Object objToSave = null;
0826: Object objLoaded;
0827:
0828: try {
0829: objToSave = ALIST;
0830: if (DEBUG)
0831: System.out.println("Obj = " + objToSave);
0832: objLoaded = dumpAndReload(objToSave);
0833: // Has to have worked
0834: assertTrue(MSG_TEST_FAILED + objToSave, ALIST
0835: .equals(objLoaded));
0836:
0837: } catch (IOException e) {
0838: fail("IOException serializing " + objToSave + " : "
0839: + e.getMessage());
0840: } catch (ClassNotFoundException e) {
0841: fail("ClassNotFoundException reading Object type : "
0842: + e.getMessage());
0843: } catch (Error err) {
0844: System.out.println("Error when obj = " + objToSave);
0845: // err.printStackTrace();
0846: throw err;
0847: }
0848: }
0849:
0850: public void test_18_97_writeObject() {
0851: // Test for method void
0852: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0853:
0854: Object objToSave = null;
0855: Object objLoaded;
0856:
0857: try {
0858: objToSave = LIST;
0859: if (DEBUG)
0860: System.out.println("Obj = " + objToSave);
0861: objLoaded = dumpAndReload(objToSave);
0862: // Has to have worked
0863: assertTrue(MSG_TEST_FAILED + objToSave, LIST
0864: .equals(objLoaded));
0865:
0866: } catch (IOException e) {
0867: fail("IOException serializing " + objToSave + " : "
0868: + e.getMessage());
0869: } catch (ClassNotFoundException e) {
0870: fail("ClassNotFoundException reading Object type : "
0871: + e.getMessage());
0872: } catch (Error err) {
0873: System.out.println("Error when obj = " + objToSave);
0874: // err.printStackTrace();
0875: throw err;
0876: }
0877: }
0878:
0879: public void test_18_98_writeObject() {
0880: // Test for method void
0881: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0882:
0883: Object objToSave = null;
0884: Object objLoaded;
0885:
0886: try {
0887: Object col = Collections.synchronizedList(LIST);
0888: objToSave = col;
0889: if (DEBUG)
0890: System.out.println("Obj = " + objToSave);
0891: objLoaded = dumpAndReload(objToSave);
0892: // Has to have worked
0893: assertTrue(MSG_TEST_FAILED + objToSave, col
0894: .equals(objLoaded));
0895:
0896: } catch (IOException e) {
0897: fail("IOException serializing " + objToSave + " : "
0898: + e.getMessage());
0899: } catch (ClassNotFoundException e) {
0900: fail("ClassNotFoundException reading Object type : "
0901: + e.getMessage());
0902: } catch (Error err) {
0903: System.out.println("Error when obj = " + objToSave);
0904: // err.printStackTrace();
0905: throw err;
0906: }
0907: }
0908:
0909: public void test_18_99_writeObject() {
0910: // Test for method void
0911: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0912:
0913: Object objToSave = null;
0914: Object objLoaded;
0915:
0916: try {
0917: Object col = Collections.unmodifiableList(LIST);
0918: objToSave = col;
0919: if (DEBUG)
0920: System.out.println("Obj = " + objToSave);
0921: objLoaded = dumpAndReload(objToSave);
0922: // Has to have worked
0923: assertTrue(MSG_TEST_FAILED + objToSave, col
0924: .equals(objLoaded));
0925:
0926: } catch (IOException e) {
0927: fail("IOException serializing " + objToSave + " : "
0928: + e.getMessage());
0929: } catch (ClassNotFoundException e) {
0930: fail("ClassNotFoundException reading Object type : "
0931: + e.getMessage());
0932: } catch (Error err) {
0933: System.out.println("Error when obj = " + objToSave);
0934: // err.printStackTrace();
0935: throw err;
0936: }
0937: }
0938:
0939: public void test_18_100_writeObject() {
0940: // Test for method void
0941: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0942:
0943: Object objToSave = null;
0944: Object objLoaded;
0945:
0946: try {
0947: objToSave = SET;
0948: if (DEBUG)
0949: System.out.println("Obj = " + objToSave);
0950: objLoaded = dumpAndReload(objToSave);
0951: // Has to have worked
0952: assertTrue(MSG_TEST_FAILED + objToSave, SET
0953: .equals(objLoaded));
0954:
0955: } catch (IOException e) {
0956: fail("IOException serializing " + objToSave + " : "
0957: + e.getMessage());
0958: } catch (ClassNotFoundException e) {
0959: fail("ClassNotFoundException reading Object type : "
0960: + e.getMessage());
0961: } catch (Error err) {
0962: System.out.println("Error when obj = " + objToSave);
0963: // err.printStackTrace();
0964: throw err;
0965: }
0966: }
0967:
0968: public void test_18_101_writeObject() {
0969: // Test for method void
0970: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
0971:
0972: Object objToSave = null;
0973: Object objLoaded;
0974:
0975: try {
0976: Object col = Collections.synchronizedSet(SET);
0977: objToSave = col;
0978: if (DEBUG)
0979: System.out.println("Obj = " + objToSave);
0980: objLoaded = dumpAndReload(objToSave);
0981: // Has to have worked
0982: assertTrue(MSG_TEST_FAILED + objToSave, col
0983: .equals(objLoaded));
0984:
0985: } catch (IOException e) {
0986: fail("IOException serializing " + objToSave + " : "
0987: + e.getMessage());
0988: } catch (ClassNotFoundException e) {
0989: fail("ClassNotFoundException reading Object type : "
0990: + e.getMessage());
0991: } catch (Error err) {
0992: System.out.println("Error when obj = " + objToSave);
0993: // err.printStackTrace();
0994: throw err;
0995: }
0996: }
0997:
0998: public void test_18_102_writeObject() {
0999: // Test for method void
1000: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1001:
1002: Object objToSave = null;
1003: Object objLoaded;
1004:
1005: try {
1006: Object col = Collections.unmodifiableSet(SET);
1007: objToSave = col;
1008: if (DEBUG)
1009: System.out.println("Obj = " + objToSave);
1010: objLoaded = dumpAndReload(objToSave);
1011: // Has to have worked
1012: assertTrue(MSG_TEST_FAILED + objToSave, col
1013: .equals(objLoaded));
1014:
1015: } catch (IOException e) {
1016: fail("IOException serializing " + objToSave + " : "
1017: + e.getMessage());
1018: } catch (ClassNotFoundException e) {
1019: fail("ClassNotFoundException reading Object type : "
1020: + e.getMessage());
1021: } catch (Error err) {
1022: System.out.println("Error when obj = " + objToSave);
1023: // err.printStackTrace();
1024: throw err;
1025: }
1026: }
1027:
1028: public void test_18_103_writeObject() {
1029: // Test for method void
1030: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1031:
1032: Object objToSave = null;
1033: Object objLoaded;
1034:
1035: try {
1036: objToSave = TREE;
1037: if (DEBUG)
1038: System.out.println("Obj = " + objToSave);
1039: objLoaded = dumpAndReload(objToSave);
1040: // Has to have worked
1041: assertTrue(MSG_TEST_FAILED + objToSave, TREE
1042: .equals(objLoaded));
1043:
1044: } catch (IOException e) {
1045: fail("IOException serializing " + objToSave + " : "
1046: + e.getMessage());
1047: } catch (ClassNotFoundException e) {
1048: fail("ClassNotFoundException reading Object type : "
1049: + e.getMessage());
1050: } catch (Error err) {
1051: System.out.println("Error when obj = " + objToSave);
1052: // err.printStackTrace();
1053: throw err;
1054: }
1055: }
1056:
1057: public void test_18_104_writeObject() {
1058: // Test for method void
1059: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1060:
1061: Object objToSave = null;
1062: Object objLoaded;
1063:
1064: try {
1065: Object col = Collections.synchronizedSortedMap(TREE);
1066: objToSave = col;
1067: if (DEBUG)
1068: System.out.println("Obj = " + objToSave);
1069: objLoaded = dumpAndReload(objToSave);
1070: // Has to have worked
1071: assertTrue(MSG_TEST_FAILED + objToSave, col
1072: .equals(objLoaded));
1073:
1074: } catch (IOException e) {
1075: fail("IOException serializing " + objToSave + " : "
1076: + e.getMessage());
1077: } catch (ClassNotFoundException e) {
1078: fail("ClassNotFoundException reading Object type : "
1079: + e.getMessage());
1080: } catch (Error err) {
1081: System.out.println("Error when obj = " + objToSave);
1082: // err.printStackTrace();
1083: throw err;
1084: }
1085: }
1086:
1087: public void test_18_105_writeObject() {
1088: // Test for method void
1089: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1090:
1091: Object objToSave = null;
1092: Object objLoaded;
1093:
1094: try {
1095: Object col = Collections.unmodifiableSortedMap(TREE);
1096: objToSave = col;
1097: if (DEBUG)
1098: System.out.println("Obj = " + objToSave);
1099: objLoaded = dumpAndReload(objToSave);
1100: // Has to have worked
1101: assertTrue(MSG_TEST_FAILED + objToSave, col
1102: .equals(objLoaded));
1103:
1104: } catch (IOException e) {
1105: fail("IOException serializing " + objToSave + " : "
1106: + e.getMessage());
1107: } catch (ClassNotFoundException e) {
1108: fail("ClassNotFoundException reading Object type : "
1109: + e.getMessage());
1110: } catch (Error err) {
1111: System.out.println("Error when obj = " + objToSave);
1112: // err.printStackTrace();
1113: throw err;
1114: }
1115: }
1116:
1117: public void test_18_106_writeObject() {
1118: // Test for method void
1119: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1120:
1121: Object objToSave = null;
1122: Object objLoaded;
1123:
1124: try {
1125: objToSave = SORTSET;
1126: if (DEBUG)
1127: System.out.println("Obj = " + objToSave);
1128: objLoaded = dumpAndReload(objToSave);
1129: // Has to have worked
1130: assertTrue(MSG_TEST_FAILED + objToSave, SET
1131: .equals(objLoaded));
1132:
1133: } catch (IOException e) {
1134: fail("IOException serializing " + objToSave + " : "
1135: + e.getMessage());
1136: } catch (ClassNotFoundException e) {
1137: fail("ClassNotFoundException reading Object type : "
1138: + e.getMessage());
1139: } catch (Error err) {
1140: System.out.println("Error when obj = " + objToSave);
1141: // err.printStackTrace();
1142: throw err;
1143: }
1144: }
1145:
1146: public void test_18_107_writeObject() {
1147: // Test for method void
1148: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1149:
1150: Object objToSave = null;
1151: Object objLoaded;
1152:
1153: try {
1154: Object col = Collections.synchronizedSortedSet(SORTSET);
1155: objToSave = col;
1156: if (DEBUG)
1157: System.out.println("Obj = " + objToSave);
1158: objLoaded = dumpAndReload(objToSave);
1159: // Has to have worked
1160: assertTrue(MSG_TEST_FAILED + objToSave, col
1161: .equals(objLoaded));
1162:
1163: } catch (IOException e) {
1164: fail("IOException serializing " + objToSave + " : "
1165: + e.getMessage());
1166: } catch (ClassNotFoundException e) {
1167: fail("ClassNotFoundException reading Object type : "
1168: + e.getMessage());
1169: } catch (Error err) {
1170: System.out.println("Error when obj = " + objToSave);
1171: // err.printStackTrace();
1172: throw err;
1173: }
1174: }
1175:
1176: public void test_18_108_writeObject() {
1177: // Test for method void
1178: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1179:
1180: Object objToSave = null;
1181: Object objLoaded;
1182:
1183: try {
1184: Object col = Collections.unmodifiableSortedSet(SORTSET);
1185: objToSave = col;
1186: if (DEBUG)
1187: System.out.println("Obj = " + objToSave);
1188: objLoaded = dumpAndReload(objToSave);
1189: // Has to have worked
1190: assertTrue(MSG_TEST_FAILED + objToSave, col
1191: .equals(objLoaded));
1192:
1193: } catch (IOException e) {
1194: fail("IOException serializing " + objToSave + " : "
1195: + e.getMessage());
1196: } catch (ClassNotFoundException e) {
1197: fail("ClassNotFoundException reading Object type : "
1198: + e.getMessage());
1199: } catch (Error err) {
1200: System.out.println("Error when obj = " + objToSave);
1201: // err.printStackTrace();
1202: throw err;
1203: }
1204: }
1205:
1206: public void test_18_109_writeObject() {
1207: // Test for method void
1208: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1209:
1210: Object objToSave = null;
1211: Object objLoaded;
1212:
1213: try {
1214: objToSave = CALENDAR;
1215: if (DEBUG)
1216: System.out.println("Obj = " + objToSave);
1217: objLoaded = dumpAndReload(objToSave);
1218: // Has to have worked
1219: assertTrue(MSG_TEST_FAILED + objToSave, CALENDAR
1220: .equals(objLoaded));
1221:
1222: } catch (IOException e) {
1223: fail("IOException serializing " + objToSave + " : "
1224: + e.getMessage());
1225: } catch (ClassNotFoundException e) {
1226: fail("ClassNotFoundException reading Object type : "
1227: + e.getMessage());
1228: } catch (Error err) {
1229: System.out.println("Error when obj = " + objToSave);
1230: // err.printStackTrace();
1231: throw err;
1232: }
1233: }
1234:
1235: public void test_18_110_writeObject() {
1236: // Test for method void
1237: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1238:
1239: Object objToSave = null;
1240: Object objLoaded;
1241:
1242: try {
1243: TimeZone test = TimeZone.getTimeZone("EST");
1244: objToSave = test;
1245: if (DEBUG)
1246: System.out.println("Obj = " + objToSave);
1247: objLoaded = dumpAndReload(objToSave);
1248: // Has to have worked
1249: assertTrue(MSG_TEST_FAILED + objToSave, test
1250: .equals(objLoaded));
1251:
1252: } catch (IOException e) {
1253: fail("IOException serializing " + objToSave + " : "
1254: + e.getMessage());
1255: } catch (ClassNotFoundException e) {
1256: fail("ClassNotFoundException reading Object type : "
1257: + e.getMessage());
1258: } catch (Error err) {
1259: System.out.println("Error when obj = " + objToSave);
1260: // err.printStackTrace();
1261: throw err;
1262: }
1263: }
1264:
1265: public void test_18_111_writeObject() {
1266: // Test for method void
1267: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1268:
1269: Object objToSave = null;
1270: Object objLoaded;
1271:
1272: try {
1273: TimeZone test = TimeZone.getTimeZone("EST");
1274: objToSave = test;
1275: if (DEBUG)
1276: System.out.println("Obj = " + objToSave);
1277: objLoaded = dumpAndReload(objToSave);
1278: // Has to have worked
1279: assertTrue(MSG_TEST_FAILED + objToSave, test
1280: .equals(objLoaded));
1281:
1282: } catch (IOException e) {
1283: fail("IOException serializing " + objToSave + " : "
1284: + e.getMessage());
1285: } catch (ClassNotFoundException e) {
1286: fail("ClassNotFoundException reading Object type : "
1287: + e.getMessage());
1288: } catch (Error err) {
1289: System.out.println("Error when obj = " + objToSave);
1290: // err.printStackTrace();
1291: throw err;
1292: }
1293: }
1294:
1295: public void test_18_112_writeObject() {
1296: // Test for method void
1297: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1298:
1299: Object objToSave = null;
1300: Object objLoaded;
1301:
1302: try {
1303: TimeZone test = TimeZone.getTimeZone("GMT");
1304: objToSave = test;
1305: if (DEBUG)
1306: System.out.println("Obj = " + objToSave);
1307: objLoaded = dumpAndReload(objToSave);
1308: // Has to have worked
1309: assertTrue(MSG_TEST_FAILED + objToSave, test
1310: .equals(objLoaded));
1311:
1312: } catch (IOException e) {
1313: fail("IOException serializing " + objToSave + " : "
1314: + e.getMessage());
1315: } catch (ClassNotFoundException e) {
1316: fail("ClassNotFoundException reading Object type : "
1317: + e.getMessage());
1318: } catch (Error err) {
1319: System.out.println("Error when obj = " + objToSave);
1320: // err.printStackTrace();
1321: throw err;
1322: }
1323: }
1324:
1325: public void test_18_113_writeObject() {
1326: // Test for method void
1327: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1328:
1329: Object objToSave = null;
1330: Object objLoaded;
1331:
1332: try {
1333: objToSave = DATEFORM;
1334: if (DEBUG)
1335: System.out.println("Obj = " + objToSave);
1336: objLoaded = dumpAndReload(objToSave);
1337: // Has to have worked
1338: assertTrue(MSG_TEST_FAILED + objToSave, DATEFORM
1339: .equals(objLoaded));
1340:
1341: } catch (IOException e) {
1342: fail("IOException serializing " + objToSave + " : "
1343: + e.getMessage());
1344: } catch (ClassNotFoundException e) {
1345: fail("ClassNotFoundException reading Object type : "
1346: + e.getMessage());
1347: } catch (Error err) {
1348: System.out.println("Error when obj = " + objToSave);
1349: // err.printStackTrace();
1350: throw err;
1351: }
1352: }
1353:
1354: public void test_18_114_writeObject() {
1355: // Test for method void
1356: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1357:
1358: Object objToSave = null;
1359: Object objLoaded;
1360:
1361: try {
1362: objToSave = CHOICE;
1363: if (DEBUG)
1364: System.out.println("Obj = " + objToSave);
1365: objLoaded = dumpAndReload(objToSave);
1366: // Has to have worked
1367: assertTrue(MSG_TEST_FAILED + objToSave, CHOICE
1368: .equals(objLoaded));
1369:
1370: } catch (IOException e) {
1371: fail("IOException serializing " + objToSave + " : "
1372: + e.getMessage());
1373: } catch (ClassNotFoundException e) {
1374: fail("ClassNotFoundException reading Object type : "
1375: + e.getMessage());
1376: } catch (Error err) {
1377: System.out.println("Error when obj = " + objToSave);
1378: // err.printStackTrace();
1379: throw err;
1380: }
1381: }
1382:
1383: public void test_18_115_writeObject() {
1384: // Test for method void
1385: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1386:
1387: Object objToSave = null;
1388: Object objLoaded;
1389:
1390: try {
1391: objToSave = NUMBERFORM;
1392: if (DEBUG)
1393: System.out.println("Obj = " + objToSave);
1394: objLoaded = dumpAndReload(objToSave);
1395: // Has to have worked
1396: assertTrue(MSG_TEST_FAILED + objToSave, NUMBERFORM
1397: .equals(objLoaded));
1398:
1399: } catch (IOException e) {
1400: fail("IOException serializing " + objToSave + " : "
1401: + e.getMessage());
1402: } catch (ClassNotFoundException e) {
1403: fail("ClassNotFoundException reading Object type : "
1404: + e.getMessage());
1405: } catch (Error err) {
1406: System.out.println("Error when obj = " + objToSave);
1407: // err.printStackTrace();
1408: throw err;
1409: }
1410: }
1411:
1412: public void test_18_116_writeObject() {
1413: // Test for method void
1414: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1415:
1416: Object objToSave = null;
1417: Object objLoaded;
1418:
1419: try {
1420: objToSave = MESSAGE;
1421: if (DEBUG)
1422: System.out.println("Obj = " + objToSave);
1423: objLoaded = dumpAndReload(objToSave);
1424: // Has to have worked
1425: assertTrue(MSG_TEST_FAILED + objToSave, MESSAGE.toPattern()
1426: .equals(
1427: ((java.text.MessageFormat) objLoaded)
1428: .toPattern()));
1429:
1430: } catch (IOException e) {
1431: fail("IOException serializing " + objToSave + " : "
1432: + e.getMessage());
1433: } catch (ClassNotFoundException e) {
1434: fail("ClassNotFoundException reading Object type : "
1435: + e.getMessage());
1436: } catch (Error err) {
1437: System.out.println("Error when obj = " + objToSave);
1438: // err.printStackTrace();
1439: throw err;
1440: }
1441: }
1442:
1443: public void test_18_117_writeObject() {
1444: // Test for method void
1445: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1446:
1447: Object objToSave = null;
1448: Object objLoaded;
1449:
1450: try {
1451: objToSave = PERM;
1452: if (DEBUG)
1453: System.out.println("Obj = " + objToSave);
1454: objLoaded = dumpAndReload(objToSave);
1455: // Has to have worked
1456: assertTrue(MSG_TEST_FAILED + objToSave, PERM
1457: .equals(objLoaded));
1458:
1459: } catch (IOException e) {
1460: fail("IOException serializing " + objToSave + " : "
1461: + e.getMessage());
1462: } catch (ClassNotFoundException e) {
1463: fail("ClassNotFoundException reading Object type : "
1464: + e.getMessage());
1465: } catch (Error err) {
1466: System.out.println("Error when obj = " + objToSave);
1467: // err.printStackTrace();
1468: throw err;
1469: }
1470: }
1471:
1472: public void test_18_118_writeObject() {
1473: // Test for method void
1474: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1475:
1476: Object objToSave = null;
1477: Object objLoaded;
1478:
1479: try {
1480: objToSave = PERMCOL;
1481: Enumeration elementsBefore = PERMCOL.elements();
1482: if (DEBUG)
1483: System.out.println("Obj = " + objToSave);
1484: objLoaded = dumpAndReload(objToSave);
1485: // Has to have worked
1486: Enumeration elementsAfter = ((PermissionCollection) objLoaded)
1487: .elements();
1488: boolean equals = true;
1489: while (elementsBefore.hasMoreElements()) {
1490: // To make sure elements are the same
1491: Object oBefore = elementsBefore.nextElement();
1492: Object oAfter = elementsAfter.nextElement();
1493: equals &= oBefore.equals(oAfter);
1494:
1495: }
1496: // To make sure sizes are the same
1497: equals &= elementsBefore.hasMoreElements() == elementsAfter
1498: .hasMoreElements();
1499:
1500: assertTrue(MSG_TEST_FAILED + objToSave, equals);
1501:
1502: } catch (IOException e) {
1503: fail("IOException serializing " + objToSave + " : "
1504: + e.getMessage());
1505: } catch (ClassNotFoundException e) {
1506: fail("ClassNotFoundException reading Object type : "
1507: + e.getMessage());
1508: } catch (Error err) {
1509: System.out.println("Error when obj = " + objToSave);
1510: // err.printStackTrace();
1511: throw err;
1512: }
1513: }
1514:
1515: public void test_18_119_writeObject() {
1516: // Test for method void
1517: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1518:
1519: Object objToSave = null;
1520: Object objLoaded;
1521:
1522: try {
1523: objToSave = Locale.CHINESE;
1524: if (DEBUG)
1525: System.out.println("Obj = " + objToSave);
1526: objLoaded = dumpAndReload(objToSave);
1527: // Has to have worked
1528: assertTrue(MSG_TEST_FAILED + objToSave, Locale.CHINESE
1529: .equals(objLoaded));
1530:
1531: } catch (IOException e) {
1532: fail("IOException serializing " + objToSave + " : "
1533: + e.getMessage());
1534: } catch (ClassNotFoundException e) {
1535: fail("ClassNotFoundException reading Object type : "
1536: + e.getMessage());
1537: } catch (Error err) {
1538: System.out.println("Error when obj = " + objToSave);
1539: // err.printStackTrace();
1540: throw err;
1541: }
1542: }
1543:
1544: public void test_18_120_writeObject() {
1545: // Test for method void
1546: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1547:
1548: Object objToSave = null;
1549: Object objLoaded;
1550:
1551: try {
1552: objToSave = LINKEDLIST;
1553: if (DEBUG)
1554: System.out.println("Obj = " + objToSave);
1555: objLoaded = dumpAndReload(objToSave);
1556: // Has to have worked
1557: assertTrue(MSG_TEST_FAILED + objToSave, LINKEDLIST
1558: .equals(objLoaded));
1559:
1560: } catch (IOException e) {
1561: fail("IOException serializing " + objToSave + " : "
1562: + e.getMessage());
1563: } catch (ClassNotFoundException e) {
1564: fail("ClassNotFoundException reading Object type : "
1565: + e.getMessage());
1566: } catch (Error err) {
1567: System.out.println("Error when obj = " + objToSave);
1568: // err.printStackTrace();
1569: throw err;
1570: }
1571: }
1572:
1573: public void test_18_121_writeObject() {
1574: // Test for method void
1575: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1576:
1577: Object objToSave = null;
1578: Object objLoaded;
1579:
1580: try {
1581: objToSave = java.text.AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT;
1582: if (DEBUG)
1583: System.out.println("Obj = " + objToSave);
1584: objLoaded = dumpAndReload(objToSave);
1585: // Has to have worked
1586: assertTrue(
1587: MSG_TEST_FAILED + objToSave,
1588: java.text.AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT == objLoaded);
1589:
1590: } catch (IOException e) {
1591: fail("IOException serializing " + objToSave + " : "
1592: + e.getMessage());
1593: } catch (ClassNotFoundException e) {
1594: fail("ClassNotFoundException reading Object type : "
1595: + e.getMessage());
1596: } catch (Error err) {
1597: System.out.println("Error when obj = " + objToSave);
1598: // err.printStackTrace();
1599: throw err;
1600: }
1601: }
1602:
1603: public void test_18_122_writeObject() {
1604: // Test for method void
1605: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1606:
1607: Object objToSave = null;
1608: Object objLoaded;
1609:
1610: try {
1611: objToSave = java.text.AttributedCharacterIterator.Attribute.LANGUAGE;
1612: if (DEBUG)
1613: System.out.println("Obj = " + objToSave);
1614: objLoaded = dumpAndReload(objToSave);
1615: // Has to have worked
1616: assertTrue(
1617: MSG_TEST_FAILED + objToSave,
1618: java.text.AttributedCharacterIterator.Attribute.LANGUAGE == objLoaded);
1619:
1620: } catch (IOException e) {
1621: fail("IOException serializing " + objToSave + " : "
1622: + e.getMessage());
1623: } catch (ClassNotFoundException e) {
1624: fail("ClassNotFoundException reading Object type : "
1625: + e.getMessage());
1626: } catch (Error err) {
1627: System.out.println("Error when obj = " + objToSave);
1628: // err.printStackTrace();
1629: throw err;
1630: }
1631: }
1632:
1633: public void test_18_123_writeObject() {
1634: // Test for method void
1635: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1636:
1637: Object objToSave = null;
1638: Object objLoaded;
1639:
1640: try {
1641: objToSave = java.text.AttributedCharacterIterator.Attribute.READING;
1642: if (DEBUG)
1643: System.out.println("Obj = " + objToSave);
1644: objLoaded = dumpAndReload(objToSave);
1645: // Has to have worked
1646: assertTrue(
1647: MSG_TEST_FAILED + objToSave,
1648: java.text.AttributedCharacterIterator.Attribute.READING == objLoaded);
1649:
1650: } catch (IOException e) {
1651: fail("IOException serializing " + objToSave + " : "
1652: + e.getMessage());
1653: } catch (ClassNotFoundException e) {
1654: fail("ClassNotFoundException reading Object type : "
1655: + e.getMessage());
1656: } catch (Error err) {
1657: System.out.println("Error when obj = " + objToSave);
1658: // err.printStackTrace();
1659: throw err;
1660: }
1661: }
1662:
1663: public void test_18_124_writeObject() {
1664: // Test for method void
1665: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1666:
1667: Object objToSave = null;
1668: Object objLoaded;
1669:
1670: try {
1671: objToSave = new Object[] { Integer.class, new Integer(1) };
1672: if (DEBUG)
1673: System.out.println("Obj = " + objToSave);
1674: objLoaded = dumpAndReload(objToSave);
1675: // Classes with the same name are unique, so test for ==
1676: assertTrue(
1677: MSG_TEST_FAILED + objToSave,
1678: ((Object[]) objLoaded)[0] == ((Object[]) objToSave)[0]
1679: && ((Object[]) objLoaded)[1]
1680: .equals(((Object[]) objToSave)[1]));
1681:
1682: } catch (IOException e) {
1683: fail("IOException serializing " + objToSave + " : "
1684: + e.getMessage());
1685: } catch (ClassNotFoundException e) {
1686: fail("ClassNotFoundException reading Object type : "
1687: + e.getMessage());
1688: } catch (Error err) {
1689: System.out.println("Error when obj = " + objToSave);
1690: // err.printStackTrace();
1691: throw err;
1692: }
1693: }
1694:
1695: public void test_18_125_writeObject() {
1696: // Test for method void
1697: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1698:
1699: Object objToSave = null;
1700: Object objLoaded;
1701:
1702: try {
1703: objToSave = new BigInteger[] { BigInteger.ZERO,
1704: BigInteger.ONE, BigInteger.valueOf(-1),
1705: BigInteger.valueOf(255), BigInteger.valueOf(-255),
1706: new BigInteger("75881644843307850793466070"),
1707: new BigInteger("-636104487142732527326202462") };
1708: if (DEBUG)
1709: System.out.println("Obj = " + objToSave);
1710: objLoaded = dumpAndReload(objToSave);
1711: assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals(
1712: (BigInteger[]) objLoaded, (BigInteger[]) objToSave));
1713:
1714: } catch (IOException e) {
1715: fail("IOException serializing " + objToSave + " : "
1716: + e.getMessage());
1717: } catch (ClassNotFoundException e) {
1718: fail("ClassNotFoundException reading Object type : "
1719: + e.getMessage());
1720: } catch (Error err) {
1721: System.out.println("Error when obj = " + objToSave);
1722: // err.printStackTrace();
1723: throw err;
1724: }
1725: }
1726:
1727: public void test_18_126_writeObject() {
1728: // Test for method void
1729: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1730:
1731: Object objToSave = null;
1732: Object objLoaded;
1733:
1734: try {
1735: objToSave = new WriteFieldsUsingPutFieldWrite();
1736: if (DEBUG)
1737: System.out.println("Obj = " + objToSave);
1738: objLoaded = dumpAndReload(objToSave);
1739: assertTrue(MSG_TEST_FAILED + objToSave,
1740: ((WriteFieldsUsingPutFieldWrite) objLoaded)
1741: .passed());
1742:
1743: } catch (IOException e) {
1744: fail("IOException serializing " + objToSave + " : "
1745: + e.getMessage());
1746: } catch (ClassNotFoundException e) {
1747: fail("ClassNotFoundException reading Object type : "
1748: + e.getMessage());
1749: } catch (Error err) {
1750: System.out.println("Error when obj = " + objToSave);
1751: // err.printStackTrace();
1752: throw err;
1753: }
1754: }
1755:
1756: public void test_18_127_writeObject() {
1757: // Test for method void
1758: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1759:
1760: Object objToSave = null;
1761: Object objLoaded;
1762:
1763: try {
1764: BitSet bs = new BitSet(64);
1765: bs.set(1);
1766: bs.set(10);
1767: bs.set(100);
1768: bs.set(1000);
1769: objToSave = bs;
1770: if (DEBUG)
1771: System.out.println("Obj = " + objToSave);
1772: objLoaded = dumpAndReload(objToSave);
1773: assertTrue(MSG_TEST_FAILED + objToSave, bs
1774: .equals(objLoaded));
1775:
1776: } catch (IOException e) {
1777: fail("IOException serializing " + objToSave + " : "
1778: + e.getMessage());
1779: } catch (ClassNotFoundException e) {
1780: fail("ClassNotFoundException reading Object type : "
1781: + e.getMessage());
1782: } catch (Error err) {
1783: System.out.println("Error when obj = " + objToSave);
1784: // err.printStackTrace();
1785: throw err;
1786: }
1787: }
1788:
1789: public void test_18_128_writeObject() {
1790: // Test for method void
1791: // java.io.ObjectOutputStream.writeObject(java.lang.Object)
1792:
1793: Object objToSave = null;
1794: Object objLoaded;
1795:
1796: try {
1797: PropertyPermission test = new PropertyPermission("java.*",
1798: "read,write");
1799: PermissionCollection p = test.newPermissionCollection();
1800: p.add(new PropertyPermission("java.*", "read"));
1801: p.add(new PropertyPermission("java.*", "write"));
1802: // System.out.println("Does implies work? " + p.implies(test));
1803:
1804: objToSave = p;
1805: if (DEBUG)
1806: System.out.println("Obj = " + objToSave);
1807: objLoaded = dumpAndReload(objToSave);
1808: assertTrue(MSG_TEST_FAILED + objToSave,
1809: ((PermissionCollection) objLoaded).implies(test));
1810:
1811: } catch (IOException e) {
1812: fail("IOException serializing " + objToSave + " : "
1813: + 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: }
|