You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2008/01/31 11:04:22 UTC

svn commit: r617085 [7/14] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/build/platform/ depends/libs/ depends/oss/ make/ make/linux.x86_64.libstdc++6/ make/windows.x86/ make/windows.x86_64/ modules/archive/META-INF/ modules/ar...

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStream2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStream2Test.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStream2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStream2Test.java Thu Jan 31 02:04:05 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,9 +19,9 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InvalidClassException;
-import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamClass;
@@ -29,10 +29,10 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
 import junit.framework.TestCase;
 
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
 public class ObjectInputStream2Test extends TestCase {
 
     public void test_readUnshared() throws IOException, ClassNotFoundException {
@@ -53,101 +53,107 @@
         } catch (ObjectStreamException e) {
             // expected
         }
-    } 
+    }
+
+    /**
+     * Micro-scenario of de/serialization of an object with non-serializable
+     * superclass. The super-constructor only should be invoked on the
+     * deserialized instance.
+     */
+    public void test_readObject_Hierarchy() throws IOException,
+            ClassNotFoundException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        oos.writeObject(new B());
+        oos.close();
+
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                baos.toByteArray()));
+        B b = (B) ois.readObject();
+        ois.close();
+
+        assertTrue("should construct super", A.list.contains(b));
+        assertFalse("should not construct self", B.list.contains(b));
+        assertEquals("super field A.s", A.DEFAULT, ((A) b).s);
+        assertNull("transient field B.s", b.s);
+    }
+
+    /**
+     * @tests {@link java.io.ObjectInputStream#readNewLongString()}
+     */
+    public void test_readNewLongString() throws Exception {
+        LongString longString = new LongString();
+        SerializationTest.verifySelf(longString);
+    }
+
+    @SuppressWarnings("serial")
+    private static class LongString implements Serializable {
+        String lString;
+
+        public LongString() {
+            StringBuilder builder = new StringBuilder();
+            // construct a string whose length > 64K
+            for (int i = 0; i < 65636; i++) {
+                builder.append('1');
+            }
+            lString = builder.toString();
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o == this) {
+                return true;
+            }
+            if (o instanceof LongString) {
+                LongString l = (LongString) o;
+                return l.lString.equals(l.lString);
+            }
+            return true;
+        }
 
