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 package org.apache.harmony.luni.tests.java.io; 18 19 import java.io.ByteArrayInputStream; 20 import java.io.ByteArrayOutputStream; 21 import java.io.DataOutputStream; 22 import java.io.IOException; 23 import java.io.ObjectInputStream; 24 import java.io.ObjectOutputStream; 25 import java.io.ObjectStreamConstants; 26 import java.io.ObjectStreamField; 27 import java.io.OptionalDataException; 28 import java.math.BigInteger; 29 import java.security.PermissionCollection; 30 import java.util.Arrays; 31 import java.util.BitSet; 32 import java.util.Collections; 33 import java.util.Enumeration; 34 import java.util.Locale; 35 import java.util.PropertyPermission; 36 import java.util.TimeZone; 37 import java.util.Vector; 38 39 40 @SuppressWarnings( { "serial", "unused" }) 41 public class SerializationStressTest3 extends SerializationStressTest { 42 43 // ----------------------------------------------------------------------------------- 44 private static class DefaultConstructor implements java.io.Serializable { 45 int f1; 46 47 static int valueAfterConstructor = 5; 48 49 DefaultConstructor() { 50 f1 = valueAfterConstructor; 51 } 52 53 public boolean equals(Object obj) { 54 /* 55 * This method is not answering it the objs is equal. It is 56 * answering if the vars have the value that it have to have after 57 * dumping and loading 58 */ 59 60 if (obj == null) 61 return false; 62 if (!(obj instanceof DefaultConstructor)) 63 return false; 64 65 DefaultConstructor inst = (DefaultConstructor) obj; 66 return inst.f1 == valueAfterConstructor; 67 } 68 } 69 70 // ----------------------------------------------------------------------------------- 71 private static class NonSerDefaultConstructor { 72 public int f1; 73 74 public static int valueAfterConstructor = 5; 75 76 NonSerDefaultConstructor() { 77 f1 = valueAfterConstructor; 78 } 79 80 public NonSerDefaultConstructor(String notUsed) { 81 } 82 } 83 84 private static class NonSerPrivateConstructor { 85 public int f1; 86 87 public static int valueAfterConstructor = 5; 88 89 private NonSerPrivateConstructor() { 90 f1 = valueAfterConstructor; 91 } 92 93 public NonSerPrivateConstructor(String notUsed) { 94 } 95 } 96 97 private static class NonSerProtectedConstructor { 98 public int f1; 99 100 public static int valueAfterConstructor = 5; 101 102 protected NonSerProtectedConstructor() { 103 f1 = valueAfterConstructor; 104 } 105 } 106 107 private static class NonSerPublicConstructor { 108 public int f1; 109 110 public static int valueAfterConstructor = 5; 111 112 public NonSerPublicConstructor() { 113 f1 = valueAfterConstructor; 114 } 115 } 116 117 // ----------------------------------------------------------------------------------- 118 private static class DefaultConstructorSub extends NonSerDefaultConstructor 119 implements java.io.Serializable { 120 int fsub; 121 122 static int subValueAfterConstructor = 11; 123 124 public DefaultConstructorSub() { 125 f1 = 7; 126 fsub = subValueAfterConstructor; 127 } 128 129 public boolean equals(Object obj) { 130 /* 131 * This method is not answering it the objs is equal. It is 132 * answering if the vars have the value that it have to have after 133 * dumping and loading 134 */ 135 136 if (obj == null) 137 return false; 138 if (!(obj instanceof DefaultConstructorSub)) 139 return false; 140 141 DefaultConstructorSub inst = (DefaultConstructorSub) obj; 142 if (inst.f1 != valueAfterConstructor) 143 return false; 144 return inst.fsub == subValueAfterConstructor; 145 } 146 } 147 148 // ----------------------------------------------------------------------------------- 149 private static class PrivateConstructor implements java.io.Serializable { 150 int f1; 151 152 static int valueAfterConstructor = 5; 153 154 private PrivateConstructor() { 155 f1 = valueAfterConstructor; 156 } 157 158 public boolean equals(Object obj) { 159 /* 160 * This method is not answering it the objs is equal. Is is 161 * answering if the vars have the value that it have to have after 162 * dumping and loading 163 */ 164 165 if (obj == null) 166 return false; 167 if (!(obj instanceof PrivateConstructor)) 168 return false; 169 170 PrivateConstructor inst = (PrivateConstructor) obj; 171 return inst.f1 == valueAfterConstructor; 172 } 173 } 174 175 // ----------------------------------------------------------------------------------- 176 private static class PrivateConstructorSub extends NonSerPrivateConstructor 177 implements java.io.Serializable { 178 int fsub; 179 180 static int subValueAfterConstructor = 11; 181 182 public PrivateConstructorSub() { 183 super("notUsed"); 184 f1 = 7; 185 fsub = subValueAfterConstructor; 186 } 187 188 public boolean equals(Object obj) { 189 /* 190 * This method is not answering it the objs is equal. Is is 191 * answering if the vars have the value that it have to have after 192 * dumping and loading 193 */ 194 195 if (obj == null) 196 return false; 197 if (!(obj instanceof PrivateConstructorSub)) 198 return false; 199 200 PrivateConstructorSub inst = (PrivateConstructorSub) obj; 201 return inst.f1 == valueAfterConstructor 202 && inst.fsub == subValueAfterConstructor; 203 } 204 } 205 206 // ----------------------------------------------------------------------------------- 207 private static class ProtectedConstructor implements java.io.Serializable { 208 int f1; 209 210 static int valueAfterConstructor = 5; 211 212 protected ProtectedConstructor() { 213 f1 = valueAfterConstructor; 214 } 215 216 public boolean equals(Object obj) { 217 /* 218 * This method is not answering it the objs is equal. Is is 219 * answering if the vars have the value that it have to have after 220 * dumping and loading 221 */ 222 223 if (obj == null) 224 return false; 225 if (!(obj instanceof ProtectedConstructor)) 226 return false; 227 228 ProtectedConstructor inst = (ProtectedConstructor) obj; 229 return inst.f1 == valueAfterConstructor; 230 } 231 } 232 233 // ----------------------------------------------------------------------------------- 234 private static class ProtectedConstructorSub extends 235 NonSerProtectedConstructor implements java.io.Serializable { 236 int fsub; 237 238 static int subValueAfterConstructor = 11; 239 240 public ProtectedConstructorSub() { 241 f1 = 7; 242 fsub = subValueAfterConstructor; 243 } 244 245 public boolean equals(Object obj) { 246 /* 247 * This method is not answering it the objs is equal. Is is 248 * answering if the vars have the value that it have to have after 249 * dumping and loading 250 */ 251 252 if (obj == null) 253 return false; 254 if (!(obj instanceof ProtectedConstructorSub)) 255 return false; 256 257 ProtectedConstructorSub inst = (ProtectedConstructorSub) obj; 258 return inst.f1 == valueAfterConstructor 259 && inst.fsub == subValueAfterConstructor; 260 } 261 } 262 263 // ----------------------------------------------------------------------------------- 264 private static class PublicConstructor implements java.io.Serializable { 265 int f1; 266 267 static int valueAfterConstructor = 5; 268 269 public PublicConstructor() { 270 f1 = valueAfterConstructor; 271 } 272 273 public boolean equals(Object obj) { 274 /* 275 * This method is not answering it the objs is equal. Is is 276 * answering if the vars have the value that it have to have after 277 * dumping and loading 278 */ 279 280 if (obj == null) 281 return false; 282 if (!(obj instanceof PublicConstructor)) 283 return false; 284 285 PublicConstructor inst = (PublicConstructor) obj; 286 return inst.f1 == valueAfterConstructor; 287 } 288 } 289 290 // ----------------------------------------------------------------------------------- 291 private static class PublicConstructorSub extends NonSerPublicConstructor 292 implements java.io.Serializable { 293 int fsub; 294 295 static final int subValueAfterConstructor = 11; 296 297 public PublicConstructorSub() { 298 f1 = 7; 299 fsub = subValueAfterConstructor; 300 } 301 302 public boolean equals(Object obj) { 303 /* 304 * This method is not answering it the objs is equal. It is 305 * answering if the vars have the value that it have to have after 306 * dumping and loading 307 */ 308 309 if (obj == null) 310 return false; 311 if (!(obj instanceof PublicConstructorSub)) 312 return false; 313 314 PublicConstructorSub inst = (PublicConstructorSub) obj; 315 return inst.f1 == valueAfterConstructor 316 && inst.fsub == subValueAfterConstructor; 317 } 318 } 319 320 // Tests the behavior of ObjectOutputStream.PutField.write() 321 private static class WriteFieldsUsingPutFieldWrite implements 322 java.io.Serializable { 323 private static final ObjectStreamField[] serialPersistentFields = { 324 new ObjectStreamField("object1", Vector.class), 325 new ObjectStreamField("int1", Integer.TYPE) }; 326 327 private static Vector v1 = new Vector<String>(Arrays.asList(new String[] { 328 "1st", "2nd" })); 329 330 private boolean passed = false; 331 332 public WriteFieldsUsingPutFieldWrite() { 333 super(); 334 } 335 336 public boolean passed() { 337 return passed; 338 } 339 340 private void readObject(java.io.ObjectInputStream in) 341 throws java.io.IOException, ClassNotFoundException { 342 int int1 = in.readInt(); 343 Vector object1 = (Vector) in.readObject(); 344 passed = int1 == 0xA9 && object1.equals(v1); 345 } 346 347 @SuppressWarnings("deprecation") 348 private void writeObject(java.io.ObjectOutputStream out) 349 throws java.io.IOException, ClassNotFoundException { 350 ObjectOutputStream.PutField fields = out.putFields(); 351 fields.put("object1", v1); 352 fields.put("int1", 0xA9); 353 // Use fields.write() instead of out.writeFields(); 354 fields.write(out); 355 } 356 } 357 358 public SerializationStressTest3(String name) { 359 super(name); 360 } 361 362 public void test_18_81_writeObject() { 363 // Test for method void 364 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 365 366 try { 367 ByteArrayOutputStream out = new ByteArrayOutputStream(); 368 DataOutputStream dos = new DataOutputStream(out); 369 new ObjectOutputStream(dos); // just to make sure we get a header 370 dos.writeByte(ObjectStreamConstants.TC_BLOCKDATALONG); 371 int length = 333; // Bigger than 1 byte 372 dos.writeInt(length); 373 for (int i = 0; i < length; i++) { 374 dos.writeByte(0); // actual value does not matter 375 } 376 dos.flush(); 377 int lengthRead = 0; 378 try { 379 ObjectInputStream ois = new ObjectInputStream( 380 new ByteArrayInputStream(out.toByteArray())); 381 Object obj = ois.readObject(); 382 } catch (OptionalDataException e) { 383 lengthRead = e.length; 384 } 385 assertTrue("Did not throw exception with optional data size ", 386 length == lengthRead); 387 } catch (ClassNotFoundException e) { 388 fail("Unable to read BLOCKDATA : " + e.getMessage()); 389 } catch (IOException e) { 390 fail("IOException testing BLOCKDATALONG : " + e.getMessage()); 391 } catch (Error err) { 392 System.out.println("Error " + err + " when testing BLOCKDATALONG"); 393 throw err; 394 } 395 } 396 397 public void test_18_82_writeObject() { 398 // Test for method void 399 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 400 401 Object objToSave = null; 402 Object objLoaded; 403 404 try { 405 DefaultConstructor test = new DefaultConstructor(); 406 objToSave = test; 407 if (DEBUG) 408 System.out.println("Obj = " + objToSave); 409 objLoaded = dumpAndReload(objToSave); 410 // Has to have worked 411 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 412 413 } catch (IOException e) { 414 fail("IOException serializing " + objToSave + " : " 415 + e.getMessage()); 416 } catch (ClassNotFoundException e) { 417 fail("ClassNotFoundException reading Object type : " 418 + e.getMessage()); 419 } catch (Error err) { 420 System.out.println("Error when obj = " + objToSave); 421 // err.printStackTrace(); 422 throw err; 423 } 424 } 425 426 public void test_18_83_writeObject() { 427 // Test for method void 428 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 429 430 Object objToSave = null; 431 Object objLoaded; 432 433 try { 434 DefaultConstructorSub test = new DefaultConstructorSub(); 435 objToSave = test; 436 if (DEBUG) 437 System.out.println("Obj = " + objToSave); 438 objLoaded = dumpAndReload(objToSave); 439 // Has to have worked 440 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 441 442 } catch (IOException e) { 443 fail("IOException serializing " + objToSave + " : " 444 + e.getMessage()); 445 } catch (ClassNotFoundException e) { 446 fail("ClassNotFoundException reading Object type : " 447 + e.getMessage()); 448 } catch (Error err) { 449 System.out.println("Error when obj = " + objToSave); 450 // err.printStackTrace(); 451 throw err; 452 } 453 } 454 455 public void test_18_84_writeObject() { 456 // Test for method void 457 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 458 459 Object objToSave = null; 460 Object objLoaded; 461 462 try { 463 PrivateConstructor test = new PrivateConstructor(); 464 objToSave = test; 465 if (DEBUG) 466 System.out.println("Obj = " + objToSave); 467 objLoaded = dumpAndReload(objToSave); 468 // Has to have worked 469 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 470 471 } catch (IOException e) { 472 fail("IOException serializing " + objToSave + " : " 473 + e.getMessage()); 474 } catch (ClassNotFoundException e) { 475 fail("ClassNotFoundException reading Object type : " 476 + e.getMessage()); 477 } catch (Error err) { 478 System.out.println("Error when obj = " + objToSave); 479 // err.printStackTrace(); 480 throw err; 481 } 482 } 483 484 public void test_18_85_writeObject() { 485 // Test for method void 486 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 487 488 Object objToSave = null; 489 Object objLoaded; 490 491 try { 492 PrivateConstructorSub test = new PrivateConstructorSub(); 493 objToSave = test; 494 if (DEBUG) 495 System.out.println("Obj = " + objToSave); 496 objLoaded = dumpAndReload(objToSave); 497 // Has to have worked 498 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 499 500 } catch (IOException e) { 501 fail("IOException serializing " + objToSave + " : " 502 + e.getMessage()); 503 } catch (ClassNotFoundException e) { 504 fail("ClassNotFoundException reading Object type : " 505 + e.getMessage()); 506 } catch (Error err) { 507 System.out.println("Error when obj = " + objToSave); 508 // err.printStackTrace(); 509 throw err; 510 } 511 } 512 513 public void test_18_86_writeObject() { 514 // Test for method void 515 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 516 517 Object objToSave = null; 518 Object objLoaded; 519 520 try { 521 ProtectedConstructor test = new ProtectedConstructor(); 522 objToSave = test; 523 if (DEBUG) 524 System.out.println("Obj = " + objToSave); 525 objLoaded = dumpAndReload(objToSave); 526 // Has to have worked 527 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 528 529 } catch (IOException e) { 530 fail("IOException serializing " + objToSave + " : " 531 + e.getMessage()); 532 } catch (ClassNotFoundException e) { 533 fail("ClassNotFoundException reading Object type : " 534 + e.getMessage()); 535 } catch (Error err) { 536 System.out.println("Error when obj = " + objToSave); 537 // err.printStackTrace(); 538 throw err; 539 } 540 } 541 542 public void test_18_87_writeObject() { 543 // Test for method void 544 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 545 546 Object objToSave = null; 547 Object objLoaded; 548 549 try { 550 ProtectedConstructorSub test = new ProtectedConstructorSub(); 551 objToSave = test; 552 if (DEBUG) 553 System.out.println("Obj = " + objToSave); 554 objLoaded = dumpAndReload(objToSave); 555 // Has to have worked 556 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 557 558 } catch (IOException e) { 559 fail("IOException serializing " + objToSave + " : " 560 + e.getMessage()); 561 } catch (ClassNotFoundException e) { 562 fail("ClassNotFoundException reading Object type : " 563 + e.getMessage()); 564 } catch (Error err) { 565 System.out.println("Error when obj = " + objToSave); 566 // err.printStackTrace(); 567 throw err; 568 } 569 } 570 571 public void test_18_88_writeObject() { 572 // Test for method void 573 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 574 575 Object objToSave = null; 576 Object objLoaded; 577 578 try { 579 PublicConstructor test = new PublicConstructor(); 580 objToSave = test; 581 if (DEBUG) 582 System.out.println("Obj = " + objToSave); 583 objLoaded = dumpAndReload(objToSave); 584 // Has to have worked 585 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 586 587 } catch (IOException e) { 588 fail("IOException serializing " + objToSave + " : " 589 + e.getMessage()); 590 } catch (ClassNotFoundException e) { 591 fail("ClassNotFoundException reading Object type : " 592 + e.getMessage()); 593 } catch (Error err) { 594 System.out.println("Error when obj = " + objToSave); 595 // err.printStackTrace(); 596 throw err; 597 } 598 } 599 600 public void test_18_89_writeObject() { 601 // Test for method void 602 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 603 604 Object objToSave = null; 605 Object objLoaded; 606 607 try { 608 PublicConstructorSub test = new PublicConstructorSub(); 609 objToSave = test; 610 if (DEBUG) 611 System.out.println("Obj = " + objToSave); 612 objLoaded = dumpAndReload(objToSave); 613 // Has to have worked 614 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 615 616 } catch (IOException e) { 617 fail("IOException serializing " + objToSave + " : " 618 + e.getMessage()); 619 } catch (ClassNotFoundException e) { 620 fail("ClassNotFoundException reading Object type : " 621 + e.getMessage()); 622 } catch (Error err) { 623 System.out.println("Error when obj = " + objToSave); 624 // err.printStackTrace(); 625 throw err; 626 } 627 } 628 629 public void test_18_90_writeObject() { 630 // Test for method void 631 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 632 633 Object objToSave = null; 634 Object objLoaded; 635 636 try { 637 objToSave = TABLE; 638 if (DEBUG) 639 System.out.println("Obj = " + objToSave); 640 objLoaded = dumpAndReload(objToSave); 641 // Has to have worked 642 assertTrue(MSG_TEST_FAILED + objToSave, TABLE.equals(objLoaded)); 643 644 } catch (IOException e) { 645 fail("IOException serializing " + objToSave + " : " 646 + e.getMessage()); 647 } catch (ClassNotFoundException e) { 648 fail("ClassNotFoundException reading Object type : " 649 + e.getMessage()); 650 } catch (Error err) { 651 System.out.println("Error when obj = " + objToSave); 652 // err.printStackTrace(); 653 throw err; 654 } 655 } 656 657 public void test_18_91_writeObject() { 658 // Test for method void 659 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 660 661 Object objToSave = null; 662 Object objLoaded; 663 664 try { 665 Object col = Collections.synchronizedMap(TABLE); 666 objToSave = col; 667 if (DEBUG) 668 System.out.println("Obj = " + objToSave); 669 objLoaded = dumpAndReload(objToSave); 670 // Has to have worked 671 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 672 673 } catch (IOException e) { 674 fail("IOException serializing " + objToSave + " : " 675 + e.getMessage()); 676 } catch (ClassNotFoundException e) { 677 fail("ClassNotFoundException reading Object type : " 678 + e.getMessage()); 679 } catch (Error err) { 680 System.out.println("Error when obj = " + objToSave); 681 // err.printStackTrace(); 682 throw err; 683 } 684 } 685 686 public void test_18_92_writeObject() { 687 // Test for method void 688 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 689 690 Object objToSave = null; 691 Object objLoaded; 692 693 try { 694 Object col = Collections.unmodifiableMap(TABLE); 695 objToSave = col; 696 if (DEBUG) 697 System.out.println("Obj = " + objToSave); 698 objLoaded = dumpAndReload(objToSave); 699 // Has to have worked 700 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 701 702 } catch (IOException e) { 703 fail("IOException serializing " + objToSave + " : " 704 + e.getMessage()); 705 } catch (ClassNotFoundException e) { 706 fail("ClassNotFoundException reading Object type : " 707 + e.getMessage()); 708 } catch (Error err) { 709 System.out.println("Error when obj = " + objToSave); 710 // err.printStackTrace(); 711 throw err; 712 } 713 } 714 715 public void test_18_93_writeObject() { 716 // Test for method void 717 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 718 719 Object objToSave = null; 720 Object objLoaded; 721 722 try { 723 objToSave = MAP; 724 if (DEBUG) 725 System.out.println("Obj = " + objToSave); 726 objLoaded = dumpAndReload(objToSave); 727 // Has to have worked 728 assertTrue(MSG_TEST_FAILED + objToSave, MAP.equals(objLoaded)); 729 730 } catch (IOException e) { 731 fail("IOException serializing " + objToSave + " : " 732 + e.getMessage()); 733 } catch (ClassNotFoundException e) { 734 fail("ClassNotFoundException reading Object type : " 735 + e.getMessage()); 736 } catch (Error err) { 737 System.out.println("Error when obj = " + objToSave); 738 // err.printStackTrace(); 739 throw err; 740 } 741 } 742 743 public void test_18_94_writeObject() { 744 // Test for method void 745 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 746 747 Object objToSave = null; 748 Object objLoaded; 749 750 try { 751 Object col = Collections.synchronizedMap(MAP); 752 objToSave = col; 753 if (DEBUG) 754 System.out.println("Obj = " + objToSave); 755 objLoaded = dumpAndReload(objToSave); 756 // Has to have worked 757 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 758 759 } catch (IOException e) { 760 fail("IOException serializing " + objToSave + " : " 761 + e.getMessage()); 762 } catch (ClassNotFoundException e) { 763 fail("ClassNotFoundException reading Object type : " 764 + e.getMessage()); 765 } catch (Error err) { 766 System.out.println("Error when obj = " + objToSave); 767 // err.printStackTrace(); 768 throw err; 769 } 770 } 771 772 public void test_18_95_writeObject() { 773 // Test for method void 774 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 775 776 Object objToSave = null; 777 Object objLoaded; 778 779 try { 780 Object col = Collections.unmodifiableMap(MAP); 781 objToSave = col; 782 if (DEBUG) 783 System.out.println("Obj = " + objToSave); 784 objLoaded = dumpAndReload(objToSave); 785 // Has to have worked 786 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 787 788 } catch (IOException e) { 789 fail("IOException serializing " + objToSave + " : " 790 + e.getMessage()); 791 } catch (ClassNotFoundException e) { 792 fail("ClassNotFoundException reading Object type : " 793 + e.getMessage()); 794 } catch (Error err) { 795 System.out.println("Error when obj = " + objToSave); 796 // err.printStackTrace(); 797 throw err; 798 } 799 } 800 801 public void test_18_96_writeObject() { 802 // Test for method void 803 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 804 805 Object objToSave = null; 806 Object objLoaded; 807 808 try { 809 objToSave = ALIST; 810 if (DEBUG) 811 System.out.println("Obj = " + objToSave); 812 objLoaded = dumpAndReload(objToSave); 813 // Has to have worked 814 assertTrue(MSG_TEST_FAILED + objToSave, ALIST.equals(objLoaded)); 815 816 } catch (IOException e) { 817 fail("IOException serializing " + objToSave + " : " 818 + e.getMessage()); 819 } catch (ClassNotFoundException e) { 820 fail("ClassNotFoundException reading Object type : " 821 + e.getMessage()); 822 } catch (Error err) { 823 System.out.println("Error when obj = " + objToSave); 824 // err.printStackTrace(); 825 throw err; 826 } 827 } 828 829 public void test_18_97_writeObject() { 830 // Test for method void 831 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 832 833 Object objToSave = null; 834 Object objLoaded; 835 836 try { 837 objToSave = LIST; 838 if (DEBUG) 839 System.out.println("Obj = " + objToSave); 840 objLoaded = dumpAndReload(objToSave); 841 // Has to have worked 842 assertTrue(MSG_TEST_FAILED + objToSave, LIST.equals(objLoaded)); 843 844 } catch (IOException e) { 845 fail("IOException serializing " + objToSave + " : " 846 + e.getMessage()); 847 } catch (ClassNotFoundException e) { 848 fail("ClassNotFoundException reading Object type : " 849 + e.getMessage()); 850 } catch (Error err) { 851 System.out.println("Error when obj = " + objToSave); 852 // err.printStackTrace(); 853 throw err; 854 } 855 } 856 857 public void test_18_98_writeObject() { 858 // Test for method void 859 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 860 861 Object objToSave = null; 862 Object objLoaded; 863 864 try { 865 Object col = Collections.synchronizedList(LIST); 866 objToSave = col; 867 if (DEBUG) 868 System.out.println("Obj = " + objToSave); 869 objLoaded = dumpAndReload(objToSave); 870 // Has to have worked 871 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 872 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 public void test_18_99_writeObject() { 887 // Test for method void 888 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 889 890 Object objToSave = null; 891 Object objLoaded; 892 893 try { 894 Object col = Collections.unmodifiableList(LIST); 895 objToSave = col; 896 if (DEBUG) 897 System.out.println("Obj = " + objToSave); 898 objLoaded = dumpAndReload(objToSave); 899 // Has to have worked 900 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 901 902 } catch (IOException e) { 903 fail("IOException serializing " + objToSave + " : " 904 + e.getMessage()); 905 } catch (ClassNotFoundException e) { 906 fail("ClassNotFoundException reading Object type : " 907 + e.getMessage()); 908 } catch (Error err) { 909 System.out.println("Error when obj = " + objToSave); 910 // err.printStackTrace(); 911 throw err; 912 } 913 } 914 915 public void test_18_100_writeObject() { 916 // Test for method void 917 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 918 919 Object objToSave = null; 920 Object objLoaded; 921 922 try { 923 objToSave = SET; 924 if (DEBUG) 925 System.out.println("Obj = " + objToSave); 926 objLoaded = dumpAndReload(objToSave); 927 // Has to have worked 928 assertTrue(MSG_TEST_FAILED + objToSave, SET.equals(objLoaded)); 929 930 } catch (IOException e) { 931 fail("IOException serializing " + objToSave + " : " 932 + e.getMessage()); 933 } catch (ClassNotFoundException e) { 934 fail("ClassNotFoundException reading Object type : " 935 + e.getMessage()); 936 } catch (Error err) { 937 System.out.println("Error when obj = " + objToSave); 938 // err.printStackTrace(); 939 throw err; 940 } 941 } 942 943 public void test_18_101_writeObject() { 944 // Test for method void 945 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 946 947 Object objToSave = null; 948 Object objLoaded; 949 950 try { 951 Object col = Collections.synchronizedSet(SET); 952 objToSave = col; 953 if (DEBUG) 954 System.out.println("Obj = " + objToSave); 955 objLoaded = dumpAndReload(objToSave); 956 // Has to have worked 957 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 958 959 } catch (IOException e) { 960 fail("IOException serializing " + objToSave + " : " 961 + e.getMessage()); 962 } catch (ClassNotFoundException e) { 963 fail("ClassNotFoundException reading Object type : " 964 + e.getMessage()); 965 } catch (Error err) { 966 System.out.println("Error when obj = " + objToSave); 967 // err.printStackTrace(); 968 throw err; 969 } 970 } 971 972 public void test_18_102_writeObject() { 973 // Test for method void 974 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 975 976 Object objToSave = null; 977 Object objLoaded; 978 979 try { 980 Object col = Collections.unmodifiableSet(SET); 981 objToSave = col; 982 if (DEBUG) 983 System.out.println("Obj = " + objToSave); 984 objLoaded = dumpAndReload(objToSave); 985 // Has to have worked 986 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 987 988 } catch (IOException e) { 989 fail("IOException serializing " + objToSave + " : " 990 + e.getMessage()); 991 } catch (ClassNotFoundException e) { 992 fail("ClassNotFoundException reading Object type : " 993 + e.getMessage()); 994 } catch (Error err) { 995 System.out.println("Error when obj = " + objToSave); 996 // err.printStackTrace(); 997 throw err; 998 } 999 } 1000 1001 public void test_18_103_writeObject() { 1002 // Test for method void 1003 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1004 1005 Object objToSave = null; 1006 Object objLoaded; 1007 1008 try { 1009 objToSave = TREE; 1010 if (DEBUG) 1011 System.out.println("Obj = " + objToSave); 1012 objLoaded = dumpAndReload(objToSave); 1013 // Has to have worked 1014 assertTrue(MSG_TEST_FAILED + objToSave, TREE.equals(objLoaded)); 1015 1016 } catch (IOException e) { 1017 fail("IOException serializing " + objToSave + " : " 1018 + e.getMessage()); 1019 } catch (ClassNotFoundException e) { 1020 fail("ClassNotFoundException reading Object type : " 1021 + e.getMessage()); 1022 } catch (Error err) { 1023 System.out.println("Error when obj = " + objToSave); 1024 // err.printStackTrace(); 1025 throw err; 1026 } 1027 } 1028 1029 public void test_18_104_writeObject() { 1030 // Test for method void 1031 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1032 1033 Object objToSave = null; 1034 Object objLoaded; 1035 1036 try { 1037 Object col = Collections.synchronizedSortedMap(TREE); 1038 objToSave = col; 1039 if (DEBUG) 1040 System.out.println("Obj = " + objToSave); 1041 objLoaded = dumpAndReload(objToSave); 1042 // Has to have worked 1043 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 1044 1045 } catch (IOException e) { 1046 fail("IOException serializing " + objToSave + " : " 1047 + e.getMessage()); 1048 } catch (ClassNotFoundException e) { 1049 fail("ClassNotFoundException reading Object type : " 1050 + e.getMessage()); 1051 } catch (Error err) { 1052 System.out.println("Error when obj = " + objToSave); 1053 // err.printStackTrace(); 1054 throw err; 1055 } 1056 } 1057 1058 public void test_18_105_writeObject() { 1059 // Test for method void 1060 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1061 1062 Object objToSave = null; 1063 Object objLoaded; 1064 1065 try { 1066 Object col = Collections.unmodifiableSortedMap(TREE); 1067 objToSave = col; 1068 if (DEBUG) 1069 System.out.println("Obj = " + objToSave); 1070 objLoaded = dumpAndReload(objToSave); 1071 // Has to have worked 1072 assertTrue(MSG_TEST_FAILED + objToSave, col.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_106_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 objToSave = SORTSET; 1096 if (DEBUG) 1097 System.out.println("Obj = " + objToSave); 1098 objLoaded = dumpAndReload(objToSave); 1099 // Has to have worked 1100 assertTrue(MSG_TEST_FAILED + objToSave, SET.equals(objLoaded)); 1101 1102 } catch (IOException e) { 1103 fail("IOException serializing " + objToSave + " : " 1104 + e.getMessage()); 1105 } catch (ClassNotFoundException e) { 1106 fail("ClassNotFoundException reading Object type : " 1107 + e.getMessage()); 1108 } catch (Error err) { 1109 System.out.println("Error when obj = " + objToSave); 1110 // err.printStackTrace(); 1111 throw err; 1112 } 1113 } 1114 1115 public void test_18_107_writeObject() { 1116 // Test for method void 1117 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1118 1119 Object objToSave = null; 1120 Object objLoaded; 1121 1122 try { 1123 Object col = Collections.synchronizedSortedSet(SORTSET); 1124 objToSave = col; 1125 if (DEBUG) 1126 System.out.println("Obj = " + objToSave); 1127 objLoaded = dumpAndReload(objToSave); 1128 // Has to have worked 1129 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 1130 1131 } catch (IOException e) { 1132 fail("IOException serializing " + objToSave + " : " 1133 + e.getMessage()); 1134 } catch (ClassNotFoundException e) { 1135 fail("ClassNotFoundException reading Object type : " 1136 + e.getMessage()); 1137 } catch (Error err) { 1138 System.out.println("Error when obj = " + objToSave); 1139 // err.printStackTrace(); 1140 throw err; 1141 } 1142 } 1143 1144 public void test_18_108_writeObject() { 1145 // Test for method void 1146 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1147 1148 Object objToSave = null; 1149 Object objLoaded; 1150 1151 try { 1152 Object col = Collections.unmodifiableSortedSet(SORTSET); 1153 objToSave = col; 1154 if (DEBUG) 1155 System.out.println("Obj = " + objToSave); 1156 objLoaded = dumpAndReload(objToSave); 1157 // Has to have worked 1158 assertTrue(MSG_TEST_FAILED + objToSave, col.equals(objLoaded)); 1159 1160 } catch (IOException e) { 1161 fail("IOException serializing " + objToSave + " : " 1162 + e.getMessage()); 1163 } catch (ClassNotFoundException e) { 1164 fail("ClassNotFoundException reading Object type : " 1165 + e.getMessage()); 1166 } catch (Error err) { 1167 System.out.println("Error when obj = " + objToSave); 1168 // err.printStackTrace(); 1169 throw err; 1170 } 1171 } 1172 1173 public void test_18_109_writeObject() { 1174 // Test for method void 1175 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1176 1177 Object objToSave = null; 1178 Object objLoaded; 1179 1180 try { 1181 objToSave = CALENDAR; 1182 if (DEBUG) 1183 System.out.println("Obj = " + objToSave); 1184 objLoaded = dumpAndReload(objToSave); 1185 // Has to have worked 1186 assertTrue(MSG_TEST_FAILED + objToSave, CALENDAR.equals(objLoaded)); 1187 1188 } catch (IOException e) { 1189 fail("IOException serializing " + objToSave + " : " 1190 + e.getMessage()); 1191 } catch (ClassNotFoundException e) { 1192 fail("ClassNotFoundException reading Object type : " 1193 + e.getMessage()); 1194 } catch (Error err) { 1195 System.out.println("Error when obj = " + objToSave); 1196 // err.printStackTrace(); 1197 throw err; 1198 } 1199 } 1200 1201 public void test_18_110_writeObject() { 1202 // Test for method void 1203 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1204 1205 Object objToSave = null; 1206 Object objLoaded; 1207 1208 try { 1209 TimeZone test = TimeZone.getTimeZone("EST"); 1210 objToSave = test; 1211 if (DEBUG) 1212 System.out.println("Obj = " + objToSave); 1213 objLoaded = dumpAndReload(objToSave); 1214 // Has to have worked 1215 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 1216 1217 } catch (IOException e) { 1218 fail("IOException serializing " + objToSave + " : " 1219 + e.getMessage()); 1220 } catch (ClassNotFoundException e) { 1221 fail("ClassNotFoundException reading Object type : " 1222 + e.getMessage()); 1223 } catch (Error err) { 1224 System.out.println("Error when obj = " + objToSave); 1225 // err.printStackTrace(); 1226 throw err; 1227 } 1228 } 1229 1230 public void test_18_111_writeObject() { 1231 // Test for method void 1232 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1233 1234 Object objToSave = null; 1235 Object objLoaded; 1236 1237 try { 1238 TimeZone test = TimeZone.getTimeZone("EST"); 1239 objToSave = test; 1240 if (DEBUG) 1241 System.out.println("Obj = " + objToSave); 1242 objLoaded = dumpAndReload(objToSave); 1243 // Has to have worked 1244 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 1245 1246 } catch (IOException e) { 1247 fail("IOException serializing " + objToSave + " : " 1248 + e.getMessage()); 1249 } catch (ClassNotFoundException e) { 1250 fail("ClassNotFoundException reading Object type : " 1251 + e.getMessage()); 1252 } catch (Error err) { 1253 System.out.println("Error when obj = " + objToSave); 1254 // err.printStackTrace(); 1255 throw err; 1256 } 1257 } 1258 1259 public void test_18_112_writeObject() { 1260 // Test for method void 1261 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1262 1263 Object objToSave = null; 1264 Object objLoaded; 1265 1266 try { 1267 TimeZone test = TimeZone.getTimeZone("GMT"); 1268 objToSave = test; 1269 if (DEBUG) 1270 System.out.println("Obj = " + objToSave); 1271 objLoaded = dumpAndReload(objToSave); 1272 // Has to have worked 1273 assertTrue(MSG_TEST_FAILED + objToSave, test.equals(objLoaded)); 1274 1275 } catch (IOException e) { 1276 fail("IOException serializing " + objToSave + " : " 1277 + e.getMessage()); 1278 } catch (ClassNotFoundException e) { 1279 fail("ClassNotFoundException reading Object type : " 1280 + e.getMessage()); 1281 } catch (Error err) { 1282 System.out.println("Error when obj = " + objToSave); 1283 // err.printStackTrace(); 1284 throw err; 1285 } 1286 } 1287 1288 public void test_18_113_writeObject() { 1289 // Test for method void 1290 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1291 1292 Object objToSave = null; 1293 Object objLoaded; 1294 1295 try { 1296 objToSave = DATEFORM; 1297 if (DEBUG) 1298 System.out.println("Obj = " + objToSave); 1299 objLoaded = dumpAndReload(objToSave); 1300 // Has to have worked 1301 assertTrue(MSG_TEST_FAILED + objToSave, DATEFORM.equals(objLoaded)); 1302 1303 } catch (IOException e) { 1304 fail("IOException serializing " + objToSave + " : " 1305 + e.getMessage()); 1306 } catch (ClassNotFoundException e) { 1307 fail("ClassNotFoundException reading Object type : " 1308 + e.getMessage()); 1309 } catch (Error err) { 1310 System.out.println("Error when obj = " + objToSave); 1311 // err.printStackTrace(); 1312 throw err; 1313 } 1314 } 1315 1316 public void test_18_114_writeObject() { 1317 // Test for method void 1318 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1319 1320 Object objToSave = null; 1321 Object objLoaded; 1322 1323 try { 1324 objToSave = CHOICE; 1325 if (DEBUG) 1326 System.out.println("Obj = " + objToSave); 1327 objLoaded = dumpAndReload(objToSave); 1328 // Has to have worked 1329 assertTrue(MSG_TEST_FAILED + objToSave, CHOICE.equals(objLoaded)); 1330 1331 } catch (IOException e) { 1332 fail("IOException serializing " + objToSave + " : " 1333 + e.getMessage()); 1334 } catch (ClassNotFoundException e) { 1335 fail("ClassNotFoundException reading Object type : " 1336 + e.getMessage()); 1337 } catch (Error err) { 1338 System.out.println("Error when obj = " + objToSave); 1339 // err.printStackTrace(); 1340 throw err; 1341 } 1342 } 1343 1344 public void test_18_115_writeObject() { 1345 // Test for method void 1346 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1347 1348 Object objToSave = null; 1349 Object objLoaded; 1350 1351 try { 1352 objToSave = NUMBERFORM; 1353 if (DEBUG) 1354 System.out.println("Obj = " + objToSave); 1355 objLoaded = dumpAndReload(objToSave); 1356 // Has to have worked 1357 assertTrue(MSG_TEST_FAILED + objToSave, NUMBERFORM 1358 .equals(objLoaded)); 1359 1360 } catch (IOException e) { 1361 fail("IOException serializing " + objToSave + " : " 1362 + e.getMessage()); 1363 } catch (ClassNotFoundException e) { 1364 fail("ClassNotFoundException reading Object type : " 1365 + e.getMessage()); 1366 } catch (Error err) { 1367 System.out.println("Error when obj = " + objToSave); 1368 // err.printStackTrace(); 1369 throw err; 1370 } 1371 } 1372 1373 public void test_18_116_writeObject() { 1374 // Test for method void 1375 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1376 1377 Object objToSave = null; 1378 Object objLoaded; 1379 1380 try { 1381 objToSave = MESSAGE; 1382 if (DEBUG) 1383 System.out.println("Obj = " + objToSave); 1384 objLoaded = dumpAndReload(objToSave); 1385 // Has to have worked 1386 assertTrue(MSG_TEST_FAILED + objToSave, MESSAGE.toPattern().equals( 1387 ((java.text.MessageFormat) objLoaded).toPattern())); 1388 1389 } catch (IOException e) { 1390 fail("IOException serializing " + objToSave + " : " 1391 + e.getMessage()); 1392 } catch (ClassNotFoundException e) { 1393 fail("ClassNotFoundException reading Object type : " 1394 + e.getMessage()); 1395 } catch (Error err) { 1396 System.out.println("Error when obj = " + objToSave); 1397 // err.printStackTrace(); 1398 throw err; 1399 } 1400 } 1401 1402 public void test_18_119_writeObject() { 1403 // Test for method void 1404 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1405 1406 Object objToSave = null; 1407 Object objLoaded; 1408 1409 try { 1410 objToSave = Locale.CHINESE; 1411 if (DEBUG) 1412 System.out.println("Obj = " + objToSave); 1413 objLoaded = dumpAndReload(objToSave); 1414 // Has to have worked 1415 assertTrue(MSG_TEST_FAILED + objToSave, Locale.CHINESE 1416 .equals(objLoaded)); 1417 1418 } catch (IOException e) { 1419 fail("IOException serializing " + objToSave + " : " 1420 + e.getMessage()); 1421 } catch (ClassNotFoundException e) { 1422 fail("ClassNotFoundException reading Object type : " 1423 + e.getMessage()); 1424 } catch (Error err) { 1425 System.out.println("Error when obj = " + objToSave); 1426 // err.printStackTrace(); 1427 throw err; 1428 } 1429 } 1430 1431 public void test_18_120_writeObject() { 1432 // Test for method void 1433 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1434 1435 Object objToSave = null; 1436 Object objLoaded; 1437 1438 try { 1439 objToSave = LINKEDLIST; 1440 if (DEBUG) 1441 System.out.println("Obj = " + objToSave); 1442 objLoaded = dumpAndReload(objToSave); 1443 // Has to have worked 1444 assertTrue(MSG_TEST_FAILED + objToSave, LINKEDLIST 1445 .equals(objLoaded)); 1446 1447 } catch (IOException e) { 1448 fail("IOException serializing " + objToSave + " : " 1449 + e.getMessage()); 1450 } catch (ClassNotFoundException e) { 1451 fail("ClassNotFoundException reading Object type : " 1452 + e.getMessage()); 1453 } catch (Error err) { 1454 System.out.println("Error when obj = " + objToSave); 1455 // err.printStackTrace(); 1456 throw err; 1457 } 1458 } 1459 1460 public void test_18_121_writeObject() { 1461 // Test for method void 1462 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1463 1464 Object objToSave = null; 1465 Object objLoaded; 1466 1467 try { 1468 objToSave = java.text.AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT; 1469 if (DEBUG) 1470 System.out.println("Obj = " + objToSave); 1471 objLoaded = dumpAndReload(objToSave); 1472 // Has to have worked 1473 assertTrue( 1474 MSG_TEST_FAILED + objToSave, 1475 java.text.AttributedCharacterIterator.Attribute.INPUT_METHOD_SEGMENT == objLoaded); 1476 1477 } catch (IOException e) { 1478 fail("IOException serializing " + objToSave + " : " 1479 + e.getMessage()); 1480 } catch (ClassNotFoundException e) { 1481 fail("ClassNotFoundException reading Object type : " 1482 + e.getMessage()); 1483 } catch (Error err) { 1484 System.out.println("Error when obj = " + objToSave); 1485 // err.printStackTrace(); 1486 throw err; 1487 } 1488 } 1489 1490 public void test_18_122_writeObject() { 1491 // Test for method void 1492 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1493 1494 Object objToSave = null; 1495 Object objLoaded; 1496 1497 try { 1498 objToSave = java.text.AttributedCharacterIterator.Attribute.LANGUAGE; 1499 if (DEBUG) 1500 System.out.println("Obj = " + objToSave); 1501 objLoaded = dumpAndReload(objToSave); 1502 // Has to have worked 1503 assertTrue( 1504 MSG_TEST_FAILED + objToSave, 1505 java.text.AttributedCharacterIterator.Attribute.LANGUAGE == objLoaded); 1506 1507 } catch (IOException e) { 1508 fail("IOException serializing " + objToSave + " : " 1509 + e.getMessage()); 1510 } catch (ClassNotFoundException e) { 1511 fail("ClassNotFoundException reading Object type : " 1512 + e.getMessage()); 1513 } catch (Error err) { 1514 System.out.println("Error when obj = " + objToSave); 1515 // err.printStackTrace(); 1516 throw err; 1517 } 1518 } 1519 1520 public void test_18_123_writeObject() { 1521 // Test for method void 1522 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1523 1524 Object objToSave = null; 1525 Object objLoaded; 1526 1527 try { 1528 objToSave = java.text.AttributedCharacterIterator.Attribute.READING; 1529 if (DEBUG) 1530 System.out.println("Obj = " + objToSave); 1531 objLoaded = dumpAndReload(objToSave); 1532 // Has to have worked 1533 assertTrue( 1534 MSG_TEST_FAILED + objToSave, 1535 java.text.AttributedCharacterIterator.Attribute.READING == objLoaded); 1536 1537 } catch (IOException e) { 1538 fail("IOException serializing " + objToSave + " : " 1539 + e.getMessage()); 1540 } catch (ClassNotFoundException e) { 1541 fail("ClassNotFoundException reading Object type : " 1542 + e.getMessage()); 1543 } catch (Error err) { 1544 System.out.println("Error when obj = " + objToSave); 1545 // err.printStackTrace(); 1546 throw err; 1547 } 1548 } 1549 1550 public void test_18_124_writeObject() { 1551 // Test for method void 1552 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1553 1554 Object objToSave = null; 1555 Object objLoaded; 1556 1557 try { 1558 objToSave = new Object[] { Integer.class, new Integer(1) }; 1559 if (DEBUG) 1560 System.out.println("Obj = " + objToSave); 1561 objLoaded = dumpAndReload(objToSave); 1562 // Classes with the same name are unique, so test for == 1563 assertTrue(MSG_TEST_FAILED + objToSave, 1564 ((Object[]) objLoaded)[0] == ((Object[]) objToSave)[0] 1565 && ((Object[]) objLoaded)[1] 1566 .equals(((Object[]) objToSave)[1])); 1567 1568 } catch (IOException e) { 1569 fail("IOException serializing " + objToSave + " : " 1570 + e.getMessage()); 1571 } catch (ClassNotFoundException e) { 1572 fail("ClassNotFoundException reading Object type : " 1573 + e.getMessage()); 1574 } catch (Error err) { 1575 System.out.println("Error when obj = " + objToSave); 1576 // err.printStackTrace(); 1577 throw err; 1578 } 1579 } 1580 1581 public void test_18_125_writeObject() { 1582 // Test for method void 1583 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1584 1585 Object objToSave = null; 1586 Object objLoaded; 1587 1588 try { 1589 objToSave = new BigInteger[] { BigInteger.ZERO, BigInteger.ONE, 1590 BigInteger.valueOf(-1), BigInteger.valueOf(255), 1591 BigInteger.valueOf(-255), 1592 new BigInteger("75881644843307850793466070"), 1593 new BigInteger("-636104487142732527326202462") }; 1594 if (DEBUG) 1595 System.out.println("Obj = " + objToSave); 1596 objLoaded = dumpAndReload(objToSave); 1597 assertTrue(MSG_TEST_FAILED + objToSave, Arrays.equals( 1598 (BigInteger[]) objLoaded, (BigInteger[]) objToSave)); 1599 1600 } catch (IOException e) { 1601 fail("IOException serializing " + objToSave + " : " 1602 + 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 public void test_18_126_writeObject() { 1614 // Test for method void 1615 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1616 1617 Object objToSave = null; 1618 Object objLoaded; 1619 1620 try { 1621 objToSave = new WriteFieldsUsingPutFieldWrite(); 1622 if (DEBUG) 1623 System.out.println("Obj = " + objToSave); 1624 objLoaded = dumpAndReload(objToSave); 1625 assertTrue(MSG_TEST_FAILED + objToSave, 1626 ((WriteFieldsUsingPutFieldWrite) objLoaded).passed()); 1627 1628 } catch (IOException e) { 1629 fail("IOException serializing " + objToSave + " : " 1630 + e.getMessage()); 1631 } catch (ClassNotFoundException e) { 1632 fail("ClassNotFoundException reading Object type : " 1633 + e.getMessage()); 1634 } catch (Error err) { 1635 System.out.println("Error when obj = " + objToSave); 1636 // err.printStackTrace(); 1637 throw err; 1638 } 1639 } 1640 1641 public void test_18_127_writeObject() { 1642 // Test for method void 1643 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1644 1645 Object objToSave = null; 1646 Object objLoaded; 1647 1648 try { 1649 BitSet bs = new BitSet(64); 1650 bs.set(1); 1651 bs.set(10); 1652 bs.set(100); 1653 bs.set(1000); 1654 objToSave = bs; 1655 if (DEBUG) 1656 System.out.println("Obj = " + objToSave); 1657 objLoaded = dumpAndReload(objToSave); 1658 assertTrue(MSG_TEST_FAILED + objToSave, bs.equals(objLoaded)); 1659 1660 } catch (IOException e) { 1661 fail("IOException serializing " + objToSave + " : " 1662 + e.getMessage()); 1663 } catch (ClassNotFoundException e) { 1664 fail("ClassNotFoundException reading Object type : " 1665 + e.getMessage()); 1666 } catch (Error err) { 1667 System.out.println("Error when obj = " + objToSave); 1668 // err.printStackTrace(); 1669 throw err; 1670 } 1671 } 1672 1673 public void test_18_128_writeObject() { 1674 // Test for method void 1675 // java.io.ObjectOutputStream.writeObject(java.lang.Object) 1676 1677 Object objToSave = null; 1678 Object objLoaded; 1679 1680 try { 1681 PropertyPermission test = new PropertyPermission("java.*", 1682 "read,write"); 1683 PermissionCollection p = test.newPermissionCollection(); 1684 p.add(new PropertyPermission("java.*", "read")); 1685 p.add(new PropertyPermission("java.*", "write")); 1686 // System.out.println("Does implies work? " + p.implies(test)); 1687 1688 objToSave = p; 1689 if (DEBUG) 1690 System.out.println("Obj = " + objToSave); 1691 objLoaded = dumpAndReload(objToSave); 1692 assertTrue(MSG_TEST_FAILED + objToSave, 1693 ((PermissionCollection) objLoaded).implies(test)); 1694 1695 } catch (IOException e) { 1696 fail("IOException serializing " + objToSave + " : " 1697 + e.getMessage()); 1698 } catch (ClassNotFoundException e) { 1699 fail("ClassNotFoundException reading Object type : " 1700 + e.getMessage()); 1701 } catch (Error err) { 1702 System.out.println("Error when obj = " + objToSave); 1703 // err.printStackTrace(); 1704 throw err; 1705 } 1706 } 1707 } 1708