-	/**
-	 * Micro-scenario of de/serialization of an object with non-serializable superclass.
-	 * The super-constructor only should be invoked on the deserialized instance.
-	 */
-	public void test_readObject_Hierarchy() throws Exception {
-	    ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
-
-	    ObjectOutputStream oos = new ObjectOutputStream(baos); 
-	    oos.writeObject(new B());
-	    oos.close(); 
-
-	    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); 
-	    B b = (B) ois.readObject();
-	    ois.close();
-	    
-	    assertTrue("should construct super", A.list.contains(b));
-	    assertFalse("should not construct self", B.list.contains(b));
-	    assertEquals("super field A.s", A.DEFAULT, ((A)b).s);
-	    assertNull("transient field B.s", b.s);
-	}
-	
-	/**
-	 * @tests {@link java.io.ObjectInputStream#readNewLongString()}
-	 */
-	public void test_readNewLongString() throws Exception {
-		LongString longString = new LongString();
-		SerializationTest.verifySelf(longString);
-	}
-	
-	@SuppressWarnings("serial")
-    private static class LongString implements Serializable{
-		String lString;
-		
-		public LongString() {
-			StringBuilder builder = new StringBuilder();
-			// construct a string whose length > 64K
-			for (int i = 0; i < 65636; i++) {
-				builder.append('1');
-			}
-			lString = builder.toString();
-		}
-		
-		@Override
-		public boolean equals(Object o) {
-			if (o == this) {
-				return true;
-			}
-			if (o instanceof LongString) {
-				LongString l = (LongString) o;
-				return l.lString.equals(l.lString);
-			}
-			return true;
-		}
-		
-		@Override
-		public int hashCode() {
-			return lString.hashCode();
-		}
-	}
-
-	static class A { 
-		static final ArrayList<A> list = new ArrayList<A>();  
-	    String s;
-	    public static final String DEFAULT = "aaa";
-	    public A() {
-	    	s = DEFAULT;
-	    	list.add(this);
-	    }
-	} 
+        @Override
+        public int hashCode() {
+            return lString.hashCode();
+        }
+    }
+
+    static class A {
+        static final ArrayList<A> list = new ArrayList<A>();
+        String s;
+        public static final String DEFAULT = "aaa";
 
-	static class B extends A implements Serializable { 
+        public A() {
+            s = DEFAULT;
+            list.add(this);
+        }
+    }
+
+    static class B extends A implements Serializable {
         private static final long serialVersionUID = 1L;
-        static final ArrayList<A> list = new ArrayList<A>();  
-	    transient String s;
-	    public B() {
-	    	s = "bbb";
-	    	list.add(this);
-	    }
-	} 	
-    
+        static final ArrayList<A> list = new ArrayList<A>();
+        transient String s;
+
+        public B() {
+            s = "bbb";
+            list.add(this);
+        }
+    }
+
     class OIS extends ObjectInputStream {
-        
-        OIS () throws IOException {
+
+        OIS() throws IOException {
             super();
-         }
-        
-        void test() throws ClassNotFoundException,IOException {
+        }
+
+        void test() throws ClassNotFoundException, IOException {
             readClassDescriptor();
         }
-        
+
     }
-    
-    public void test_readClassDescriptor() throws ClassNotFoundException,IOException {
+
+    public void test_readClassDescriptor() throws ClassNotFoundException,
+            IOException {
         try {
             new OIS().test();
             fail("Should throw NullPointerException");
@@ -161,6 +167,7 @@
             super(in);
         }
 
+        @Override
         @SuppressWarnings("unchecked")
         protected Class resolveClass(ObjectStreamClass desc)
                 throws IOException, ClassNotFoundException {
@@ -171,7 +178,7 @@
         }
     }
 
-    static class TestClass1 implements Serializable { 
+    static class TestClass1 implements Serializable {
         private static final long serialVersionUID = 11111L;
         int i = 0;
     }
@@ -181,8 +188,7 @@
         int i = 0;
     }
 
-    public void test_resolveClass_invalidClassName()
-            throws Exception {
+    public void test_resolveClass_invalidClassName() throws Exception {
         // Regression test for HARMONY-1920
         TestClass1 to1 = new TestClass1();
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -199,12 +205,9 @@
 
         try {
             ois.readObject();
-
             fail("Should throw InvalidClassException");
         } catch (InvalidClassException ice) {
-            // valid
+            // Excpected
         }
     }
 }
-
-

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java Thu Jan 31 02:04:05 2008
@@ -42,15 +42,17 @@
 import java.io.StreamCorruptedException;
 import java.security.Permission;
 import java.util.Arrays;
-import java.util.Hashtable;
 import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Vector;
 
+import junit.framework.TestCase;
+
 import org.apache.harmony.testframework.serialization.SerializationTest;
 import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
 
 @SuppressWarnings("serial")
-public class ObjectInputStreamTest extends junit.framework.TestCase implements
+public class ObjectInputStreamTest extends TestCase implements
         Serializable {
 
     ObjectInputStream ois;
@@ -139,7 +141,6 @@
      * @tests java.io.ObjectInputStream#ObjectInputStream(java.io.InputStream)
      */
     public void test_ConstructorLjava_io_InputStream() throws IOException {
-        // Test for method java.io.ObjectInputStream(java.io.InputStream)
         oos.writeDouble(Double.MAX_VALUE);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -149,7 +150,9 @@
         try {
             ois = new ObjectInputStream(new ByteArrayInputStream(new byte[90]));
             fail("StreamCorruptedException expected");
-        } catch (StreamCorruptedException e) {}
+        } catch (StreamCorruptedException e) {
+            // Expected
+        }
     }
 
     /**
@@ -159,7 +162,8 @@
         SecurityManager sm = System.getSecurityManager();
         System.setSecurityManager(new SecurityManager() {
             Permission golden = new SerializablePermission("enableSubclassImplementation");
-            
+
+            @Override
             public void checkPermission(Permission p) {
                 if (golden.equals(p)) {
                     throw new SecurityException();
@@ -185,23 +189,29 @@
 
             try {
                 new ObjectInputStream(in) {
+                    @Override
                     public Object readUnshared() throws IOException, ClassNotFoundException {
                         return null;
                     }
                 };
                 fail("should throw SecurityException 1");
-            } catch (SecurityException e) {}
+            } catch (SecurityException e) {
+                // Expected
+            }
 
             in.reset();
             try {
                 new ObjectInputStream(in) {
+                    @Override
                     public GetField readFields() throws IOException,
                             ClassNotFoundException, NotActiveException {
                         return null;
                     }
                 };
                 fail("should throw SecurityException 2");
-            } catch (SecurityException e) {}
+            } catch (SecurityException e) {
+                // Expected
+            }
         } finally {
             System.setSecurityManager(sm);
         }
@@ -211,7 +221,6 @@
      * @tests java.io.ObjectInputStream#available()
      */
     public void test_available() throws IOException {
-        // Test for method int java.io.ObjectInputStream.available()
         oos.writeBytes("HelloWorld");
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -223,7 +232,6 @@
      * @tests java.io.ObjectInputStream#close()
      */
     public void test_close() throws IOException {
-        // Test for method void java.io.ObjectInputStream.close()
         oos.writeBytes("HelloWorld");
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -234,7 +242,6 @@
      * @tests java.io.ObjectInputStream#defaultReadObject()
      */
     public void test_defaultReadObject() throws Exception {
-        // Test for method void java.io.ObjectInputStream.defaultReadObject()
         // SM. This method may as well be private, as if called directly it
         // throws an exception.
         String s = "HelloWorld";
@@ -255,7 +262,6 @@
      * @tests java.io.ObjectInputStream#read()
      */
     public void test_read() throws IOException {
-        // Test for method int java.io.ObjectInputStream.read()
         oos.write('T');
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -267,7 +273,6 @@
      * @tests java.io.ObjectInputStream#read(byte[], int, int)
      */
     public void test_read$BII() throws IOException {
-        // Test for method int java.io.ObjectInputStream.read(byte [], int, int)
         byte[] buf = new byte[10];
         oos.writeBytes("HelloWorld");
         oos.close();
@@ -282,7 +287,6 @@
      * @tests java.io.ObjectInputStream#readBoolean()
      */
     public void test_readBoolean() throws IOException {
-        // Test for method boolean java.io.ObjectInputStream.readBoolean()
         oos.writeBoolean(true);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -294,7 +298,6 @@
      * @tests java.io.ObjectInputStream#readByte()
      */
     public void test_readByte() throws IOException {
-        // Test for method byte java.io.ObjectInputStream.readByte()
         oos.writeByte(127);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -306,7 +309,6 @@
      * @tests java.io.ObjectInputStream#readChar()
      */
     public void test_readChar() throws IOException {
-        // Test for method char java.io.ObjectInputStream.readChar()
         oos.writeChar('T');
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -318,7 +320,6 @@
      * @tests java.io.ObjectInputStream#readDouble()
      */
     public void test_readDouble() throws IOException {
-        // Test for method double java.io.ObjectInputStream.readDouble()
         oos.writeDouble(Double.MAX_VALUE);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -331,8 +332,6 @@
      * @tests java.io.ObjectInputStream#readFields()
      */
     public void test_readFields() throws Exception {
-        // Test for method java.io.ObjectInputStream$GetField
-        // java.io.ObjectInputStream.readFields()
 
         SerializableTestHelper sth;
 
@@ -358,7 +357,6 @@
      * @tests java.io.ObjectInputStream#readFloat()
      */
     public void test_readFloat() throws IOException {
-        // Test for method float java.io.ObjectInputStream.readFloat()
         oos.writeFloat(Float.MAX_VALUE);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -371,7 +369,6 @@
      * @tests java.io.ObjectInputStream#readFully(byte[])
      */
     public void test_readFully$B() throws IOException {
-        // Test for method void java.io.ObjectInputStream.readFully(byte [])
         byte[] buf = new byte[10];
         oos.writeBytes("HelloWorld");
         oos.close();
@@ -386,8 +383,6 @@
      * @tests java.io.ObjectInputStream#readFully(byte[], int, int)
      */
     public void test_readFully$BII() throws IOException {
-        // Test for method void java.io.ObjectInputStream.readFully(byte [],
-        // int, int)
         byte[] buf = new byte[10];
         oos.writeBytes("HelloWorld");
         oos.close();
@@ -402,7 +397,6 @@
      * @tests java.io.ObjectInputStream#readInt()
      */
     public void test_readInt() throws IOException {
-        // Test for method int java.io.ObjectInputStream.readInt()
         oos.writeInt(Integer.MAX_VALUE);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -416,7 +410,6 @@
      */
     @SuppressWarnings("deprecation")
     public void test_readLine() throws IOException {
-        // Test for method java.lang.String java.io.ObjectInputStream.readLine()
         oos.writeBytes("HelloWorld\nSecondLine");
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -430,7 +423,6 @@
      * @tests java.io.ObjectInputStream#readLong()
      */
     public void test_readLong() throws IOException {
-        // Test for method long java.io.ObjectInputStream.readLong()
         oos.writeLong(Long.MAX_VALUE);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -443,8 +435,6 @@
      * @tests java.io.ObjectInputStream#readObject()
      */
     public void test_readObject() throws Exception {
-        // Test for method java.lang.Object
-        // java.io.ObjectInputStream.readObject()
         String s = "HelloWorld";
         oos.writeObject(s);
         oos.close();
@@ -536,6 +526,7 @@
         // Regression for HARMONY-846
         assertNull(new ObjectInputStream() {
 
+            @Override
             public Object readObjectOverride() throws IOException,
                     ClassNotFoundException {
                 return super.readObjectOverride();
@@ -561,30 +552,23 @@
     /**
      * @tests java.io.ObjectInputStream#readObject()
      */
-    public void test_readObjectCorrupt() {
+    public void test_readObjectCorrupt() throws IOException, ClassNotFoundException {
         byte[] bytes = { 00, 00, 00, 0x64, 0x43, 0x48, (byte) 0xFD, 0x71, 00,
                 00, 0x0B, (byte) 0xB8, 0x4D, 0x65 };
         ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
-        boolean exception = false;
         try {
             ObjectInputStream in = new ObjectInputStream(bin);
             in.readObject();
             fail("Unexpected read of corrupted stream");
         } catch (StreamCorruptedException e) {
-            exception = true;
-        } catch (IOException e) {
-            fail("Unexpected: " + e);
-        } catch (ClassNotFoundException e) {
-            fail("Unexpected: " + e);
+            // Expected
         }
-        assertTrue("Expected StreamCorruptedException", exception);
     }
 
     /**
      * @tests java.io.ObjectInputStream#readShort()
      */
     public void test_readShort() throws IOException {
-        // Test for method short java.io.ObjectInputStream.readShort()
         oos.writeShort(Short.MAX_VALUE);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -597,7 +581,6 @@
      * @tests java.io.ObjectInputStream#readUnsignedByte()
      */
     public void test_readUnsignedByte() throws IOException {
-        // Test for method int java.io.ObjectInputStream.readUnsignedByte()
         oos.writeByte(-1);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -610,7 +593,6 @@
      * @tests java.io.ObjectInputStream#readUnsignedShort()
      */
     public void test_readUnsignedShort() throws IOException {
-        // Test for method int java.io.ObjectInputStream.readUnsignedShort()
         oos.writeShort(-1);
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -623,7 +605,6 @@
      * @tests java.io.ObjectInputStream#readUTF()
      */
     public void test_readUTF() throws IOException {
-        // Test for method java.lang.String java.io.ObjectInputStream.readUTF()
         oos.writeUTF("HelloWorld");
         oos.close();
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
@@ -635,7 +616,6 @@
      * @tests java.io.ObjectInputStream#skipBytes(int)
      */
     public void test_skipBytesI() throws IOException {
-        // Test for method int java.io.ObjectInputStream.skipBytes(int)
         byte[] buf = new byte[10];
         oos.writeBytes("HelloWorld");
         oos.close();
@@ -651,7 +631,7 @@
             fail("NullPointerException expected");
         } catch (NullPointerException e) {}
     }
-    
+
     // Regression Test for JIRA 2192
 	public void test_readObject_withPrimitiveClass() throws Exception {
 		File file = new File("test.ser");
@@ -667,7 +647,7 @@
 		in.close();
 		assertEquals(test, another);
 	}
-    
+
     //Regression Test for JIRA-2249
     public static class ObjectOutputStreamWithWriteDesc extends
             ObjectOutputStream {
@@ -676,6 +656,7 @@
             super(os);
         }
 
+        @Override
         public void writeClassDescriptor(ObjectStreamClass desc)
                 throws IOException {
         }
@@ -691,13 +672,14 @@
             this.returnClass = returnClass;
         }
 
+        @Override
         public ObjectStreamClass readClassDescriptor() throws IOException,
                 ClassNotFoundException {
             return ObjectStreamClass.lookup(returnClass);
 
         }
     }
-    
+
     static class TestClassForSerialization implements Serializable {
 		private static final long serialVersionUID = 1L;
 	}
@@ -717,7 +699,7 @@
 		Object obj = ois.readObject();
 		ois.close();
 		assertEquals(cls, obj);
-	} 
+	}
 
 	// Regression Test for JIRA-2340
     public static class ObjectOutputStreamWithWriteDesc1 extends
@@ -727,32 +709,35 @@
 			super(os);
 		}
 
-		public void writeClassDescriptor(ObjectStreamClass desc)
+		@Override
+        public void writeClassDescriptor(ObjectStreamClass desc)
 				throws IOException {
 			super.writeClassDescriptor(desc);
 		}
 	}
 
 	public static class ObjectIutputStreamWithReadDesc1 extends
-			ObjectInputStream {		
+			ObjectInputStream {
 
 		public ObjectIutputStreamWithReadDesc1(InputStream is)
 				throws IOException {
-			super(is);			
+			super(is);
 		}
 
-		public ObjectStreamClass readClassDescriptor() throws IOException,
+		@Override
+        public ObjectStreamClass readClassDescriptor() throws IOException,
 				ClassNotFoundException {
 			return super.readClassDescriptor();
 		}
 	}
-    
+
     // Regression test for Harmony-1921
     public static class ObjectInputStreamWithResolve extends ObjectInputStream {
         public ObjectInputStreamWithResolve(InputStream in) throws IOException {
             super(in);
         }
 
+        @Override
         @SuppressWarnings("unchecked")
         protected Class resolveClass(ObjectStreamClass desc)
                 throws IOException, ClassNotFoundException {
@@ -782,24 +767,25 @@
                     + to2.i);
         }
     }
-	
+
     static class ObjectInputStreamWithResolveObject extends ObjectInputStream {
-        
+
         public static Integer intObj = Integer.valueOf(1000);
-        
+
         public ObjectInputStreamWithResolveObject(InputStream in) throws IOException {
             super(in);
             enableResolveObject(true);
         }
-        
+
+        @Override
         protected Object resolveObject(Object obj) throws IOException {
             if(obj instanceof Integer){
                 obj = intObj;
             }
             return super.resolveObject(obj);
-        }        
+        }
     }
-    
+
     /**
      * @tests java.io.ObjectInputStream#resolveObject(Object)
      */
@@ -815,15 +801,15 @@
         // Read the object from memory
         byte[] bytes = baos.toByteArray();
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-        ObjectInputStreamWithResolveObject ois = 
+        ObjectInputStreamWithResolveObject ois =
             new ObjectInputStreamWithResolveObject(bais);
         Integer actual = (Integer) ois.readObject();
         ois.close();
 
-        // object should be resolved from 10 to 1000 
+        // object should be resolved from 10 to 1000
         assertEquals(ObjectInputStreamWithResolveObject.intObj, actual);
     }
-    
+
 	public void test_readClassDescriptor() throws IOException,
 			ClassNotFoundException {
 
@@ -834,7 +820,7 @@
 		.lookup(TestClassForSerialization.class);
 		oos.writeClassDescriptor(desc);
 		oos.close();
-		
+
         byte[] bytes = baos.toByteArray();
 		ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
 		ObjectIutputStreamWithReadDesc1 ois = new ObjectIutputStreamWithReadDesc1(
@@ -842,7 +828,7 @@
 		Object obj = ois.readClassDescriptor();
 		ois.close();
 		assertEquals(desc.getClass(), obj.getClass());
-        
+
         //eof
         bais = new ByteArrayInputStream(bytes);
         ExceptionalBufferedInputStream bis = new ExceptionalBufferedInputStream(
@@ -850,7 +836,7 @@
         ois = new ObjectIutputStreamWithReadDesc1(bis);
 
         bis.setEOF(true);
-        
+
         try {
             obj = ois.readClassDescriptor();
         } catch (IOException e) {
@@ -858,7 +844,7 @@
         } finally {
             ois.close();
         }
-        
+
         //throw exception
         bais = new ByteArrayInputStream(bytes);
         bis = new ExceptionalBufferedInputStream(bais);
@@ -878,9 +864,9 @@
         bais = new ByteArrayInputStream(bytes);
         bis = new ExceptionalBufferedInputStream(bais);
         ois = new ObjectIutputStreamWithReadDesc1(bis);
-        
+
         bis.setCorrupt(true);
-        
+
         try {
             obj = ois.readClassDescriptor();
         } catch (IOException e) {
@@ -888,41 +874,41 @@
         } finally {
             ois.close();
         }
-
 	}
-    
+
     static class ExceptionalBufferedInputStream extends BufferedInputStream {
         private boolean eof = false;
-        private IOException exception = null; 
-        private boolean corrupt = false; 
-        
+        private IOException exception = null;
+        private boolean corrupt = false;
+
         public ExceptionalBufferedInputStream(InputStream in) {
             super(in);
         }
-        
+
+        @Override
         public int read() throws IOException {
             if (exception != null) {
                 throw exception;
             }
-            
+
             if (eof) {
                 return -1;
             }
-            
+
             if (corrupt) {
                 return 0;
             }
             return super.read();
         }
-        
+
         public void setEOF(boolean eof) {
             this.eof = eof;
         }
-        
+
         public void setException(IOException exception) {
             this.exception = exception;
         }
-        
+
         public void setCorrupt(boolean corrupt) {
             this.corrupt = corrupt;
         }
@@ -938,6 +924,7 @@
             this.returnClass = returnClass;
         }
 
+        @Override
         public ObjectStreamClass readClassDescriptor() throws IOException,
                 ClassNotFoundException {
             ObjectStreamClass osc = super.readClassDescriptor();
@@ -994,7 +981,7 @@
         } catch (NotActiveException nae) {
             // expected
         }
-        
+
         // Regression Test for Harmony-3916
         baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -1005,7 +992,7 @@
         // should not throw NotActiveException
         fis.readObject();
     }
-    
+
     private static class RegisterValidationClass implements Serializable {
         @SuppressWarnings("unused")
         private A a = new A();
@@ -1014,18 +1001,18 @@
             stream.registerValidation(new MockObjectInputValidation(), 0);
         }
     }
-    
+
     private static class MockObjectInputValidation implements ObjectInputValidation {
         public void validateObject() throws InvalidObjectException {
-            
+
         }
     }
-    
+
     //Regression Test for HARMONY-3726
     public void test_readObject_array() throws Exception {
-        
+
         final String resourcePrefix = ObjectInputStreamTest.class.getPackage().getName().replace('.', '/');
-        
+
 //        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("/temp/test_array_strings.ser"));
 //        TestArray ta = new TestArray(new String[] { "AAA", "BBB" });
 //        oos.writeObject(ta);
@@ -1034,15 +1021,15 @@
 //        ta = new TestArray(new Integer[] { 10, 20 });
 //        oos.writeObject(ta);
 //        oos.close();
-        
+
         ObjectInputStream oin = new ObjectInputStream(this.getClass().getClassLoader().getResourceAsStream(
-                "serialization/" + resourcePrefix + "/test_array_strings.ser"));               
+                "serialization/" + resourcePrefix + "/test_array_strings.ser"));
         TestArray testArray = (TestArray) oin.readObject();
         String[] strings = new String[] { "AAA", "BBB" };
         assertTrue(java.util.Arrays.equals(strings, testArray.array));
 
         oin = new ObjectInputStream(this.getClass().getClassLoader().getResourceAsStream(
-                "serialization/" + resourcePrefix + "/test_array_integers.ser"));        
+                "serialization/" + resourcePrefix + "/test_array_integers.ser"));
         testArray = (TestArray) oin.readObject();
         Integer[] integers = new Integer[] { 10, 20 };
         assertTrue(java.util.Arrays.equals(integers, testArray.array));
@@ -1067,6 +1054,7 @@
             this.objs = objs;
         }
 
+        @Override
         protected void writeClassDescriptor(ObjectStreamClass osc) throws IOException {
             objs[pos++] = osc;        }
     }
@@ -1080,8 +1068,9 @@
             this.objs = objs;
         }
 
+        @Override
         protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
-            return (ObjectStreamClass) objs[pos++];
+            return objs[pos++];
         }
     }
 
@@ -1103,6 +1092,7 @@
      * Sets up the fixture, for example, open a network connection. This method
      * is called before a test is executed.
      */
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
@@ -1112,13 +1102,13 @@
 class TestArray implements Serializable
 {
     private static final long serialVersionUID = 1L;
-    
+
     public Object[] array;
-    
+
     public TestArray(Object[] array) {
         this.array = array;
     }
-    
+
 }
 
 class Test implements Serializable {
@@ -1127,7 +1117,8 @@
 	Class classes[] = new Class[] { byte.class, short.class, int.class,
 			long.class, boolean.class, char.class, float.class, double.class };
 
-	public boolean equals(Object o) {
+	@Override
+    public boolean equals(Object o) {
 		if (!(o instanceof Test)) {
 			return false;
 		}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectOutputStreamTest.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectOutputStreamTest.java Thu Jan 31 02:04:05 2008
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.Externalizable;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -40,425 +41,426 @@
 import java.security.Permission;
 import java.util.Arrays;
 
+import junit.framework.TestCase;
+
 @SuppressWarnings( { "unused", "serial" })
-public class ObjectOutputStreamTest extends junit.framework.TestCase implements
-		Serializable {
+public class ObjectOutputStreamTest extends TestCase implements Serializable {
+
+    File f;
+
+    public class SerializableTestHelper implements Serializable {
+        public String aField1;
 
-	java.io.File f;
+        public String aField2;
+
+        SerializableTestHelper() {
+            aField1 = null;
+            aField2 = null;
+        }
 
-	public class SerializableTestHelper implements Serializable {
-		public String aField1;
+        SerializableTestHelper(String s, String t) {
+            aField1 = s;
+            aField2 = t;
+        }
 
-		public String aField2;
-
-		SerializableTestHelper() {
-			aField1 = null;
-			aField2 = null;
-		}
-
-		SerializableTestHelper(String s, String t) {
-			aField1 = s;
-			aField2 = t;
-		}
-
-		private void readObject(ObjectInputStream ois) throws IOException {
-			// note aField2 is not read
-			try {
-				ObjectInputStream.GetField fields = ois.readFields();
-				aField1 = (String) fields.get("aField1", "Zap");
-			} catch (Exception e) {
-			}
-		}
-
-		private void writeObject(ObjectOutputStream oos) throws IOException {
-			// note aField2 is not written
-			ObjectOutputStream.PutField fields = oos.putFields();
-			fields.put("aField1", aField1);
-			oos.writeFields();
-		}
-
-		public String getText1() {
-			return aField1;
-		}
-
-		public void setText1(String s) {
-			aField1 = s;
-		}
-
-		public String getText2() {
-			return aField2;
-		}
-
-		public void setText2(String s) {
-			aField2 = s;
-		}
-	}
-
-	private static class SerializationTest implements java.io.Serializable {
-		int anInt = INIT_INT_VALUE;
-
-		public SerializationTest() {
-			super();
-		}
-	}
+        private void readObject(ObjectInputStream ois) throws IOException {
+            // note aField2 is not read
+            try {
+                ObjectInputStream.GetField fields = ois.readFields();
+                aField1 = (String) fields.get("aField1", "Zap");
+            } catch (Exception e) {
+            }
+        }
+
+        private void writeObject(ObjectOutputStream oos) throws IOException {
+            // note aField2 is not written
+            ObjectOutputStream.PutField fields = oos.putFields();
+            fields.put("aField1", aField1);
+            oos.writeFields();
+        }
+
+        public String getText1() {
+            return aField1;
+        }
+
+        public void setText1(String s) {
+            aField1 = s;
+        }
+
+        public String getText2() {
+            return aField2;
+        }
+
+        public void setText2(String s) {
+            aField2 = s;
+        }
+    }
+
+    private static class SerializationTest implements java.io.Serializable {
+        int anInt = INIT_INT_VALUE;
+
+        public SerializationTest() {
+            super();
+        }
+    }
 
     private static class SerializationTestSubclass1 extends SerializationTest
-			implements Serializable {
-		String aString = INIT_STR_VALUE;
+            implements Serializable {
+        String aString = INIT_STR_VALUE;
+
+        public SerializationTestSubclass1() {
+            super();
+            // Just to change default superclass init value
+            anInt = INIT_INT_VALUE / 2;
+        }
+    }
+
+    private static class SpecTestSuperClass implements Runnable, Serializable {
+        protected java.lang.String instVar;
+
+        public void run() {
+        }
+    }
+
+    private static class SpecTest extends SpecTestSuperClass implements
+            Cloneable, Serializable {
+        public java.lang.String instVar1;
+
+        public static java.lang.String staticVar1;
+
+        public static java.lang.String staticVar2;
+        {
+            instVar1 = "NonStaticInitialValue";
+        }
+        static {
+            staticVar1 = "StaticInitialValue";
+            staticVar1 = new String(staticVar1);
+        }
+
+        public Object method(Object objParam, Object objParam2) {
+            return new Object();
+        }
+
+        public boolean method(boolean bParam, Object objParam) {
+            return true;
+        }
+
+        public boolean method(boolean bParam, Object objParam, Object objParam2) {
+            return true;
+        }
+
+    }
+
+    private static class SpecTestSubclass extends SpecTest implements
+            Serializable {
+        public transient java.lang.String transientInstVar = "transientValue";
+    }
+
+    private static class ReadWriteObject implements java.io.Serializable {
+        public boolean calledWriteObject = false;
+
+        public boolean calledReadObject = false;
+
+        public ReadWriteObject() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            calledReadObject = true;
+            in.readObject();
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException {
+            calledWriteObject = true;
+            out.writeObject(FOO);
+        }
+    }
+
+    private static class PublicReadWriteObject implements java.io.Serializable {
+        public boolean calledWriteObject = false;
+
+        public boolean calledReadObject = false;
+
+        public PublicReadWriteObject() {
+            super();
+        }
+
+        public void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            calledReadObject = true;
+            in.readObject();
+        }
+
+        public void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException {
+            calledWriteObject = true;
+            out.writeObject(FOO);
+        }
+    }
+
+    private static class FieldOrder implements Serializable {
+        String aaa1NonPrimitive = "aaa1";
+
+        int bbb1PrimitiveInt = 5;
+
+        boolean aaa2PrimitiveBoolean = true;
+
+        String bbb2NonPrimitive = "bbb2";
+    }
 
-		public SerializationTestSubclass1() {
-			super();
-			// Just to change default superclass init value
-			anInt = INIT_INT_VALUE / 2;
-		}
-	}
-
-	private static class SpecTestSuperClass implements Runnable, Serializable {
-		protected java.lang.String instVar;
-
-		public void run() {
-		}
-	}
-
-	private static class SpecTest extends SpecTestSuperClass implements
-			Cloneable, Serializable {
-		public java.lang.String instVar1;
-
-		public static java.lang.String staticVar1;
-
-		public static java.lang.String staticVar2;
-		{
-			instVar1 = "NonStaticInitialValue";
-		}
-		static {
-			staticVar1 = "StaticInitialValue";
-			staticVar1 = new String(staticVar1);
-		}
-
-		public Object method(Object objParam, Object objParam2) {
-			return new Object();
-		}
-
-		public boolean method(boolean bParam, Object objParam) {
-			return true;
-		}
-
-		public boolean method(boolean bParam, Object objParam, Object objParam2) {
-			return true;
-		}
-
-	}
-
-	private static class SpecTestSubclass extends SpecTest implements
-			Serializable {
-		public transient java.lang.String transientInstVar = "transientValue";
-	}
-
-	private static class ReadWriteObject implements java.io.Serializable {
-		public boolean calledWriteObject = false;
-
-		public boolean calledReadObject = false;
-
-		public ReadWriteObject() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			calledReadObject = true;
-			in.readObject();
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException {
-			calledWriteObject = true;
-			out.writeObject(FOO);
-		}
-	}
-
-	private static class PublicReadWriteObject implements java.io.Serializable {
-		public boolean calledWriteObject = false;
-
-		public boolean calledReadObject = false;
-
-		public PublicReadWriteObject() {
-			super();
-		}
-
-		public void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			calledReadObject = true;
-			in.readObject();
-		}
-
-		public void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException {
-			calledWriteObject = true;
-			out.writeObject(FOO);
-		}
-	}
-
-	private static class FieldOrder implements Serializable {
-		String aaa1NonPrimitive = "aaa1";
-
-		int bbb1PrimitiveInt = 5;
-
-		boolean aaa2PrimitiveBoolean = true;
-
-		String bbb2NonPrimitive = "bbb2";
-	}
-
-	private static class JustReadObject implements java.io.Serializable {
-		public boolean calledReadObject = false;
-
-		public JustReadObject() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			calledReadObject = true;
-			in.defaultReadObject();
-		}
-	}
-
-	private static class JustWriteObject implements java.io.Serializable {
-		public boolean calledWriteObject = false;
-
-		public JustWriteObject() {
-			super();
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException, ClassNotFoundException {
-			calledWriteObject = true;
-			out.defaultWriteObject();
-		}
-	}
-
-	private static class ClassBasedReplacementWhenDumping implements
-			java.io.Serializable {
-		public boolean calledReplacement = false;
-
-		public ClassBasedReplacementWhenDumping() {
-			super();
-		}
-
-		private Object writeReplace() {
-			calledReplacement = true;
-			return FOO; // Replacement is a String
-		}
-	}
-
-	private static class MultipleClassBasedReplacementWhenDumping implements
-			java.io.Serializable {
-		private static class C1 implements java.io.Serializable {
-			private Object writeReplace() {
-				return new C2();
-			}
-		}
-
-		private static class C2 implements java.io.Serializable {
-			private Object writeReplace() {
-				return new C3();
-			}
-		}
-
-		private static class C3 implements java.io.Serializable {
-			private Object writeReplace() {
-				return FOO;
-			}
-		}
-
-		public MultipleClassBasedReplacementWhenDumping() {
-			super();
-		}
-
-		private Object writeReplace() {
-			return new C1();
-		}
-	}
-
-	private static class ClassBasedReplacementWhenLoading implements
-			java.io.Serializable {
-		public ClassBasedReplacementWhenLoading() {
-			super();
-		}
-
-		private Object readResolve() {
-			return FOO; // Replacement is a String
-		}
-	}
-
-	private static class ClassBasedReplacementWhenLoadingViolatesFieldType
-			implements java.io.Serializable {
-		public ClassBasedReplacementWhenLoading classBasedReplacementWhenLoading = new ClassBasedReplacementWhenLoading();
-
-		public ClassBasedReplacementWhenLoadingViolatesFieldType() {
-			super();
-		}
-	}
-
-	private static class MyExceptionWhenDumping implements java.io.Serializable {
-		private static class MyException extends java.io.IOException {
-		};
-
-		public boolean anInstanceVar = false;
-
-		public MyExceptionWhenDumping() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			in.defaultReadObject();
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException, ClassNotFoundException {
-			throw new MyException();
-		}
-	}
-
-	private static class NonSerializableExceptionWhenDumping implements
-			java.io.Serializable {
-		public Object anInstanceVar = new Object();
-
-		public NonSerializableExceptionWhenDumping() {
-			super();
-		}
-	}
-
-	private static class MyUnserializableExceptionWhenDumping implements
-			java.io.Serializable {
-		private static class MyException extends java.io.IOException {
-			private Object notSerializable = new Object();
-		};
-
-		public boolean anInstanceVar = false;
-
-		public MyUnserializableExceptionWhenDumping() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			in.defaultReadObject();
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException, ClassNotFoundException {
-			throw new MyException();
-		}
-	}
-
-	private static class WithUnmatchingSerialPersistentFields implements
-			java.io.Serializable {
-		private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
-				"value", String.class) };
-
-		public int anInstanceVar = 5;
-
-		public WithUnmatchingSerialPersistentFields() {
-			super();
-		}
-	}
-
-	private static class WithMatchingSerialPersistentFields implements
-			java.io.Serializable {
-		private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
-				"anInstanceVar", String.class) };
-
-		public String anInstanceVar = FOO + FOO;
-
-		public WithMatchingSerialPersistentFields() {
-			super();
-		}
-	}
-
-	private static class SerialPersistentFields implements java.io.Serializable {
-		private static final String SIMULATED_FIELD_NAME = "text";
-
-		private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
-				SIMULATED_FIELD_NAME, String.class) };
-
-		public int anInstanceVar = 5;
-
-		public SerialPersistentFields() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			ObjectInputStream.GetField fields = in.readFields();
-			anInstanceVar = Integer.parseInt((String) fields.get(
-					SIMULATED_FIELD_NAME, "-5"));
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException, ClassNotFoundException {
-			ObjectOutputStream.PutField fields = out.putFields();
-			fields.put(SIMULATED_FIELD_NAME, Integer.toString(anInstanceVar));
-			out.writeFields();
-		}
-	}
-
-	private static class WriteFieldsWithoutFetchingPutFields implements
-			java.io.Serializable {
-		private static final String SIMULATED_FIELD_NAME = "text";
-
-		private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
-				SIMULATED_FIELD_NAME, String.class) };
-
-		public int anInstanceVar = 5;
-
-		public WriteFieldsWithoutFetchingPutFields() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			in.readFields();
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException, ClassNotFoundException {
-			out.writeFields();
-		}
-	}
-
-	private static class SerialPersistentFieldsWithoutField implements
-			java.io.Serializable {
-		public int anInstanceVar = 5;
-
-		public SerialPersistentFieldsWithoutField() {
-			super();
-		}
-
-		private void readObject(java.io.ObjectInputStream in)
-				throws java.io.IOException, ClassNotFoundException {
-			in.readFields();
-		}
-
-		private void writeObject(java.io.ObjectOutputStream out)
-				throws java.io.IOException, ClassNotFoundException {
-			out.putFields();
-			out.writeFields();
-		}
-	}
-
-	private static class NotSerializable {
-		private int foo;
-
-		public NotSerializable() {
-		}
-
-		protected Object writeReplace() throws ObjectStreamException {
-			return new Integer(42);
-		}
-	}
-	
-	private static class WriteReplaceObject implements Serializable {
+    private static class JustReadObject implements java.io.Serializable {
+        public boolean calledReadObject = false;
+
+        public JustReadObject() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            calledReadObject = true;
+            in.defaultReadObject();
+        }
+    }
+
+    private static class JustWriteObject implements java.io.Serializable {
+        public boolean calledWriteObject = false;
+
+        public JustWriteObject() {
+            super();
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException, ClassNotFoundException {
+            calledWriteObject = true;
+            out.defaultWriteObject();
+        }
+    }
+
+    private static class ClassBasedReplacementWhenDumping implements
+            java.io.Serializable {
+        public boolean calledReplacement = false;
+
+        public ClassBasedReplacementWhenDumping() {
+            super();
+        }
+
+        private Object writeReplace() {
+            calledReplacement = true;
+            return FOO; // Replacement is a String
+        }
+    }
+
+    private static class MultipleClassBasedReplacementWhenDumping implements
+            java.io.Serializable {
+        private static class C1 implements java.io.Serializable {
+            private Object writeReplace() {
+                return new C2();
+            }
+        }
+
+        private static class C2 implements java.io.Serializable {
+            private Object writeReplace() {
+                return new C3();
+            }
+        }
+
+        private static class C3 implements java.io.Serializable {
+            private Object writeReplace() {
+                return FOO;
+            }
+        }
+
+        public MultipleClassBasedReplacementWhenDumping() {
+            super();
+        }
+
+        private Object writeReplace() {
+            return new C1();
+        }
+    }
+
+    private static class ClassBasedReplacementWhenLoading implements
+            java.io.Serializable {
+        public ClassBasedReplacementWhenLoading() {
+            super();
+        }
+
+        private Object readResolve() {
+            return FOO; // Replacement is a String
+        }
+    }
+
+    private static class ClassBasedReplacementWhenLoadingViolatesFieldType
+            implements java.io.Serializable {
+        public ClassBasedReplacementWhenLoading classBasedReplacementWhenLoading = new ClassBasedReplacementWhenLoading();
+
+        public ClassBasedReplacementWhenLoadingViolatesFieldType() {
+            super();
+        }
+    }
+
+    private static class MyExceptionWhenDumping implements java.io.Serializable {
+        private static class MyException extends java.io.IOException {
+        };
+
+        public boolean anInstanceVar = false;
+
+        public MyExceptionWhenDumping() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            in.defaultReadObject();
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException, ClassNotFoundException {
+            throw new MyException();
+        }
+    }
+
+    private static class NonSerializableExceptionWhenDumping implements
+            java.io.Serializable {
+        public Object anInstanceVar = new Object();
+
+        public NonSerializableExceptionWhenDumping() {
+            super();
+        }
+    }
+
+    private static class MyUnserializableExceptionWhenDumping implements
+            java.io.Serializable {
+        private static class MyException extends java.io.IOException {
+            private Object notSerializable = new Object();
+        };
+
+        public boolean anInstanceVar = false;
+
+        public MyUnserializableExceptionWhenDumping() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            in.defaultReadObject();
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException, ClassNotFoundException {
+            throw new MyException();
+        }
+    }
+
+    private static class WithUnmatchingSerialPersistentFields implements
+            java.io.Serializable {
+        private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
+                "value", String.class) };
+
+        public int anInstanceVar = 5;
+
+        public WithUnmatchingSerialPersistentFields() {
+            super();
+        }
+    }
+
+    private static class WithMatchingSerialPersistentFields implements
+            java.io.Serializable {
+        private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
+                "anInstanceVar", String.class) };
+
+        public String anInstanceVar = FOO + FOO;
+
+        public WithMatchingSerialPersistentFields() {
+            super();
+        }
+    }
+
+    private static class SerialPersistentFields implements java.io.Serializable {
+        private static final String SIMULATED_FIELD_NAME = "text";
+
+        private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
+                SIMULATED_FIELD_NAME, String.class) };
+
+        public int anInstanceVar = 5;
+
+        public SerialPersistentFields() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            ObjectInputStream.GetField fields = in.readFields();
+            anInstanceVar = Integer.parseInt((String) fields.get(
+                    SIMULATED_FIELD_NAME, "-5"));
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException, ClassNotFoundException {
+            ObjectOutputStream.PutField fields = out.putFields();
+            fields.put(SIMULATED_FIELD_NAME, Integer.toString(anInstanceVar));
+            out.writeFields();
+        }
+    }
+
+    private static class WriteFieldsWithoutFetchingPutFields implements
+            java.io.Serializable {
+        private static final String SIMULATED_FIELD_NAME = "text";
+
+        private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField(
+                SIMULATED_FIELD_NAME, String.class) };
+
+        public int anInstanceVar = 5;
+
+        public WriteFieldsWithoutFetchingPutFields() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            in.readFields();
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException, ClassNotFoundException {
+            out.writeFields();
+        }
+    }
+
+    private static class SerialPersistentFieldsWithoutField implements
+            java.io.Serializable {
+        public int anInstanceVar = 5;
+
+        public SerialPersistentFieldsWithoutField() {
+            super();
+        }
+
+        private void readObject(java.io.ObjectInputStream in)
+                throws java.io.IOException, ClassNotFoundException {
+            in.readFields();
+        }
+
+        private void writeObject(java.io.ObjectOutputStream out)
+                throws java.io.IOException, ClassNotFoundException {
+            out.putFields();
+            out.writeFields();
+        }
+    }
+
+    private static class NotSerializable {
+        private int foo;
+
+        public NotSerializable() {
+        }
+
+        protected Object writeReplace() throws ObjectStreamException {
+            return new Integer(42);
+        }
+    }
+
+    private static class WriteReplaceObject implements Serializable {
         private Object replaceObject;
 
         private static enum Color {
@@ -474,25 +476,27 @@
         }
     }
 
-	private static class ExternalizableWithReplace implements Externalizable {
-		private int foo;
+    private static class ExternalizableWithReplace implements Externalizable {
+        private int foo;
 
-		public ExternalizableWithReplace() {
-		}
+        public ExternalizableWithReplace() {
+        }
 
-		protected Object writeReplace() throws ObjectStreamException {
-			return new Integer(42);
-		}
+        protected Object writeReplace() throws ObjectStreamException {
+            return new Integer(42);
+        }
 
-		public void writeExternal(ObjectOutput out) {
-		}
+        public void writeExternal(ObjectOutput out) {
+        }
 
-		public void readExternal(ObjectInput in) {
-		}
-	}
+        public void readExternal(ObjectInput in) {
+        }
+    }
 
-    private static class ObjectOutputStreamWithReplace extends ObjectOutputStream {
-        public ObjectOutputStreamWithReplace(OutputStream out) throws IOException {
+    private static class ObjectOutputStreamWithReplace extends
+            ObjectOutputStream {
+        public ObjectOutputStreamWithReplace(OutputStream out)
+                throws IOException {
             super(out);
             enableReplaceObject(true);
         }
@@ -504,10 +508,10 @@
             if (obj instanceof Integer) {
                 return new Long(((Integer) obj).longValue());
             }
-            return super.replaceObject(obj);            
+            return super.replaceObject(obj);
         }
     }
-        
+
     private static class ObjectOutputStreamWithReplace2 extends
             ObjectOutputStream {
         public ObjectOutputStreamWithReplace2(OutputStream out)
@@ -520,8 +524,9 @@
             return new Long(10);
         }
     }
-    
-    private static class ObjectOutputStreamWriteOverride extends ObjectOutputStream {
+
+    private static class ObjectOutputStreamWriteOverride extends
+            ObjectOutputStream {
         String test = "test";
 
         protected ObjectOutputStreamWriteOverride() throws IOException,
@@ -536,34 +541,34 @@
         }
     }
 
-	protected static final String MODE_XLOAD = "xload";
+    protected static final String MODE_XLOAD = "xload";
 
-	protected static final String MODE_XDUMP = "xdump";
+    protected static final String MODE_XDUMP = "xdump";
 
-	static final String FOO = "foo";
+    static final String FOO = "foo";
 
-	static final String MSG_WITE_FAILED = "Failed to write: ";
+    static final String MSG_WITE_FAILED = "Failed to write: ";
 
-	private static final boolean DEBUG = false;
+    private static final boolean DEBUG = false;
 
-	protected static boolean xload = false;
+    protected static boolean xload = false;
 
-	protected static boolean xdump = false;
+    protected static boolean xdump = false;
 
-	protected static String xFileName = null;
+    protected static String xFileName = null;
 
-	protected ObjectInputStream ois;
+    protected ObjectInputStream ois;
 
-	protected ObjectOutputStream oos;
+    protected ObjectOutputStream oos;
 
-	protected ByteArrayOutputStream bao;
+    protected ByteArrayOutputStream bao;
 
-	static final int INIT_INT_VALUE = 7;
+    static final int INIT_INT_VALUE = 7;
 
-	static final String INIT_STR_VALUE = "a string that is blortz";
+    static final String INIT_STR_VALUE = "a string that is blortz";
 
-	/**
-	 * @tests java.io.ObjectOutputStream#ObjectOutputStream(java.io.OutputStream)
+    /**
+     * @tests java.io.ObjectOutputStream#ObjectOutputStream(java.io.OutputStream)
      */
     public void test_ConstructorLjava_io_OutputStream() throws IOException {
         // Test for method java.io.ObjectOutputStream(java.io.OutputStream)
@@ -572,97 +577,98 @@
         oos.close();
     }
 
-	/**
-	 * @tests java.io.ObjectOutputStream#ObjectOutputStream(java.io.OutputStream)
-	 */
-	public void test_ConstructorLjava_io_OutputStream_subtest0() throws IOException {
-
-		// custom security manager
-		SecurityManager sm = new SecurityManager() {
-
-			final SerializablePermission forbidenPermission =
-				new SerializablePermission("enableSubclassImplementation");
-
-			public void checkPermission(Permission perm) {
-				if (forbidenPermission.equals(perm)) {
-					throw new SecurityException();
-				}
-			}
-		};
-
-		SecurityManager oldSm = System.getSecurityManager();
-		System.setSecurityManager(sm);
-		try {
-			ByteArrayOutputStream out = new ByteArrayOutputStream();
-			// should not cause SecurityException
-			new ObjectOutputStream(out);
-			// should not cause SecurityException
-			class SubTest1 extends ObjectOutputStream {
-				SubTest1(OutputStream out) throws IOException {
-					super(out);
-				}
-			}
-
-			// should not cause SecurityException
-			new SubTest1(out);
-			class SubTest2 extends ObjectOutputStream {
-				SubTest2(OutputStream out) throws IOException {
-					super(out);
-				}
-
-				public void writeUnshared(Object obj) throws IOException {
-				}
-			}
+    /**
+     * @tests java.io.ObjectOutputStream#ObjectOutputStream(java.io.OutputStream)
+     */
+    public void test_ConstructorLjava_io_OutputStream_subtest0()
+            throws IOException {
+
+        // custom security manager
+        SecurityManager sm = new SecurityManager() {
+
+            final SerializablePermission forbidenPermission = new SerializablePermission(
+                    "enableSubclassImplementation");
+
+            public void checkPermission(Permission perm) {
+                if (forbidenPermission.equals(perm)) {
+                    throw new SecurityException();
+                }
+            }
+        };
+
+        SecurityManager oldSm = System.getSecurityManager();
+        System.setSecurityManager(sm);
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            // should not cause SecurityException
+            new ObjectOutputStream(out);
+            // should not cause SecurityException
+            class SubTest1 extends ObjectOutputStream {
+                SubTest1(OutputStream out) throws IOException {
+                    super(out);
+                }
+            }
+
+            // should not cause SecurityException
+            new SubTest1(out);
+            class SubTest2 extends ObjectOutputStream {
+                SubTest2(OutputStream out) throws IOException {
+                    super(out);
+                }
+
+                public void writeUnshared(Object obj) throws IOException {
+                }
+            }
 
             try {
-				new SubTest2(out);
-				fail("should throw SecurityException 1");
-			} catch (SecurityException e) {
-			}
-			class SubTest3 extends ObjectOutputStream {
-				SubTest3(OutputStream out) throws IOException {
-					super(out);
-				}
-
-				public PutField putFields() throws IOException {
-					return null;
-				}
-			}
-
-			try {
-				new SubTest3(out);
-				fail("should throw SecurityException 2");
-			} catch (SecurityException e) {
-			}
-		} finally {
-			System.setSecurityManager(oldSm);
-		}
-	}
-
-	/**
-	 * @tests java.io.ObjectOutputStream#close()
-	 */
-	public void test_close() {
-		// Test for method void java.io.ObjectOutputStream.close()
-	}
-
-	/**
-	 * @tests java.io.ObjectOutputStream#defaultWriteObject()
-	 */
-	public void test_defaultWriteObject() throws IOException {
-		// Test for method void java.io.ObjectOutputStream.defaultWriteObject()
-		try {
-			oos.defaultWriteObject();
+                new SubTest2(out);
+                fail("should throw SecurityException 1");
+            } catch (SecurityException e) {
+            }
+            class SubTest3 extends ObjectOutputStream {
+                SubTest3(OutputStream out) throws IOException {
+                    super(out);
+                }
+
+                public PutField putFields() throws IOException {
+                    return null;
+                }
+            }
+
+            try {
+                new SubTest3(out);
+                fail("should throw SecurityException 2");
+            } catch (SecurityException e) {
+            }
+        } finally {
+            System.setSecurityManager(oldSm);
+        }
+    }
+
+    /**
+     * @tests java.io.ObjectOutputStream#close()
+     */
+    public void test_close() {
+        // Test for method void java.io.ObjectOutputStream.close()
+    }
+
+    /**
+     * @tests java.io.ObjectOutputStream#defaultWriteObject()
+     */
+    public void test_defaultWriteObject() throws IOException {
+        // Test for method void java.io.ObjectOutputStream.defaultWriteObject()
+        try {
+            oos.defaultWriteObject();
             fail("Failed to throw NotActiveException");
-		} catch (NotActiveException e) {
-			// Correct
-		}
-	}
-
-	/**
-	 * @tests java.io.ObjectOutputStream#flush()
-	 */
-	public void test_flush() throws Exception {
+        } catch (NotActiveException e) {
+            // Correct
+        }
+    }
+
+    /**
+     * @tests java.io.ObjectOutputStream#flush()
+     */
+    public void test_flush() throws Exception {
         // Test for method void java.io.ObjectOutputStream.flush()
         int size = bao.size();
         oos.writeByte(127);
@@ -675,21 +681,21 @@
         oos = null;
     }
 
-	/**
-	 * @tests java.io.ObjectOutputStream#putFields()
-	 */
-	public void test_putFields() throws Exception {
-		// Test for method java.io.ObjectOutputStream$PutField
-		// java.io.ObjectOutputStream.putFields()
-
-		SerializableTestHelper sth;
-
-		/*
-		 * "SerializableTestHelper" is an object created for these tests with
-		 * two fields (Strings) and simple implementations of readObject and
-		 * writeObject which simply read and write the first field but not the
-		 * second
-		 */
+    /**
+     * @tests java.io.ObjectOutputStream#putFields()
+     */
+    public void test_putFields() throws Exception {
+        // Test for method java.io.ObjectOutputStream$PutField
+        // java.io.ObjectOutputStream.putFields()
+
+        SerializableTestHelper sth;
+
+        /*
+         * "SerializableTestHelper" is an object created for these tests with
+         * two fields (Strings) and simple implementations of readObject and
+         * writeObject which simply read and write the first field but not the
+         * second
+         */
 
         oos.writeObject(new SerializableTestHelper("Gabba", "Jabba"));
         oos.flush();
@@ -702,10 +708,10 @@
                 sth.getText2());
     }
 
-	/**
-	 * @tests java.io.ObjectOutputStream#reset()
-	 */
-	public void test_reset() throws Exception {
+    /**
+     * @tests java.io.ObjectOutputStream#reset()
+     */
+    public void test_reset() throws Exception {
         // Test for method void java.io.ObjectOutputStream.reset()
         String o = "HelloWorld";
         oos.writeObject(o);
@@ -716,41 +722,41 @@
         ois.close();
     }
 
-	private static class ExternalTest implements Externalizable {
-		public String value;
+    private static class ExternalTest implements Externalizable {
+        public String value;
+
+        public ExternalTest() {
+        }
+
+        public void setValue(String val) {
+            value = val;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+        public void writeExternal(ObjectOutput output) {
+            try {
+                output.writeUTF(value);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
 
-		public ExternalTest() {
-		}
+        public void readExternal(ObjectInput input) {
+            try {
+                value = input.readUTF();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 
-		public void setValue(String val) {
-			value = val;
-		}
-
-		public String getValue() {
-			return value;
-		}
-
-		public void writeExternal(ObjectOutput output) {
-			try {
-				output.writeUTF(value);
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-
-		public void readExternal(ObjectInput input) {
-			try {
-				value = input.readUTF();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	/**
-	 * @tests java.io.ObjectOutputStream#useProtocolVersion(int)
-	 */
-	public void test_useProtocolVersionI() throws Exception {
+    /**
+     * @tests java.io.ObjectOutputStream#useProtocolVersion(int)
+     */
+    public void test_useProtocolVersionI() throws Exception {
         // Test for method void
         // java.io.ObjectOutputStream.useProtocolVersion(int)
         oos.useProtocolVersion(ObjectOutputStream.PROTOCOL_VERSION_1);
@@ -766,7 +772,8 @@
                         + t2.getValue(), t1.getValue().equals(t2.getValue()));
 
         // Cannot set protocol version when stream in-flight
-        ObjectOutputStream out = new ObjectOutputStream(new ByteArrayOutputStream());
+        ObjectOutputStream out = new ObjectOutputStream(
+                new ByteArrayOutputStream());
         out.writeObject("hello world");
         try {
             out.useProtocolVersion(ObjectStreamConstants.PROTOCOL_VERSION_1);
@@ -776,10 +783,10 @@
         }
     }
 
-	/**
-	 * @tests java.io.ObjectOutputStream#write(byte[])
-	 */
-	public void test_write$B() throws Exception {
+    /**
+     * @tests java.io.ObjectOutputStream#write(byte[])
+     */
+    public void test_write$B() throws Exception {
         // Test for method void java.io.ObjectOutputStream.write(byte [])
         byte[] buf = new byte[10];
         oos.write("HelloWorld".getBytes());
@@ -791,7 +798,7 @@
                 10));
     }
 
-	/**
+    /**
      * @tests java.io.ObjectOutputStream#write(byte[], int, int)
      */
     public void test_write$BII() throws Exception {
@@ -979,10 +986,11 @@
             out = new ObjectOutputStream(new ByteArrayOutputStream());
             out.writeObject(new NotSerializable());
             fail("Expected NotSerializableException");
-        } catch (NotSerializableException e) {}
+        } catch (NotSerializableException e) {
+        }
         out.writeObject(new ExternalizableWithReplace());
     }
-    
+
     /**
      * @tests {@link java.io.ObjectOutputStream#writeObjectOverride(Object)}
      */
@@ -1014,11 +1022,12 @@
         ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
         assertEquals("Wrote incorrect UTF value", "HelloWorld", ois.readUTF());
     }
-    
+
     /**
      * @tests java.io.ObjectOutputStream#writeObject(java.lang.Object)
      */
-    public void test_writeObject_Exception() throws ClassNotFoundException, IOException {
+    public void test_writeObject_Exception() throws ClassNotFoundException,
+            IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         ObjectOutputStream oos = new ObjectOutputStream(baos);
 
@@ -1063,7 +1072,8 @@
         if (oos != null) {
             try {
                 oos.close();
-            } catch (Exception e) {}
+            } catch (Exception e) {
+            }
         }
         if (f != null && f.exists()) {
             if (!f.delete()) {
@@ -1149,7 +1159,8 @@
                     oos.close();
                 if (ois != null)
                     ois.close();
-            } catch (IOException e) {}
+            } catch (IOException e) {
+            }
         }
     }
 
@@ -1157,7 +1168,7 @@
      * @tests java.io.ObjectOutputStream#writeUnshared(java.lang.Object)
      */
     public void test_writeUnshared() throws Exception {
-        //Regression for HARMONY-187
+        // Regression for HARMONY-187
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
 
@@ -1167,7 +1178,8 @@
         oos.writeObject(o);
         oos.flush();
 
-        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream (baos.toByteArray()));
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                baos.toByteArray()));
 
         Object[] oa = new Object[3];
         for (int i = 0; i < oa.length; i++) {
@@ -1187,7 +1199,7 @@
      * @tests java.io.ObjectOutputStream#writeUnshared(java.lang.Object)
      */
     public void test_writeUnshared2() throws Exception {
-        //Regression for HARMONY-187
+        // Regression for HARMONY-187
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
 
@@ -1197,7 +1209,8 @@
         oos.writeObject(o);
         oos.flush();
 
-        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream (baos.toByteArray()));
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                baos.toByteArray()));
 
         Object[] oa = new Object[3];
         for (int i = 0; i < oa.length; i++) {
@@ -1242,55 +1255,57 @@
      * @tests java.io.ObjectOutputStream#replaceObject(java.lang.Object)
      */
     public void test_replaceObject() throws Exception {
-        //Regression for HARMONY-1429
+        // Regression for HARMONY-1429
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ObjectOutputStreamWithReplace oos = new ObjectOutputStreamWithReplace(baos);
+        ObjectOutputStreamWithReplace oos = new ObjectOutputStreamWithReplace(
+                baos);
 
         oos.writeObject(new NotSerializable());
         oos.flush();
-        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream (baos.toByteArray()));
+        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(
+                baos.toByteArray()));
         Object obj = ois.readObject();
         oos.close();
         ois.close();
         assertTrue("replaceObject has not been called", (obj instanceof Long));
 
-		//Regression for HARMONY-2239
-		Object replaceObject = int.class;
-		baos = new ByteArrayOutputStream();
-		ObjectOutputStreamWithReplace2 oos2 = new ObjectOutputStreamWithReplace2(
-				baos);
-		oos2.writeObject(new WriteReplaceObject(replaceObject));
-		oos2.flush();
-		ois = new ObjectInputStream(
-				new ByteArrayInputStream(baos.toByteArray()));
-		obj = ois.readObject();
-		oos.close();
-		ois.close();
-		assertTrue("replaceObject has not been called", (obj instanceof Long));
-
-		replaceObject = ObjectStreamClass.lookup(Integer.class);
-		baos = new ByteArrayOutputStream();
-		oos2 = new ObjectOutputStreamWithReplace2(baos);
-		oos2.writeObject(new WriteReplaceObject(replaceObject));
-		oos2.flush();
-		ois = new ObjectInputStream(
-				new ByteArrayInputStream(baos.toByteArray()));
-		obj = ois.readObject();
-		oos.close();
-		ois.close();
-		assertTrue("replaceObject has not been called", (obj instanceof Long));
-
-		replaceObject = WriteReplaceObject.Color.red;
-		baos = new ByteArrayOutputStream();
-		oos2 = new ObjectOutputStreamWithReplace2(baos);
-		oos2.writeObject(new WriteReplaceObject(replaceObject));
-		oos2.flush();
-		ois = new ObjectInputStream(
-				new ByteArrayInputStream(baos.toByteArray()));
-		obj = ois.readObject();
-		oos.close();
-		ois.close();
-		assertTrue("replaceObject has not been called", (obj instanceof Long));
+        // Regression for HARMONY-2239
+        Object replaceObject = int.class;
+        baos = new ByteArrayOutputStream();
+        ObjectOutputStreamWithReplace2 oos2 = new ObjectOutputStreamWithReplace2(
+                baos);
+        oos2.writeObject(new WriteReplaceObject(replaceObject));
+        oos2.flush();
+        ois = new ObjectInputStream(
+                new ByteArrayInputStream(baos.toByteArray()));
+        obj = ois.readObject();
+        oos.close();
+        ois.close();
+        assertTrue("replaceObject has not been called", (obj instanceof Long));
+
+        replaceObject = ObjectStreamClass.lookup(Integer.class);
+        baos = new ByteArrayOutputStream();
+        oos2 = new ObjectOutputStreamWithReplace2(baos);
+        oos2.writeObject(new WriteReplaceObject(replaceObject));
+        oos2.flush();
+        ois = new ObjectInputStream(
+                new ByteArrayInputStream(baos.toByteArray()));
+        obj = ois.readObject();
+        oos.close();
+        ois.close();
+        assertTrue("replaceObject has not been called", (obj instanceof Long));
+
+        replaceObject = WriteReplaceObject.Color.red;
+        baos = new ByteArrayOutputStream();
+        oos2 = new ObjectOutputStreamWithReplace2(baos);
+        oos2.writeObject(new WriteReplaceObject(replaceObject));
+        oos2.flush();
+        ois = new ObjectInputStream(
+                new ByteArrayInputStream(baos.toByteArray()));
+        obj = ois.readObject();
+        oos.close();
+        ois.close();
+        assertTrue("replaceObject has not been called", (obj instanceof Long));
 
         // Regression for HARMONY-3158
         Object obj1;
@@ -1305,7 +1320,8 @@
         oos.writeObject(ObjectStreamClass.lookup(Integer.class));
         oos.flush();
 
-        ois = new ObjectInputStream(new ByteArrayInputStream (baos.toByteArray()));
+        ois = new ObjectInputStream(
+                new ByteArrayInputStream(baos.toByteArray()));
         obj1 = ois.readObject();
         obj2 = ois.readObject();
         obj3 = ois.readObject();
@@ -1313,10 +1329,11 @@
         ois.close();
 
         assertTrue("1st replaceObject worked incorrectly", obj1 instanceof Long);
-        assertEquals("1st replaceObject worked incorrectly",
-                99, ((Long) obj1).longValue());
-        assertEquals("2nd replaceObject worked incorrectly", Integer.class, obj2);
+        assertEquals("1st replaceObject worked incorrectly", 99, ((Long) obj1)
+                .longValue());
+        assertEquals("2nd replaceObject worked incorrectly", Integer.class,
+                obj2);
         assertEquals("3rd replaceObject worked incorrectly",
                 ObjectStreamClass.class, obj3.getClass());
-	}
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java?rev=617085&r1=617084&r2=617085&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectStreamClassTest.java Thu Jan 31 02:04:05 2008
@@ -26,14 +26,16 @@
 import java.io.Serializable;
 import java.lang.reflect.Proxy;
 
-public class ObjectStreamClassTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
 
-	static class DummyClass implements Serializable {
-		private static final long serialVersionUID = 999999999999999L;
+public class ObjectStreamClassTest extends TestCase {
 
-		long bam = 999L;
+    static class DummyClass implements Serializable {
+        private static final long serialVersionUID = 999999999999999L;
 
-		int ham = 9999;
+        long bam = 999L;
+
+        int ham = 9999;
 
 		public static long getUID() {
 			return serialVersionUID;
@@ -41,6 +43,120 @@
 	}
     
     /**
+     * @tests java.io.ObjectStreamClass#forClass()
+     */
+    public void test_forClass() {
+        // Need to test during serialization to be sure an instance is
+        // returned
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        assertTrue("forClass returned an object: " + osc.forClass(), osc
+                .forClass().equals(DummyClass.class));
+    }
+
+    /**
+     * @tests java.io.ObjectStreamClass#getField(java.lang.String)
+     */
+    public void test_getFieldLjava_lang_String() {
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        assertEquals("getField did not return correct field", 'J', osc
+                .getField("bam").getTypeCode());
+        assertNull("getField did not null for non-existent field", osc
+                .getField("wham"));
+    }
+
+    /**
+     * @tests java.io.ObjectStreamClass#getFields()
+     */
+    public void test_getFields() {
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        ObjectStreamField[] osfArray = osc.getFields();
+        assertTrue(
+                "Array of fields should be of length 2 but is instead of length: "
+                        + osfArray.length, osfArray.length == 2);
+    }
+
+    /**
+     * @tests java.io.ObjectStreamClass#getName()
+     */
+    public void test_getName() {
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        assertTrue(
+                "getName returned incorrect name: " + osc.getName(),
+                osc
+                        .getName()
+                        .equals(
+                                "org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass"));
+    }
+
+    /**
+     * @tests java.io.ObjectStreamClass#getSerialVersionUID()
+     */
+    public void test_getSerialVersionUID() {
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        assertTrue("getSerialversionUID returned incorrect uid: "
+                + osc.getSerialVersionUID() + " instead of "
+                + DummyClass.getUID(), osc.getSerialVersionUID() == DummyClass
+                .getUID());
+    }
+
+    /**
+     * @tests java.io.ObjectStreamClass#toString()
+     */
+    public void test_toString() {
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        String oscString = osc.toString();
+
+        // The previous test was more specific than the spec so it was replaced
+        // with the test below
+        assertTrue("toString returned incorrect string: " + osc.toString(),
+                oscString.indexOf("serialVersionUID") >= 0
+                        && oscString.indexOf("999999999999999L") >= 0);
+        ;
+    }
+
+    /**
+     * @tests java.io.ObjectStreamClass#lookup(java.lang.Class)
+     */
+    public void test_lookupLjava_lang_Class() {
+        ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
+        assertTrue(
+                "lookup returned wrong class: " + osc.getName(),
+                osc
+                        .getName()
+                        .equals(
+                                "org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass"));
+    }
+
+    public void testSerialization() {
+        ObjectStreamClass osc = ObjectStreamClass
+                .lookup(ObjectStreamClass.class);
+        assertEquals(0, osc.getFields().length);
+    }
+
+    public void test_specialTypes() {
+        Class<?> proxyClass = Proxy.getProxyClass(this.getClass()
+                .getClassLoader(), new Class[] { Runnable.class });
+
+        ObjectStreamClass proxyStreamClass = ObjectStreamClass
+                .lookup(proxyClass);
+
+        assertEquals("Proxy classes should have zero serialVersionUID", 0,
+                proxyStreamClass.getSerialVersionUID());
+        ObjectStreamField[] proxyFields = proxyStreamClass.getFields();
+        assertEquals("Proxy classes should have no serialized fields", 0,
+                proxyFields.length);
+
+        ObjectStreamClass enumStreamClass = ObjectStreamClass
+                .lookup(Thread.State.class);
+
+        assertEquals("Enum classes should have zero serialVersionUID", 0,
+                enumStreamClass.getSerialVersionUID());
+        ObjectStreamField[] enumFields = enumStreamClass.getFields();
+        assertEquals("Enum classes should have no serialized fields", 0,
+                enumFields.length);
+    }
+    
+        /**
      * @since 1.6 
      */
     static class NonSerialzableClass {
@@ -66,80 +182,7 @@
         }
         
 	}
-
-	/**
-	 * @tests java.io.ObjectStreamClass#forClass()
-	 */
-	public void test_forClass() {
-		// Test for method java.lang.Class java.io.ObjectStreamClass.forClass()
-		// Need to test during serialization to be sure an instance is
-		// returned
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		assertTrue("forClass returned an object: " + osc.forClass(), osc
-				.forClass().equals(DummyClass.class));
-	}
-
-	/**
-	 * @tests java.io.ObjectStreamClass#getField(java.lang.String)
-	 */
-	public void test_getFieldLjava_lang_String() {
-		// Test for method java.io.ObjectStreamField
-		// java.io.ObjectStreamClass.getField(java.lang.String)
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		assertEquals("getField did not return correct field", 'J', osc.getField("bam")
-				.getTypeCode());
-		assertNull("getField did not null for non-existent field", osc
-				.getField("wham"));
-	}
-
-	/**
-	 * @tests java.io.ObjectStreamClass#getFields()
-	 */
-	public void test_getFields() {
-		// Test for method java.io.ObjectStreamField []
-		// java.io.ObjectStreamClass.getFields()
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		ObjectStreamField[] osfArray = osc.getFields();
-		assertTrue(
-				"Array of fields should be of length 2 but is instead of length: "
-						+ osfArray.length, osfArray.length == 2);
-	}
-
-	/**
-	 * @tests java.io.ObjectStreamClass#getName()
-	 */
-	public void test_getName() {
-		// Test for method java.lang.String java.io.ObjectStreamClass.getName()
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		assertTrue("getName returned incorrect name: " + osc.getName(), osc
-				.getName().equals(
-						"org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass"));
-	}
-
-	/**
-	 * @tests java.io.ObjectStreamClass#getSerialVersionUID()
-	 */
-	public void test_getSerialVersionUID() {
-		// Test for method long java.io.ObjectStreamClass.getSerialVersionUID()
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		assertTrue("getSerialversionUID returned incorrect uid: "
-				+ osc.getSerialVersionUID() + " instead of "
-				+ DummyClass.getUID(), osc.getSerialVersionUID() == DummyClass
-				.getUID());
-	}
-
-	/**
-	 * @tests java.io.ObjectStreamClass#lookup(java.lang.Class)
-	 */
-	public void test_lookupLjava_lang_Class() {
-		// Test for method java.io.ObjectStreamClass
-		// java.io.ObjectStreamClass.lookup(java.lang.Class)
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		assertTrue("lookup returned wrong class: " + osc.getName(), osc
-				.getName().equals(
-						"org.apache.harmony.luni.tests.java.io.ObjectStreamClassTest$DummyClass"));
-	}
-
+	
     /**
      * @tests java.io.ObjectStreamClass#lookupAny(java.lang.Class)
      * @since 1.6
@@ -167,46 +210,5 @@
         
     }
     
-	/**
-	 * @tests java.io.ObjectStreamClass#toString()
-	 */
-	public void test_toString() {
-		// Test for method java.lang.String java.io.ObjectStreamClass.toString()
-		ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
-		String oscString = osc.toString();
-		// The previous test was more specific than the spec so it was replaced
-		// with the test below
-		assertTrue("toString returned incorrect string: " + osc.toString(),
-				oscString.indexOf("serialVersionUID") >= 0
-						&& oscString.indexOf("999999999999999L") >= 0);
-		;
-	}
-
-    public void testSerialization() {
-        ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectStreamClass.class);
-        assertEquals(0, osc.getFields().length);
-    }
     
-    public void test_specialTypes() {
-        Class<?> proxyClass = Proxy.getProxyClass(this.getClass()
-                .getClassLoader(), new Class[] { Runnable.class });
-
-        ObjectStreamClass proxyStreamClass = ObjectStreamClass
-                .lookup(proxyClass);
-
-        assertEquals("Proxy classes should have zero serialVersionUID", 0,
-                proxyStreamClass.getSerialVersionUID());
-        ObjectStreamField[] proxyFields = proxyStreamClass.getFields();
-        assertEquals("Proxy classes should have no serialized fields", 0,
-                proxyFields.length);
-
-        ObjectStreamClass enumStreamClass = ObjectStreamClass
-                .lookup(Thread.State.class);
-
-        assertEquals("Enum classes should have zero serialVersionUID", 0,
-                enumStreamClass.getSerialVersionUID());
-        ObjectStreamField[] enumFields = enumStreamClass.getFields();
-        assertEquals("Enum classes should have no serialized fields", 0,
-                enumFields.length);
-    }
 }